mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
Fix unportable use of isxdigit() with char (rather than unsigned char)
argument, per warnings from buildfarm member pika. Also clean up code formatting a trifle.
This commit is contained in:
parent
e319e6799a
commit
196a6ca5de
@ -24,7 +24,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.165 2010/01/02 16:57:50 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.166 2010/01/16 17:39:55 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1137,7 +1137,7 @@ process_integer_literal(const char *token, YYSTYPE *lval)
|
|||||||
return ICONST;
|
return ICONST;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static unsigned int
|
||||||
hexval(unsigned char c)
|
hexval(unsigned char c)
|
||||||
{
|
{
|
||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9')
|
||||||
@ -1241,9 +1241,17 @@ litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner)
|
|||||||
*out++ = escape;
|
*out++ = escape;
|
||||||
in += 2;
|
in += 2;
|
||||||
}
|
}
|
||||||
else if (isxdigit(in[1]) && isxdigit(in[2]) && isxdigit(in[3]) && isxdigit(in[4]))
|
else if (isxdigit((unsigned char) in[1]) &&
|
||||||
|
isxdigit((unsigned char) in[2]) &&
|
||||||
|
isxdigit((unsigned char) in[3]) &&
|
||||||
|
isxdigit((unsigned char) in[4]))
|
||||||
{
|
{
|
||||||
pg_wchar unicode = hexval(in[1]) * 16*16*16 + hexval(in[2]) * 16*16 + hexval(in[3]) * 16 + hexval(in[4]);
|
pg_wchar unicode;
|
||||||
|
|
||||||
|
unicode = (hexval(in[1]) << 12) +
|
||||||
|
(hexval(in[2]) << 8) +
|
||||||
|
(hexval(in[3]) << 4) +
|
||||||
|
hexval(in[4]);
|
||||||
check_unicode_value(unicode, in, yyscanner);
|
check_unicode_value(unicode, in, yyscanner);
|
||||||
if (pair_first)
|
if (pair_first)
|
||||||
{
|
{
|
||||||
@ -1270,13 +1278,22 @@ litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner)
|
|||||||
}
|
}
|
||||||
in += 5;
|
in += 5;
|
||||||
}
|
}
|
||||||
else if (in[1] == '+'
|
else if (in[1] == '+' &&
|
||||||
&& isxdigit(in[2]) && isxdigit(in[3])
|
isxdigit((unsigned char) in[2]) &&
|
||||||
&& isxdigit(in[4]) && isxdigit(in[5])
|
isxdigit((unsigned char) in[3]) &&
|
||||||
&& isxdigit(in[6]) && isxdigit(in[7]))
|
isxdigit((unsigned char) in[4]) &&
|
||||||
|
isxdigit((unsigned char) in[5]) &&
|
||||||
|
isxdigit((unsigned char) in[6]) &&
|
||||||
|
isxdigit((unsigned char) in[7]))
|
||||||
{
|
{
|
||||||
pg_wchar unicode = hexval(in[2]) * 16*16*16*16*16 + hexval(in[3]) * 16*16*16*16 + hexval(in[4]) * 16*16*16
|
pg_wchar unicode;
|
||||||
+ hexval(in[5]) * 16*16 + hexval(in[6]) * 16 + hexval(in[7]);
|
|
||||||
|
unicode = (hexval(in[2]) << 20) +
|
||||||
|
(hexval(in[3]) << 16) +
|
||||||
|
(hexval(in[4]) << 12) +
|
||||||
|
(hexval(in[5]) << 8) +
|
||||||
|
(hexval(in[6]) << 4) +
|
||||||
|
hexval(in[7]);
|
||||||
check_unicode_value(unicode, in, yyscanner);
|
check_unicode_value(unicode, in, yyscanner);
|
||||||
if (pair_first)
|
if (pair_first)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user