static YY_BUFFER_STATE prepare_buffer(const char *txt, int len,
char **txtcopy);
static void emit(const char *txt, int len);
-static bool is_utf16_surrogate_first(uint32 c);
static void escape_variable(bool as_ident);
#define ECHO emit(yytext, yyleng)
* $foo$ quoted strings
* quoted identifier with Unicode escapes
* quoted string with Unicode escapes
- * Unicode surrogate pair in extended quoted string
+ *
+ * Note: we intentionally don't mimic the backend's state; we have
+ * no need to distinguish it from state, and no good way to get out
+ * of it in error cases. The backend just throws yyerror() in those
+ * cases, but that's not an option here.
*/
%x xb
%x xdolq
%x xui
%x xus
-%x xeu
/* Additional exclusive states for psql only: lex backslash commands */
%x xslashcmd
%x xslasharg
ECHO;
}
{xeunicode} {
- uint32 c = strtoul(yytext+2, NULL, 16);
-
- if (is_utf16_surrogate_first(c))
- BEGIN(xeu);
- ECHO;
- }
-{xeunicode} {
- BEGIN(xe);
ECHO;
}
-. { ECHO; }
-\n { ECHO; }
-{xeunicodefail} {
+{xeunicodefail} {
ECHO;
}
{xeescape} {
case LEXRES_EOL: /* end of input */
switch (state->start_state)
{
+ /* This switch must cover all non-slash-command states. */
case INITIAL:
if (state->paren_depth > 0)
{
result = PSCAN_INCOMPLETE;
*prompt = PROMPT_SINGLEQUOTE;
break;
- case xq:
+ case xe:
result = PSCAN_INCOMPLETE;
*prompt = PROMPT_SINGLEQUOTE;
break;
- case xe:
+ case xq:
result = PSCAN_INCOMPLETE;
*prompt = PROMPT_SINGLEQUOTE;
break;
result = PSCAN_INCOMPLETE;
*prompt = PROMPT_DOLLARQUOTE;
break;
+ case xui:
+ result = PSCAN_INCOMPLETE;
+ *prompt = PROMPT_DOUBLEQUOTE;
+ break;
+ case xus:
+ result = PSCAN_INCOMPLETE;
+ *prompt = PROMPT_SINGLEQUOTE;
+ break;
default:
/* can't get here */
fprintf(stderr, "invalid YY_START\n");
}
}
-static bool
-is_utf16_surrogate_first(uint32 c)
-{
- return (c >= 0xD800 && c <= 0xDBFF);
-}
-
static void
escape_variable(bool as_ident)
{