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

Commite04fa58

Browse files
committed
Fix unportable usages of tolower(). On signed-char machines, it is necessary
to explicitly cast the output back to char before comparing it to a charvalue, else we get the wrong result for high-bit-set characters. Found byRolf Jentsch. Also, fix several places where <ctype.h> functions were beingcalled without casting the argument to unsigned char; this is likewiseunportable, but we keep making that mistake :-(. These found by buildfarmmember salamander, which I will desperately miss if it ever goes belly-up.
1 parent3bf822c commite04fa58

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

‎src/backend/utils/adt/like_match.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Copyright (c) 1996-2008, PostgreSQL Global Development Group
2020
*
2121
* IDENTIFICATION
22-
*$PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.20 2008/01/0119:45:52 momjian Exp $
22+
*$PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.21 2008/03/0103:26:34 tgl Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -71,7 +71,7 @@
7171
*/
7272

7373
#ifdefMATCH_LOWER
74-
#defineTCHAR(t) tolower((t))
74+
#defineTCHAR(t)((char)tolower((unsigned char) (t)))
7575
#else
7676
#defineTCHAR(t) (t)
7777
#endif

‎src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.76 2008/02/07 11:09:12 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.77 2008/03/01 03:26:34 tgl Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -122,13 +122,15 @@ next_insert(char *text, int pos, bool questionmarks)
122122
string=string ? false : true;
123123
elseif (!string)
124124
{
125-
if (text[p]=='$'&&isdigit(text[p+1]))
125+
if (text[p]=='$'&&isdigit((unsignedchar)text[p+1]))
126126
{
127127
/* this can be either a dollar quote or a variable */
128128
inti;
129129

130-
for (i=p+1;isdigit(text[i]);i++);
131-
if (!isalpha(text[i])&&isascii(text[i])&&text[i]!='_')
130+
for (i=p+1;isdigit((unsignedchar)text[i]);i++)
131+
/* empty loop body */ ;
132+
if (!isalpha((unsignedchar)text[i])&&
133+
isascii((unsignedchar)text[i])&&text[i]!='_')
132134
/* not dollar delimited quote */
133135
returnp;
134136
}

‎src/interfaces/ecpg/preproc/preproc.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.361 2008/02/15 22:17:06 tgl Exp $*/
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.362 2008/03/01 03:26:35 tgl Exp $*/
22

33
/* Copyright comment*/
44
%{
@@ -5847,7 +5847,7 @@ prepared_name: name {
58475847
int i;
58485848

58495849
for (i =0; i< strlen($1); i++)
5850-
$1[i] = tolower($1[i]);
5850+
$1[i] = tolower((unsignedchar)$1[i]);
58515851

58525852
$$ = make3_str(make_str("\""),$1, make_str("\""));
58535853
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp