Commit 0ab3595e authored by Tom Lane's avatar Tom Lane

Rename strtoi() to strtoint().

NetBSD has seen fit to invent a libc function named strtoi(), which
conflicts with the long-established static functions of the same name in
datetime.c and ecpg's interval.c.  While muttering darkly about intrusions
on application namespace, we'll rename our functions to avoid the conflict.

Back-patch to all supported branches, since this would affect attempts
to build any of them on recent NetBSD.

Thomas Munro
parent b87b2f4b
......@@ -256,10 +256,10 @@ static const datetkn *abbrevcache[MAXDATEFIELDS] = {NULL};
/*
* strtoi --- just like strtol, but returns int not long
* strtoint --- just like strtol, but returns int not long
*/
static int
strtoi(const char *nptr, char **endptr, int base)
strtoint(const char *nptr, char **endptr, int base)
{
long val;
......@@ -898,7 +898,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
return DTERR_BAD_FORMAT;
errno = 0;
val = strtoi(field[i], &cp, 10);
val = strtoint(field[i], &cp, 10);
if (errno == ERANGE || val < 0)
return DTERR_FIELD_OVERFLOW;
......@@ -1062,7 +1062,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
int val;
errno = 0;
val = strtoi(field[i], &cp, 10);
val = strtoint(field[i], &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
......@@ -1929,7 +1929,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
}
errno = 0;
val = strtoi(field[i], &cp, 10);
val = strtoint(field[i], &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
......@@ -2600,13 +2600,13 @@ DecodeTime(char *str, int fmask, int range,
*tmask = DTK_TIME_M;
errno = 0;
tm->tm_hour = strtoi(str, &cp, 10);
tm->tm_hour = strtoint(str, &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
if (*cp != ':')
return DTERR_BAD_FORMAT;
errno = 0;
tm->tm_min = strtoi(cp + 1, &cp, 10);
tm->tm_min = strtoint(cp + 1, &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
if (*cp == '\0')
......@@ -2634,7 +2634,7 @@ DecodeTime(char *str, int fmask, int range,
else if (*cp == ':')
{
errno = 0;
tm->tm_sec = strtoi(cp + 1, &cp, 10);
tm->tm_sec = strtoint(cp + 1, &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
if (*cp == '\0')
......@@ -2684,7 +2684,7 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask,
*tmask = 0;
errno = 0;
val = strtoi(str, &cp, 10);
val = strtoint(str, &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
if (cp == str)
......@@ -2963,7 +2963,7 @@ DecodeTimezone(char *str, int *tzp)
return DTERR_BAD_FORMAT;
errno = 0;
hr = strtoi(str + 1, &cp, 10);
hr = strtoint(str + 1, &cp, 10);
if (errno == ERANGE)
return DTERR_TZDISP_OVERFLOW;
......@@ -2971,13 +2971,13 @@ DecodeTimezone(char *str, int *tzp)
if (*cp == ':')
{
errno = 0;
min = strtoi(cp + 1, &cp, 10);
min = strtoint(cp + 1, &cp, 10);
if (errno == ERANGE)
return DTERR_TZDISP_OVERFLOW;
if (*cp == ':')
{
errno = 0;
sec = strtoi(cp + 1, &cp, 10);
sec = strtoint(cp + 1, &cp, 10);
if (errno == ERANGE)
return DTERR_TZDISP_OVERFLOW;
}
......@@ -3250,7 +3250,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
}
errno = 0;
val = strtoi(field[i], &cp, 10);
val = strtoint(field[i], &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
......@@ -3259,7 +3259,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
/* SQL "years-months" syntax */
int val2;
val2 = strtoi(cp + 1, &cp, 10);
val2 = strtoint(cp + 1, &cp, 10);
if (errno == ERANGE || val2 < 0 || val2 >= MONTHS_PER_YEAR)
return DTERR_FIELD_OVERFLOW;
if (*cp != '\0')
......
......@@ -16,7 +16,7 @@
/* copy&pasted from .../src/backend/utils/adt/datetime.c */
static int
strtoi(const char *nptr, char **endptr, int base)
strtoint(const char *nptr, char **endptr, int base)
{
long val;
......@@ -448,7 +448,7 @@ DecodeInterval(char **field, int *ftype, int nf, /* int range, */
}
errno = 0;
val = strtoi(field[i], &cp, 10);
val = strtoint(field[i], &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
......@@ -457,7 +457,7 @@ DecodeInterval(char **field, int *ftype, int nf, /* int range, */
/* SQL "years-months" syntax */
int val2;
val2 = strtoi(cp + 1, &cp, 10);
val2 = strtoint(cp + 1, &cp, 10);
if (errno == ERANGE || val2 < 0 || val2 >= MONTHS_PER_YEAR)
return DTERR_FIELD_OVERFLOW;
if (*cp != '\0')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment