mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-04 17:37:19 +02:00
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
This commit is contained in:
parent
3debaa603f
commit
bdf7744f73
@ -252,10 +252,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;
|
||||
|
||||
@ -829,7 +829,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;
|
||||
|
||||
@ -993,7 +993,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;
|
||||
|
||||
@ -1860,7 +1860,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;
|
||||
|
||||
@ -2531,13 +2531,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')
|
||||
@ -2565,7 +2565,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')
|
||||
@ -2615,7 +2615,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)
|
||||
@ -2894,7 +2894,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;
|
||||
|
||||
@ -2902,13 +2902,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;
|
||||
}
|
||||
@ -3181,7 +3181,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;
|
||||
|
||||
@ -3190,7 +3190,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')
|
||||
|
Loading…
Reference in New Issue
Block a user