2424 * Portions Copyright (c) 1994, Regents of the University of California
2525 *
2626 * IDENTIFICATION
27- * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.165 2010/01/02 16:57:50 momjian Exp $
27+ * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.166 2010/01/16 17:39:55 tgl Exp $
2828 *
2929 *-------------------------------------------------------------------------
3030*/
@@ -1137,7 +1137,7 @@ process_integer_literal(const char *token, YYSTYPE *lval)
11371137return ICONST;
11381138}
11391139
1140- static int
1140+ static unsigned int
11411141hexval (unsigned char c)
11421142{
11431143if (c >=' 0' && c <=' 9' )
@@ -1194,7 +1194,7 @@ addunicode(pg_wchar c, core_yyscan_t yyscanner)
11941194yyerror (" Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8" );
11951195yyextra->saw_non_ascii =true ;
11961196}
1197- unicode_to_utf8 (c, (unsigned char *)buf);
1197+ unicode_to_utf8 (c, (unsigned char *) buf);
11981198addlit (buf,pg_mblen (buf), yyscanner);
11991199}
12001200
@@ -1241,9 +1241,17 @@ litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner)
12411241*out++ = escape;
12421242in +=2 ;
12431243}
1244- else if (isxdigit (in[1 ]) &&isxdigit (in[2 ]) &&isxdigit (in[3 ]) &&isxdigit (in[4 ]))
1244+ else if (isxdigit ((unsigned char ) in[1 ]) &&
1245+ isxdigit ((unsigned char ) in[2 ]) &&
1246+ isxdigit ((unsigned char ) in[3 ]) &&
1247+ isxdigit ((unsigned char ) in[4 ]))
12451248{
1246- pg_wchar unicode =hexval (in[1 ]) *16 *16 *16 +hexval (in[2 ]) *16 *16 +hexval (in[3 ]) *16 +hexval (in[4 ]);
1249+ pg_wchar unicode;
1250+
1251+ unicode = (hexval (in[1 ]) <<12 ) +
1252+ (hexval (in[2 ]) <<8 ) +
1253+ (hexval (in[3 ]) <<4 ) +
1254+ hexval (in[4 ]);
12471255check_unicode_value (unicode, in, yyscanner);
12481256if (pair_first)
12491257{
@@ -1270,13 +1278,22 @@ litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner)
12701278}
12711279in +=5 ;
12721280}
1273- else if (in[1 ] ==' +'
1274- &&isxdigit (in[2 ]) &&isxdigit (in[3 ])
1275- &&isxdigit (in[4 ]) &&isxdigit (in[5 ])
1276- &&isxdigit (in[6 ]) &&isxdigit (in[7 ]))
1281+ else if (in[1 ] ==' +' &&
1282+ isxdigit ((unsigned char ) in[2 ]) &&
1283+ isxdigit ((unsigned char ) in[3 ]) &&
1284+ isxdigit ((unsigned char ) in[4 ]) &&
1285+ isxdigit ((unsigned char ) in[5 ]) &&
1286+ isxdigit ((unsigned char ) in[6 ]) &&
1287+ isxdigit ((unsigned char ) in[7 ]))
12771288{
1278- pg_wchar unicode =hexval (in[2 ]) *16 *16 *16 *16 *16 +hexval (in[3 ]) *16 *16 *16 *16 +hexval (in[4 ]) *16 *16 *16
1279- +hexval (in[5 ]) *16 *16 +hexval (in[6 ]) *16 +hexval (in[7 ]);
1289+ pg_wchar unicode;
1290+
1291+ unicode = (hexval (in[2 ]) <<20 ) +
1292+ (hexval (in[3 ]) <<16 ) +
1293+ (hexval (in[4 ]) <<12 ) +
1294+ (hexval (in[5 ]) <<8 ) +
1295+ (hexval (in[6 ]) <<4 ) +
1296+ hexval (in[7 ]);
12801297check_unicode_value (unicode, in, yyscanner);
12811298if (pair_first)
12821299{