Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita27b691

Browse files
committed
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 necessaryfor portability. Per discussion on pghackers around 9/16/00.
1 parent4d2a506 commita27b691

File tree

59 files changed

+318
-303
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+318
-303
lines changed

‎contrib/fulltextindex/fti.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include"postgres.h"
22
#include"executor/spi.h"
33
#include"commands/trigger.h"
4-
#include<ctype.h>/* tolower */
4+
#include<ctype.h>
55
#include<stdio.h>/* debugging */
66

77
/*
@@ -256,10 +256,9 @@ fti(PG_FUNCTION_ARGS)
256256
char*string=column;
257257

258258
while (*string!='\0')
259-
{/* placed 'really' inline. */
260-
*string=tolower(*string);/* some compilers will
261-
* choke */
262-
string++;/* on 'inline' keyword */
259+
{
260+
*string=tolower((unsignedchar)*string);
261+
string++;
263262
}
264263

265264
data= (structvarlena*)palloc(sizeof(int32)+strlen(column)+1);
@@ -312,9 +311,9 @@ breakup(char *string, char *substring)
312311
* (ie. 'string$%^&', last_start first points to '&', and after
313312
* this to 'g'
314313
*/
315-
if (!isalnum((int)*last_start))
314+
if (!isalnum((unsignedchar)*last_start))
316315
{
317-
while (!isalnum((int)*last_start)&&
316+
while (!isalnum((unsignedchar)*last_start)&&
318317
last_start>string)
319318
last_start--;
320319
cur_pos=last_start;
@@ -323,7 +322,7 @@ breakup(char *string, char *substring)
323322
cur_pos--;/* substrings are at minimum 2 characters
324323
* long */
325324

326-
if (isalnum((int)*cur_pos))
325+
if (isalnum((unsignedchar)*cur_pos))
327326
{
328327
/* Houston, we have a substring! :) */
329328
memcpy(substring,cur_pos,last_start-cur_pos+1);

‎contrib/soundex/soundex.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/contrib/soundex/Attic/soundex.c,v 1.8 2000/11/20 20:36:57 tgl Exp $ */
1+
/* $Header: /cvsroot/pgsql/contrib/soundex/Attic/soundex.c,v 1.9 2000/12/03 20:45:31 tgl Exp $ */
22
#include"postgres.h"
33
#include"fmgr.h"
44
#include"utils/builtins.h"
@@ -42,7 +42,7 @@ text_soundex(PG_FUNCTION_ARGS)
4242

4343
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
4444
staticconstchar*soundex_table="01230120022455012623010202";
45-
#definesoundex_code(letter) soundex_table[toupper(letter) - 'A']
45+
#definesoundex_code(letter) soundex_table[toupper((unsigned char) (letter)) - 'A']
4646

4747

4848
staticvoid
@@ -56,7 +56,7 @@ soundex(const char *instr, char *outstr)
5656
outstr[SOUNDEX_LEN]='\0';
5757

5858
/* Skip leading non-alphabetic characters */
59-
while (!isalpha(instr[0])&&instr[0])
59+
while (!isalpha((unsignedchar)instr[0])&&instr[0])
6060
++instr;
6161

6262
/* No string left */
@@ -67,12 +67,13 @@ soundex(const char *instr, char *outstr)
6767
}
6868

6969
/* Take the first letter as is */
70-
*outstr++= (char)toupper(*instr++);
70+
*outstr++= (char)toupper((unsignedchar)*instr++);
7171

7272
count=1;
7373
while (*instr&&count<SOUNDEX_LEN)
7474
{
75-
if (isalpha(*instr)&&soundex_code(*instr)!=soundex_code(*(instr-1)))
75+
if (isalpha((unsignedchar)*instr)&&
76+
soundex_code(*instr)!=soundex_code(*(instr-1)))
7677
{
7778
*outstr=soundex_code(instr[0]);
7879
if (*outstr!='0')

‎contrib/spi/preprocessor/step1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ strtoupper(char *string)
66
inti;
77

88
for (i=0;i<strlen(string);i++)
9-
string[i]=toupper(string[i]);
9+
string[i]=toupper((unsignedchar)string[i]);
1010
returnstring;
1111
}
1212

‎contrib/spi/refint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include"executor/spi.h"/* this is what you need to work with SPI */
77
#include"commands/trigger.h"/* -"- and triggers */
8-
#include<ctype.h>/* tolower () */
8+
#include<ctype.h>
99

1010

1111
externDatumcheck_primary_key(PG_FUNCTION_ARGS);
@@ -293,7 +293,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
293293
nrefs=pg_atoi(args[0],sizeof(int),0);
294294
if (nrefs<1)
295295
elog(ERROR,"check_foreign_key: %d (< 1) number of references specified",nrefs);
296-
action=tolower(*(args[1]));
296+
action=tolower((unsignedchar)*(args[1]));
297297
if (action!='r'&&action!='c'&&action!='s')
298298
elog(ERROR,"check_foreign_key: invalid action %s",args[1]);
299299
nargs-=2;

‎contrib/spi/timetravel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include"executor/spi.h"/* this is what you need to work with SPI */
77
#include"commands/trigger.h"/* -"- and triggers */
8-
#include<ctype.h>/* tolower () */
8+
#include<ctype.h>
99

1010
#defineABSTIMEOID702/* it should be in pg_type.h */
1111

@@ -376,7 +376,7 @@ set_timetravel(PG_FUNCTION_ARGS)
376376
NameGetDatum(relname)));
377377
d=TTOff[nTTOff]=malloc(strlen(rname)+1);
378378
while (*s)
379-
*d++=tolower(*s++);
379+
*d++=tolower((unsignedchar)*s++);
380380
*d=0;
381381
pfree(rname);
382382
nTTOff++;

‎contrib/string/string_io.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
#defineDIGIT(val)((val) + '0')
2929
#defineISOCTAL(c)(((c) >= '0') && ((c) <= '7'))
3030
#ifndefISO8859
31-
#defineNOTPRINTABLE(c) (!isprint(c))
31+
#defineNOTPRINTABLE(c) (!isprint((unsigned char) (c)))
3232
#else
33-
#defineNOTPRINTABLE(c) (!isprint(c) && ((c) < 0xa0))
33+
#defineNOTPRINTABLE(c) (!isprint((unsigned char) (c)) && \
34+
((unsigned char) (c) < (unsigned char) 0xa0))
3435
#endif
3536

3637
/*

‎src/backend/commands/define.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.49 2000/11/20 20:36:47 tgl Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.50 2000/12/03 20:45:33 tgl Exp $
1414
*
1515
* DESCRIPTION
1616
* The "DefineFoo" routines take the parse tree and pick out the
@@ -71,7 +71,7 @@ case_translate_language_name(const char *input, char *output)
7171
inti;
7272

7373
for (i=0;i<NAMEDATALEN-1&&input[i];++i)
74-
output[i]=tolower(input[i]);
74+
output[i]=tolower((unsignedchar)input[i]);
7575

7676
output[i]='\0';
7777

‎src/backend/commands/proclang.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ case_translate_language_name(const char *input, char *output)
3131
inti;
3232

3333
for (i=0;i<NAMEDATALEN&&input[i];++i)
34-
output[i]=tolower(input[i]);
34+
output[i]=tolower((unsignedchar)input[i]);
3535

3636
output[i]='\0';
3737

‎src/backend/commands/sequence.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,8 @@ get_seq_name(text *seqin)
473473
*/
474474
for (;*rawname;rawname++)
475475
{
476-
if (isascii((int)*rawname)&&
477-
isupper((int)*rawname))
478-
*rawname=tolower(*rawname);
476+
if (isupper((unsignedchar)*rawname))
477+
*rawname=tolower((unsignedchar)*rawname);
479478
}
480479
}
481480
returnseqname;

