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? */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp