@@ -120,7 +120,6 @@ static bool var_is_current_source(PsqlScanState state, const char *varname);
120
120
static YY_BUFFER_STATE prepare_buffer (const char *txt, int len,
121
121
char **txtcopy);
122
122
static void emit (const char *txt, int len);
123
- static bool is_utf16_surrogate_first (uint32 c);
124
123
static void escape_variable (bool as_ident);
125
124
126
125
#define ECHO emit (yytext, yyleng)
@@ -163,7 +162,11 @@ static void escape_variable(bool as_ident);
163
162
* <xdolq> $foo$ quoted strings
164
163
* <xui> quoted identifier with Unicode escapes
165
164
* <xus> quoted string with Unicode escapes
166
- * <xeu> Unicode surrogate pair in extended quoted string
165
+ *
166
+ * Note: we intentionally don't mimic the backend's <xeu> state; we have
167
+ * no need to distinguish it from <xe> state, and no good way to get out
168
+ * of it in error cases. The backend just throws yyerror() in those
169
+ * cases, but that's not an option here.
167
170
*/
168
171
169
172
%x xb
@@ -175,7 +178,6 @@ static void escape_variable(bool as_ident);
175
178
%x xdolq
176
179
%x xui
177
180
%x xus
178
- %x xeu
179
181
/* Additional exclusive states for psql only: lex backslash commands */
180
182
%x xslashcmd
181
183
%x xslasharg
@@ -529,19 +531,9 @@ other .
529
531
ECHO;
530
532
}
531
533
<xe>{xeunicode} {
532
- uint32 c = strtoul (yytext+2 , NULL , 16 );
533
-
534
- if (is_utf16_surrogate_first (c))
535
- BEGIN (xeu);
536
- ECHO;
537
- }
538
- <xeu>{xeunicode} {
539
- BEGIN (xe);
540
534
ECHO;
541
535
}
542
- <xeu>. { ECHO; }
543
- <xeu>\n { ECHO; }
544
- <xe,xeu>{xeunicodefail} {
536
+ <xe>{xeunicodefail} {
545
537
ECHO;
546
538
}
547
539
<xe>{xeescape} {
@@ -1242,6 +1234,7 @@ psql_scan(PsqlScanState state,
1242
1234
case LEXRES_EOL: /* end of input */
1243
1235
switch (state->start_state )
1244
1236
{
1237
+ /* This switch must cover all non-slash-command states. */
1245
1238
case INITIAL:
1246
1239
if (state->paren_depth > 0 )
1247
1240
{
@@ -1276,18 +1269,26 @@ psql_scan(PsqlScanState state,
1276
1269
result = PSCAN_INCOMPLETE;
1277
1270
*prompt = PROMPT_SINGLEQUOTE;
1278
1271
break ;
1279
- case xq :
1272
+ case xe :
1280
1273
result = PSCAN_INCOMPLETE;
1281
1274
*prompt = PROMPT_SINGLEQUOTE;
1282
1275
break ;
1283
- case xe :
1276
+ case xq :
1284
1277
result = PSCAN_INCOMPLETE;
1285
1278
*prompt = PROMPT_SINGLEQUOTE;
1286
1279
break ;
1287
1280
case xdolq:
1288
1281
result = PSCAN_INCOMPLETE;
1289
1282
*prompt = PROMPT_DOLLARQUOTE;
1290
1283
break ;
1284
+ case xui:
1285
+ result = PSCAN_INCOMPLETE;
1286
+ *prompt = PROMPT_DOUBLEQUOTE;
1287
+ break ;
1288
+ case xus:
1289
+ result = PSCAN_INCOMPLETE;
1290
+ *prompt = PROMPT_SINGLEQUOTE;
1291
+ break ;
1291
1292
default :
1292
1293
/* can't get here */
1293
1294
fprintf (stderr, " invalid YY_START\n " );
@@ -1814,12 +1815,6 @@ emit(const char *txt, int len)
1814
1815
}
1815
1816
}
1816
1817
1817
- static bool
1818
- is_utf16_surrogate_first (uint32 c)
1819
- {
1820
- return (c >= 0xD800 && c <= 0xDBFF );
1821
- }
1822
-
1823
1818
static void
1824
1819
escape_variable (bool as_ident)
1825
1820
{
0 commit comments