aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/ecpglib/execute.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-03-01 03:26:35 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-03-01 03:26:35 +0000
commite04fa58dcdf59e480db4a65be3d731d45a99fa3d (patch)
tree0de141a156f57d26d81d66248d999384e578bfd4 /src/interfaces/ecpg/ecpglib/execute.c
parent3bf822c4d722d6245a65abdd2502a9d26ab990d5 (diff)
downloadpostgresql-e04fa58dcdf59e480db4a65be3d731d45a99fa3d.tar.gz
postgresql-e04fa58dcdf59e480db4a65be3d731d45a99fa3d.zip
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 char value, else we get the wrong result for high-bit-set characters. Found by Rolf Jentsch. Also, fix several places where <ctype.h> functions were being called without casting the argument to unsigned char; this is likewise unportable, but we keep making that mistake :-(. These found by buildfarm member salamander, which I will desperately miss if it ever goes belly-up.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/execute.c')
-rw-r--r--src/interfaces/ecpg/ecpglib/execute.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index 20231c62a7d..f7bfd9dca7f 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.76 2008/02/07 11:09:12 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.77 2008/03/01 03:26:34 tgl Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@@ -122,13 +122,15 @@ next_insert(char *text, int pos, bool questionmarks)
string = string ? false : true;
else if (!string)
{
- if (text[p] == '$' && isdigit(text[p + 1]))
+ if (text[p] == '$' && isdigit((unsigned char) text[p + 1]))
{
/* this can be either a dollar quote or a variable */
int i;
- for (i = p + 1; isdigit(text[i]); i++);
- if (!isalpha(text[i]) && isascii(text[i]) && text[i] != '_')
+ for (i = p + 1; isdigit((unsigned char) text[i]); i++)
+ /* empty loop body */ ;
+ if (!isalpha((unsigned char) text[i]) &&
+ isascii((unsigned char) text[i]) && text[i] != '_')
/* not dollar delimited quote */
return p;
}