* Copyright (c) 1996-2008, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.20 2008/01/01 19:45:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.20.2.1 2008/03/01 03:26:44 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
  */
 
 #ifdef MATCH_LOWER
-#define TCHAR(t) tolower((t))
+#define TCHAR(t) ((char) tolower((unsigned char) (t)))
 #else
 #define TCHAR(t) (t)
 #endif
 
-/* $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.76.2.1 2008/03/01 03:26:44 tgl Exp $ */
 
 /*
  * The aim is to get a simpler inteface to the database routines.
            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;
            }
 
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.359.2.1 2008/02/15 12:11:02 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.359.2.2 2008/03/01 03:26:44 tgl Exp $ */
 
 /* Copyright comment */
 %{
                        int i;
 
                        for (i = 0; i< strlen($1); i++)
-                           $1[i] = tolower($1[i]);
+                           $1[i] = tolower((unsigned char) $1[i]);
 
                        $$ = make3_str(make_str("\""), $1, make_str("\""));
                    }