#include "mbswidth.h"
#include "complain.h"
#include "quote.h"
+#include "struniq.h"
#include "getargs.h"
#include "gram.h"
#include "reader.h"
#define YY_USER_INIT \
do { \
LOCATION_RESET (*yylloc); \
- yylloc->file = infile; \
+ yylloc->file = current_file; \
/* This is only to avoid GCC warnings. */ \
if (yycontrol) {;}; \
} while (0)
static struct obstack string_obstack;
+/* A string representing the most recently saved token. */
+static char *last_string;
+
+
#define YY_OBS_GROW \
obstack_grow (&string_obstack, yytext, yyleng)
#define YY_OBS_FREE \
obstack_free (&string_obstack, last_string)
+void
+scanner_last_string_free (void)
+{
+ YY_OBS_FREE;
+}
/* Within well-formed rules, RULE_LENGTH is the number of values in
the current rule so far, which says where to find `$0' with respect
/* Scanner context when scanning C code. */
int c_context IF_LINT (= 0);
- /* A string representing the most recently saved token. */
- char *last_string;
-
/* At each yylex invocation, mark the current position as the
start of the next token. */
YY_STEP;
YY_STEP;
}
- ^"#line "{int}" \""[^\"]*"\"\n" handle_syncline (yytext + strlen ("#line "), yylloc); YY_STEP;
+ ^"#line "{int}" \"".*"\"\n" {
+ handle_syncline (yytext + sizeof "#line " - 1, yylloc);
+ YY_STEP;
+ }
"=" return EQUAL;
":" rule_length = 0; return COLON;
"<"{tag}">" {
obstack_grow (&string_obstack, yytext + 1, yyleng - 2);
YY_OBS_FINISH;
- yylval->string = last_string;
+ yylval->struniq = struniq_new (last_string);
+ YY_OBS_FREE;
return TYPE;
}
\\r obstack_1grow (&string_obstack, '\r');
\\t obstack_1grow (&string_obstack, '\t');
\\v obstack_1grow (&string_obstack, '\v');
- \\[\"\'?\\] obstack_1grow (&string_obstack, yytext[1]);
+
+ /* \\[\"\'?\\] would be shorter, but it confuses xgettext. */
+ \\("\""|"'"|"?"|"\\") obstack_1grow (&string_obstack, yytext[1]);
+
\\(u|U[0-9a-fA-F]{4})[0-9a-fA-F]{4} {
int c = convert_ucn_to_byte (yytext);
if (c < 0)
<SC_CHARACTER>
{
- "'" YY_OBS_GROW; BEGIN c_context;
- \\{splice}[\'\\] YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (yylloc, "'");
+ "'" YY_OBS_GROW; BEGIN c_context;
+ \\{splice}[^$@\[\]] YY_OBS_GROW;
+ <<EOF>> unexpected_end_of_file (yylloc, "'");
}
<SC_STRING>
{
- "\"" YY_OBS_GROW; BEGIN c_context;
- \\{splice}[\"\\] YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (yylloc, "\"");
+ "\"" YY_OBS_GROW; BEGIN c_context;
+ \\{splice}[^$@\[\]] YY_OBS_GROW;
+ <<EOF>> unexpected_end_of_file (yylloc, "\"");
}
const char *file = NULL;
file = strchr (args, '"') + 1;
*strchr (file, '"') = 0;
- /* FIXME: Leaking... Can't free, as some locations are still
- pointing to the old file name. */
- infile = xstrdup (file);
- location->file = infile;
+ current_file = xstrdup (file);
+ location->file = current_file;
location->last_line = lineno;
}