1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-21 00:42:43 +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

@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.68 2000/11/20 03:51:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.69 2000/12/03 20:45:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -537,8 +537,8 @@ cppline {space}*#(.*\\{line_end})*.*
/* this should leave the last byte set to '\0' */
strncpy(lower_text, yytext, NAMEDATALEN-1);
for(i = 0; lower_text[i]; i++)
if (isascii((int)lower_text[i]) && isupper((int) lower_text[i]))
lower_text[i] = tolower(lower_text[i]);
if (isupper((unsigned char) lower_text[i]))
lower_text[i] = tolower((unsigned char) lower_text[i]);
if (i >= NAMEDATALEN)
{
@@ -755,7 +755,10 @@ cppline {space}*#(.*\\{line_end})*.*
/* skip the ";" and trailing whitespace. Note that yytext contains
at least one non-space character plus the ";" */
for ( i = strlen(yytext)-2; i > 0 && isspace((int) yytext[i]); i-- ) {}
for ( i = strlen(yytext)-2;
i > 0 && isspace((unsigned char) yytext[i]);
i-- )
{}
yytext[i+1] = '\0';
for ( defptr = defines; defptr != NULL &&
@@ -827,7 +830,10 @@ cppline {space}*#(.*\\{line_end})*.*
/* skip the ";" and trailing whitespace. Note that yytext contains
at least one non-space character plus the ";" */
for ( i = strlen(yytext)-2; i > 0 && isspace((int) yytext[i]); i-- ) {}
for ( i = strlen(yytext)-2;
i > 0 && isspace((unsigned char) yytext[i]);
i-- )
{}
yytext[i+1] = '\0';
yyin = NULL;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.50 2000/11/27 13:29:32 wieck Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.51 2000/12/03 20:45:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1846,7 +1846,7 @@ Pg_listen(ClientData cData, Tcl_Interp *interp, int argc, char *argv[])
char *reld = caserelname;
while (*rels)
*reld++ = tolower(*rels++);
*reld++ = tolower((unsigned char) *rels++);
*reld = '\0';
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.152 2000/11/30 23:20:51 tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.153 2000/12/03 20:45:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2248,20 +2248,21 @@ int parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) {
line[strlen(line)-1] = 0;
/* ignore leading blanks */
while(*line && isspace(line[0]))
line++;
while(*line && isspace((unsigned char) line[0]))
line++;
/* ignore comments and empty lines */
if(strlen(line) == 0 || line[0] == '#')
continue;
continue;
/* Check for right groupname */
if(line[0] == '[') {
if(group_found) {
/* group info already read */
fclose(f);
return 0;
}
if(line[0] == '[')
{
if(group_found) {
/* group info already read */
fclose(f);
return 0;
}
if(strncmp(line+1, service, strlen(service)) == 0 &&
line[strlen(service)+1] == ']')
@@ -2358,7 +2359,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
while (*cp)
{
/* Skip blanks before the parameter name */
if (isspace((int) *cp))
if (isspace((unsigned char) *cp))
{
cp++;
continue;
@@ -2370,12 +2371,12 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
{
if (*cp == '=')
break;
if (isspace((int) *cp))
if (isspace((unsigned char) *cp))
{
*cp++ = '\0';
while (*cp)
{
if (!isspace((int) *cp))
if (!isspace((unsigned char) *cp))
break;
cp++;
}
@@ -2399,7 +2400,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
/* Skip blanks after the '=' */
while (*cp)
{
if (!isspace((int) *cp))
if (!isspace((unsigned char) *cp))
break;
cp++;
}
@@ -2412,7 +2413,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
cp2 = pval;
while (*cp)
{
if (isspace((int) *cp))
if (isspace((unsigned char) *cp))
{
*cp++ = '\0';
break;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.96 2000/06/14 18:17:58 petere Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.97 2000/12/03 20:45:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1955,9 +1955,8 @@ PQfnumber(const PGresult *res, const char *field_name)
}
else
for (i = 0; field_case[i]; i++)
if (isascii((int) field_case[i]) &&
isupper((int) field_case[i]))
field_case[i] = tolower(field_case[i]);
if (isupper((unsigned char) field_case[i]))
field_case[i] = tolower((unsigned char) field_case[i]);
for (i = 0; i < res->numAttributes; i++)
{

View File

@@ -284,9 +284,9 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
nval++;
/* skip the current token */
while ((*vp != '\0') && (! isspace(*vp))) vp++;
while ((*vp != '\0') && (! isspace((unsigned char) *vp))) vp++;
/* and skip the space to the next token */
while ((*vp != '\0') && (isspace(*vp))) vp++;
while ((*vp != '\0') && (isspace((unsigned char) *vp))) vp++;
if (*vp == '\0')
break;
}
@@ -1126,10 +1126,10 @@ static char escape[1024];
char key[33];
/* Separate off the key, skipping leading and trailing whitespace */
while ((*value != '\0') && isspace(*value)) value++;
while ((*value != '\0') && isspace((unsigned char) *value)) value++;
sscanf(value, "%32s", key);
while ((*value != '\0') && (! isspace(*value))) value++;
while ((*value != '\0') && isspace(*value)) value++;
while ((*value != '\0') && (! isspace((unsigned char) *value))) value++;
while ((*value != '\0') && isspace((unsigned char) *value)) value++;
mylog("convert_escape: key='%s', val='%s'\n", key, value);
@@ -1149,12 +1149,14 @@ char key[33];
char *mapFunc;
while ((*funcEnd != '\0') && (*funcEnd != '(') &&
(! isspace(*funcEnd))) funcEnd++;
(! isspace((unsigned char) *funcEnd)))
funcEnd++;
svchar = *funcEnd;
*funcEnd = '\0';
sscanf(value, "%32s", key);
*funcEnd = svchar;
while ((*funcEnd != '\0') && isspace(*funcEnd)) funcEnd++;
while ((*funcEnd != '\0') && isspace((unsigned char) *funcEnd))
funcEnd++;
/* We expect left parenthesis here,
* else return fn body as-is since it is
@@ -1430,18 +1432,18 @@ int i, o=0;
void
encode(char *in, char *out)
{
unsigned int i, o = 0;
unsigned int i, o = 0;
for (i = 0; i < strlen(in); i++) {
if ( in[i] == '+') {
sprintf(&out[o], "%%2B");
o += 3;
}
else if ( isspace(in[i])) {
else if ( isspace((unsigned char) in[i])) {
out[o++] = '+';
}
else if ( ! isalnum(in[i])) {
sprintf(&out[o], "%%%02x", in[i]);
else if ( ! isalnum((unsigned char) in[i])) {
sprintf(&out[o], "%%%02x", (unsigned char) in[i]);
o += 3;
}
else

View File

@@ -144,8 +144,8 @@ GetPrivateProfileString(char *theSection, /* section name */
{
aStart = aLine + 1;
aString--;
while (isspace(*aStart)) aStart++;
while (isspace(*aString)) aString--;
while (isspace((unsigned char) *aStart)) aStart++;
while (isspace((unsigned char) *aString)) aString--;
*(aString+1) = '\0';
/* accept as matched if NULL key or exact match */
@@ -188,7 +188,7 @@ GetPrivateProfileString(char *theSection, /* section name */
}
aStart = aLine;
while(isspace(*aStart)) aStart++;
while (isspace((unsigned char) *aStart)) aStart++;
/* strip trailing blanks from key */

View File

@@ -28,7 +28,7 @@
#include "iodbc.h"
#include "isql.h"
#include "isqlext.h"
#include <ctype.h> /* for tolower function */
#include <ctype.h>
#else
#include <windows.h>
#include <sql.h>
@@ -2615,7 +2615,7 @@ Int2 result_cols;
/* Handle action (i.e., 'cascade', 'restrict', 'setnull') */
switch(tolower(ptr[0])) {
switch(tolower((unsigned char) ptr[0])) {
case 'c':
action = SQL_CASCADE;
break;

View File

@@ -55,7 +55,7 @@ char qc, in_escape = FALSE;
smax--;
/* skip leading delimiters */
while (isspace(s[i]) || s[i] == ',') {
while (isspace((unsigned char) s[i]) || s[i] == ',') {
/* mylog("skipping '%c'\n", s[i]); */
i++;
}
@@ -70,7 +70,8 @@ char qc, in_escape = FALSE;
if (numeric) *numeric = FALSE;
/* get the next token */
while ( ! isspace(s[i]) && s[i] != ',' && s[i] != '\0' && out != smax) {
while ( ! isspace((unsigned char) s[i]) && s[i] != ',' &&
s[i] != '\0' && out != smax) {
/* Handle quoted stuff */
if ( out == 0 && (s[i] == '\"' || s[i] == '\'')) {
@@ -102,16 +103,16 @@ char qc, in_escape = FALSE;
}
/* Check for numeric literals */
if ( out == 0 && isdigit(s[i])) {
if ( out == 0 && isdigit((unsigned char) s[i])) {
if (numeric) *numeric = TRUE;
token[out++] = s[i++];
while ( isalnum(s[i]) || s[i] == '.')
while ( isalnum((unsigned char) s[i]) || s[i] == '.')
token[out++] = s[i++];
break;
}
if ( ispunct(s[i]) && s[i] != '_') {
if ( ispunct((unsigned char) s[i]) && s[i] != '_') {
mylog("got ispunct: s[%d] = '%c'\n", i, s[i]);
if (out == 0) {
@@ -133,7 +134,7 @@ char qc, in_escape = FALSE;
token[out] = '\0';
/* find the delimiter */
while ( isspace(s[i]))
while ( isspace((unsigned char) s[i]))
i++;
/* return the most priority delimiter */
@@ -148,7 +149,7 @@ char qc, in_escape = FALSE;
}
/* skip trailing blanks */
while ( isspace(s[i])) {
while ( isspace((unsigned char) s[i])) {
i++;
}

View File

@@ -1,6 +1,6 @@
/*-------------------------------------------------------
*
* $Id: Pg.xs,v 1.15 2000/10/24 17:00:00 tgl Exp $ with patch for NULs
* $Id: Pg.xs,v 1.16 2000/12/03 20:45:40 tgl Exp $ with patch for NULs
*
* Copyright (c) 1997, 1998 Edmund Mergl
*
@@ -215,7 +215,7 @@ PQconnectdb(conninfo)
}
} else {
while (*ptr && *ptr != ' ' && *ptr != '\t') {
*ptr = tolower(*ptr);
*ptr = tolower((unsigned char) *ptr);
ptr++;
}
}
@@ -734,7 +734,7 @@ connectdb(conninfo)
}
} else {
while (*ptr && *ptr != ' ' && *ptr != '\t') {
*ptr = tolower(*ptr);
*ptr = tolower((unsigned char) *ptr);
ptr++;
}
}