Skip to content

Commit 89ee5b8

Browse files
committed
Fix some more compatibility issues (ctype.h macros must never be passed
signed chars...)
1 parent eeaef25 commit 89ee5b8

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

contrib/tsearch2/dict_syn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ findwrd(char *in, char **end)
3737
char *start;
3838

3939
*end = NULL;
40-
while (*in && isspace(*in))
40+
while (*in && isspace((unsigned char) *in))
4141
in++;
4242

4343
if (!in)
4444
return NULL;
4545
start = in;
4646

47-
while (*in && !isspace(*in))
47+
while (*in && !isspace((unsigned char) *in))
4848
in++;
4949

5050
*end = in;

contrib/tsearch2/prs_dcfg.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ parse_cfgdict(text *in, Map ** m)
6666
{
6767
if (state == CS_WAITKEY)
6868
{
69-
if (isalpha(*ptr))
69+
if (isalpha((unsigned char) *ptr))
7070
{
7171
begin = ptr;
7272
state = CS_INKEY;
7373
}
74-
else if (!isspace(*ptr))
74+
else if (!isspace((unsigned char) *ptr))
7575
ereport(ERROR,
7676
(errcode(ERRCODE_SYNTAX_ERROR),
7777
errmsg("syntax error"),
@@ -80,7 +80,7 @@ parse_cfgdict(text *in, Map ** m)
8080
}
8181
else if (state == CS_INKEY)
8282
{
83-
if (isspace(*ptr))
83+
if (isspace((unsigned char) *ptr))
8484
{
8585
mptr->key = nstrdup(begin, ptr - begin);
8686
state = CS_WAITEQ;
@@ -90,7 +90,7 @@ parse_cfgdict(text *in, Map ** m)
9090
mptr->key = nstrdup(begin, ptr - begin);
9191
state = CS_WAITVALUE;
9292
}
93-
else if (!isalpha(*ptr))
93+
else if (!isalpha((unsigned char) *ptr))
9494
ereport(ERROR,
9595
(errcode(ERRCODE_SYNTAX_ERROR),
9696
errmsg("syntax error"),
@@ -101,7 +101,7 @@ parse_cfgdict(text *in, Map ** m)
101101
{
102102
if (*ptr == '=')
103103
state = CS_WAITVALUE;
104-
else if (!isspace(*ptr))
104+
else if (!isspace((unsigned char) *ptr))
105105
ereport(ERROR,
106106
(errcode(ERRCODE_SYNTAX_ERROR),
107107
errmsg("syntax error"),
@@ -115,7 +115,7 @@ parse_cfgdict(text *in, Map ** m)
115115
begin = ptr + 1;
116116
state = CS_INVALUE;
117117
}
118-
else if (!isspace(*ptr))
118+
else if (!isspace((unsigned char) *ptr))
119119
{
120120
begin = ptr;
121121
state = CS_IN2VALUE;
@@ -134,7 +134,7 @@ parse_cfgdict(text *in, Map ** m)
134134
}
135135
else if (state == CS_IN2VALUE)
136136
{
137-
if (isspace(*ptr) || *ptr == ',')
137+
if (isspace((unsigned char) *ptr) || *ptr == ',')
138138
{
139139
mptr->value = nstrdup(begin, ptr - begin);
140140
mptr++;
@@ -147,7 +147,7 @@ parse_cfgdict(text *in, Map ** m)
147147
{
148148
if (*ptr == ',')
149149
state = CS_WAITKEY;
150-
else if (!isspace(*ptr))
150+
else if (!isspace((unsigned char) *ptr))
151151
ereport(ERROR,
152152
(errcode(ERRCODE_SYNTAX_ERROR),
153153
errmsg("syntax error"),

contrib/tsearch2/tsvector.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ gettoken_tsvector(TI_IN_STATE * state)
310310
}
311311
else if (state->state == INPOSINFO)
312312
{
313-
if (isdigit(*(state->prsbuf)))
313+
if (isdigit((unsigned char) *(state->prsbuf)))
314314
{
315315
if (state->alen == 0)
316316
{
@@ -373,9 +373,10 @@ gettoken_tsvector(TI_IN_STATE * state)
373373
errmsg("syntax error")));
374374
state->pos[*(uint16 *) (state->pos)].weight = 0;
375375
}
376-
else if (isspace(*(state->prsbuf)) || *(state->prsbuf) == '\0')
376+
else if (isspace((unsigned char) *(state->prsbuf)) ||
377+
*(state->prsbuf) == '\0')
377378
return 1;
378-
else if (!isdigit(*(state->prsbuf)))
379+
else if (!isdigit((unsigned char) *(state->prsbuf)))
379380
ereport(ERROR,
380381
(errcode(ERRCODE_SYNTAX_ERROR),
381382
errmsg("syntax error")));

0 commit comments

Comments
 (0)