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

index 40b94b71365b620716c2769784b40ceed6a5b433..423abd38b62978e4f21d31ac5cd44222ef3ab285 100644 (file)
@@ -589,8 +589,9 @@ testdb=&gt;
     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
-    <literal>\n</literal> (new line), <literal>\t</literal> (tab), and
-    <literal>\</literal><replaceable>digits</replaceable> (octal).
+    <literal>\n</literal> (new line), <literal>\t</literal> (tab),
+    <literal>\</literal><replaceable>digits</replaceable> (octal),
+    <literal>\x</literal><replaceable>digits</replaceable> (hexadecimal).
     </para>
 
     <para>
index 357fd139434077633575b8279c4cb5bb8ba040e0..5ace4a079dc9e3ca458b4057a6e43957fe4b13f5 100644 (file)
@@ -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                       .
 <xq>{xqoctesc}  {
                                        ECHO;
                                }
+<xq>{xqhexesc}  {
+                                       ECHO;
+                               }
 <xq>{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; }