24
24
* Portions Copyright (c) 1994, Regents of the University of California
25
25
*
26
26
* 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 $
28
28
*
29
29
*-------------------------------------------------------------------------
30
30
*/
@@ -1137,7 +1137,7 @@ process_integer_literal(const char *token, YYSTYPE *lval)
1137
1137
return ICONST;
1138
1138
}
1139
1139
1140
- static int
1140
+ static unsigned int
1141
1141
hexval (unsigned char c)
1142
1142
{
1143
1143
if (c >= ' 0' && c <= ' 9' )
@@ -1194,7 +1194,7 @@ addunicode(pg_wchar c, core_yyscan_t yyscanner)
1194
1194
yyerror (" Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8" );
1195
1195
yyextra->saw_non_ascii = true ;
1196
1196
}
1197
- unicode_to_utf8 (c, (unsigned char *)buf);
1197
+ unicode_to_utf8 (c, (unsigned char *) buf);
1198
1198
addlit (buf, pg_mblen (buf), yyscanner);
1199
1199
}
1200
1200
@@ -1241,9 +1241,17 @@ litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner)
1241
1241
*out++ = escape;
1242
1242
in += 2 ;
1243
1243
}
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 ]))
1245
1248
{
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 ]);
1247
1255
check_unicode_value (unicode, in, yyscanner);
1248
1256
if (pair_first)
1249
1257
{
@@ -1270,13 +1278,22 @@ litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner)
1270
1278
}
1271
1279
in += 5 ;
1272
1280
}
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 ]))
1277
1288
{
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 ]);
1280
1297
check_unicode_value (unicode, in, yyscanner);
1281
1298
if (pair_first)
1282
1299
{
0 commit comments