‎src/backend/commands/variable.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.43 2000/10/26 17:31:34 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.44 2000/12/03 20:45:33 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -104,7 +104,7 @@ get_token(char **tok, char **val, char *str)
104104
returnNULL;
105105

106106
/* skip leading white space */
107-
while (isspace((int)*str))
107+
while (isspace((unsignedchar)*str))
108108
str++;
109109

110110
/* end of string? then return NULL */
@@ -118,15 +118,16 @@ get_token(char **tok, char **val, char *str)
118118
*tok=str;
119119

120120
/* Advance to end of word */
121-
while (*str&& !isspace((int)*str)&&*str!=','&&*str!='=')
121+
while (*str&& !isspace((unsignedchar)*str)&&
122+
*str!=','&&*str!='=')
122123
str++;
123124

124125
/* Terminate word string for caller */
125126
ch=*str;
126127
*str='\0';
127128

128129
/* Skip any whitespace */
129-
while (isspace((int)ch))
130+
while (isspace((unsignedchar)ch))
130131
ch=*(++str);
131132

132133
/* end of string? */
@@ -144,7 +145,7 @@ get_token(char **tok, char **val, char *str)
144145
str++;
145146

146147
/* skip whitespace after '=' */
147-
while (isspace((int)*str))
148+
while (isspace((unsignedchar)*str))
148149
str++;
149150

150151
if (*str==','||*str=='\0')
@@ -154,15 +155,15 @@ get_token(char **tok, char **val, char *str)
154155
*val=str;
155156

156157
/* Advance to end of word */
157-
while (*str&& !isspace((int)*str)&&*str!=',')
158+
while (*str&& !isspace((unsignedchar)*str)&&*str!=',')
158159
str++;
159160

160161
/* Terminate word string for caller */
161162
ch=*str;
162163
*str='\0';
163164

164165
/* Skip any whitespace */
165-
while (isspace((int)ch))
166+
while (isspace((unsignedchar)ch))
166167
ch=*(++str);
167168

