1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-13 16:22:44 +03:00

Ensure that all uses of <ctype.h> functions are applied to unsigned-char

values, whether the local char type is signed or not.  This is necessary
for portability.  Per discussion on pghackers around 9/16/00.
This commit is contained in:
Tom Lane
2000-12-03 20:45:40 +00:00
parent 4d2a506526
commit a27b691e29
59 changed files with 318 additions and 303 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: inet_aton.c,v 1.17 1999/07/17 04:12:09 momjian Exp $
/* $Id: inet_aton.c,v 1.18 2000/12/03 20:45:34 tgl Exp $
*
* This inet_aton() function was taken from the GNU C library and
* incorporated into Postgres for those systems which do not have this
@@ -83,16 +83,16 @@ inet_aton(const char *cp, struct in_addr * addr)
}
while ((c = *cp) != '\0')
{
if (isascii(c) && isdigit(c))
if (isdigit((unsigned char) c))
{
val = (val * base) + (c - '0');
cp++;
continue;
}
if (base == 16 && isascii(c) && isxdigit(c))
if (base == 16 && isxdigit((unsigned char) c))
{
val = (val << 4) +
(c + 10 - (islower(c) ? 'a' : 'A'));
(c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
cp++;
continue;
}
@@ -114,10 +114,11 @@ inet_aton(const char *cp, struct in_addr * addr)
}
/*
* Check for trailing characters.
* Check for trailing junk.
*/
if (*cp && (!isascii(*cp) || !isspace(*cp)))
return 0;
while (*cp)
if (!isspace((unsigned char) *cp++))
return 0;
/*
* Concoct the address according to the number of parts specified.

View File

@@ -74,7 +74,7 @@ typedef unsigned long ulong_long;
* causing nast effects.
**************************************************************/
/*static char _id[] = "$Id: snprintf.c,v 1.27 1999/09/09 03:13:22 tgl Exp $";*/
/*static char _id[] = "$Id: snprintf.c,v 1.28 2000/12/03 20:45:34 tgl Exp $";*/
static char *end;
static int SnprfOverflow;
@@ -457,7 +457,7 @@ static void
dopr_outch(int c)
{
#ifdef NOT_USED
if (iscntrl(c) && c != '\n' && c != '\t')
if (iscntrl((unsigned char) c) && c != '\n' && c != '\t')
{
c = '@' + (c & 0x1F);
if (end == 0 || output < end)

View File

@@ -58,7 +58,7 @@ int base;
{
const char *s = nptr;
unsigned long acc;
int c;
unsigned char c;
unsigned long cutoff;
int neg = 0,
any,
@@ -109,7 +109,7 @@ int base;
cutoff = neg ? -(unsigned long) LONG_MIN : LONG_MAX;
cutlim = cutoff % (unsigned long) base;
cutoff /= (unsigned long) base;
for (acc = 0, any = 0;; c = *s++)
for (acc = 0, any = 0; ; c = *s++)
{
if (isdigit(c))
c -= '0';
@@ -117,9 +117,9 @@ int base;
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
if ((int) c >= base)
break;
if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
if (any < 0 || acc > cutoff || acc == cutoff && (int) c > cutlim)
any = -1;
else
{

View File

@@ -96,9 +96,9 @@ register int base;
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
if ((int) c >= base)
break;
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
if (any < 0 || acc > cutoff || (acc == cutoff && (int) c > cutlim))
any = -1;
else
{