Add support for \x hex strings in psql variables.
authorBruce Momjian
Thu, 2 Jun 2005 01:23:48 +0000 (01:23 +0000)
committerBruce Momjian
Thu, 2 Jun 2005 01:23:48 +0000 (01:23 +0000)
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/psqlscan.l

index 55c160e91cfdec5b1badc142c442217374c8936c..bc762ab7c18bbafb9772fb147e1b6041c32e45eb 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -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).
     
 
     
index 4159ee0220f87794cf88cd840029ee4d9ca0ffbc..d0e1dc80d202546566661c8d6ad9add8299ab8e4 100644 (file)
@@ -33,7 +33,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.12 2005/05/30 16:48:47 momjian Exp $
+ *   $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.13 2005/06/02 01:23:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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; }