168169
/* end of string? */

‎src/backend/libpq/auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.49 2000/08/25 10:00:30 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.50 2000/12/03 20:45:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -23,7 +23,7 @@
2323
#include<netdb.h>/* for MAXHOSTNAMELEN on some */
2424
#endif
2525
#include<pwd.h>
26-
#include<ctype.h>/* isspace() declaration */
26+
#include<ctype.h>
2727

2828
#include<sys/types.h>/* needed by in.h on Ultrix */
2929
#include<netinet/in.h>

‎src/backend/nodes/outfuncs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.134 2000/11/16 22:30:23 tgl Exp $
9+
*$Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.135 2000/12/03 20:45:33 tgl Exp $
1010
*
1111
* NOTES
1212
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -70,8 +70,8 @@ _outToken(StringInfo str, char *s)
7070
if (*s=='<'||
7171
*s=='\"'||
7272
*s=='@'||
73-
isdigit((int)*s)||
74-
(*s=='-'&&isdigit((int)s[1])))
73+
isdigit((unsignedchar)*s)||
74+
(*s=='-'&&isdigit((unsignedchar)s[1])))
7575
appendStringInfoChar(str,'\\');
7676
while (*s)
7777
{

‎src/backend/nodes/read.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.25 2000/10/31 13:59:52 petere Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.26 2000/12/03 20:45:33 tgl Exp $
1313
*
1414
* HISTORY
1515
* AUTHORDATEMAJOR EVENT
@@ -205,8 +205,8 @@ nodeTokenType(char *token, int length)
205205
numlen=length;
206206
if (*numptr=='+'||*numptr=='-')
207207
numptr++,numlen--;
208-
if ((numlen>0&&isdigit((int)*numptr))||
209-
(numlen>1&&*numptr=='.'&&isdigit((int)numptr[1])))
208+
if ((numlen>0&&isdigit((unsignedchar)*numptr))||
209+
(numlen>1&&*numptr=='.'&&isdigit((unsignedchar)numptr[1])))
210210
{
211211

212212
/*

‎src/backend/parser/parse_node.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.49 2000/11/16 22:30:28 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.50 2000/12/03 20:45:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -533,7 +533,7 @@ fitsInFloat(Value *value)
533533
ndigits=0;
534534
for (;*ptr;ptr++)
535535
{
536-
if (isdigit((int)*ptr))
536+
if (isdigit((unsignedchar)*ptr))
537537
ndigits++;
538538
elseif (*ptr=='e'||*ptr=='E')
539539
break;/* don't count digits in exponent */

‎src/backend/parser/scan.l

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.83 2000/11/16 22:47:44 petere Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.84 2000/12/03 20:45:34 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -478,9 +478,8 @@ other.
478478
ScanKeyword*keyword;
479479

480480
for(i =0; yytext[i]; i++)
481-
if (isascii((int) yytext[i]) &&
482-
isupper((int) yytext[i]))
483-
yytext[i] =tolower(yytext[i]);
481+
if (isupper((unsignedchar) yytext[i]))
482+
yytext[i] =tolower((unsignedchar) yytext[i]);
484483
if (i >= NAMEDATALEN)
485484
{
486485
#ifdef MULTIBYTE

‎src/backend/port/inet_aton.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: inet_aton.c,v 1.17 1999/07/17 04:12:09 momjian Exp $
1+
/* $Id: inet_aton.c,v 1.18 2000/12/03 20:45:34 tgl Exp $
22
*
33
*This inet_aton() function was taken from the GNU C library and
44
*incorporated into Postgres for those systems which do not have this
@@ -83,16 +83,16 @@ inet_aton(const char *cp, struct in_addr * addr)
8383
}
8484
while ((c=*cp)!='\0')
8585
{
86-
if (isascii(c)&&isdigit(c))
86+
if (isdigit((unsignedchar)c))
8787
{
8888
val= (val*base)+ (c-'0');
8989
cp++;
9090
continue;
9191
}
92-
if (base==16&&isascii(c)&&isxdigit(c))
92+
if (base==16&&isxdigit((unsignedchar)c))
9393
{
9494
val= (val <<4)+
95-
(c+10- (islower(c) ?'a' :'A'));
95+
(c+10- (islower((unsignedchar)c) ?'a' :'A'));
9696
cp++;
9797
continue;
9898
}
@@ -114,10 +114,11 @@ inet_aton(const char *cp, struct in_addr * addr)
114114
}
115115

116116
/*
117-
* Check for trailingcharacters.
117+
* Check for trailingjunk.
118118
*/
119-
if (*cp&& (!isascii(*cp)|| !isspace(*cp)))
120-
return0;
119+
while (*cp)
120+
if (!isspace((unsignedchar)*cp++))
121+
return0;
121122

122123
/*
123124
* Concoct the address according to the number of parts specified.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp