From: Bruce Momjian Date: Thu, 2 Jun 2005 01:23:48 +0000 (+0000) Subject: Add support for \x hex strings in psql variables. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=aa552eb803f57d9f9368b3062ebce501bc89b084;p=users%2Fbernd%2Fpostgres.git Add support for \x hex strings in psql variables. --- diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 40b94b7136..423abd38b6 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -589,8 +589,9 @@ testdb=> single quote. To include a single quote into such an argument, precede it by a backslash. Anything contained in single quotes is furthermore subject to C-like substitutions for - \n (new line), \t (tab), and - \digits (octal). + \n (new line), \t (tab), + \digits (octal), + \xdigits (hexadecimal). diff --git a/src/bin/psql/psqlscan.l b/src/bin/psql/psqlscan.l index 357fd13943..5ace4a079d 100644 --- a/src/bin/psql/psqlscan.l +++ b/src/bin/psql/psqlscan.l @@ -250,8 +250,9 @@ xnstart [nN]{quote} xqstart {quote} xqdouble {quote}{quote} xqinside [^\\']+ -xqescape [\\][^0-7] +xqescape [\\][^0-7x] xqoctesc [\\][0-7]{1,3} +xqhexesc [\\]x[0-9A-Fa-f]{1,2} /* $foo$ style quotes ("dollar quoting") * The quoted string starts with $foo$ where "foo" is an optional string @@ -467,6 +468,9 @@ other . {xqoctesc} { ECHO; } +{xqhexesc} { + ECHO; + } {quotecontinue} { ECHO; } @@ -855,6 +859,12 @@ other . (char) strtol(yytext + 1, NULL, 8)); } +{xqhexesc} { + /* hex case */ + appendPQExpBufferChar(output_buf, + (char) strtol(yytext + 2, NULL, 16)); + } + "\\". { emit(yytext + 1, 1); } {other}|\n { ECHO; }