aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Banack <bob5972 at gmail.com>2010-04-09 17:56:05 -0700
committerMatthias Andree <matthias.andree@gmx.de>2010-04-10 16:57:29 +0200
commit1c6fb40e79a1344c35dcc69b292f9b6913cd4e95 (patch)
treeda8c00049d0caba2cedee47729249942d90d31ff
parenta1fefd08e2722d93b6f776baa817e2d0d1044ee2 (diff)
downloadfetchmail-1c6fb40e79a1344c35dcc69b292f9b6913cd4e95.tar.gz
fetchmail-1c6fb40e79a1344c35dcc69b292f9b6913cd4e95.tar.bz2
fetchmail-1c6fb40e79a1344c35dcc69b292f9b6913cd4e95.zip
Changed the lexer to copy string values out of yytext.
Fixes BerliOS bug #14257.
-rw-r--r--rcfile_l.l54
1 files changed, 41 insertions, 13 deletions
diff --git a/rcfile_l.l b/rcfile_l.l
index d40648d5..6854851b 100644
--- a/rcfile_l.l
+++ b/rcfile_l.l
@@ -32,18 +32,36 @@ int prc_lineno = 1;
%%
\"[^\"]*\" {
- yytext[yyleng-1] = '\0';
- escapes(yytext+1, yytext);
- yyleng = strlen(yytext);
- yylval.sval = yytext;
+ static char *in = NULL;
+ static size_t ins = 0;
+
+ if ((size_t)yyleng + 1 > ins) {
+ ins = yyleng + 1;
+ in = (char *)xrealloc(in, ins);
+ }
+ memcpy(in, yytext, yyleng);
+
+ in[yyleng-1] = '\0';
+ escapes(in+1, in);
+ yyleng = strlen(in);
+ yylval.sval = in;
SETSTATE(0);
return STRING;
}
\'[^\']*\' {
- yytext[yyleng-1] = '\0';
- escapes(yytext+1, yytext);
- yyleng = strlen(yytext);
- yylval.sval = yytext;
+ static char *in = NULL;
+ static size_t ins = 0;
+
+ if ((size_t)yyleng + 1 > ins) {
+ ins = yyleng + 1;
+ in = (char *)xrealloc(in, ins);
+ }
+ memcpy(in, yytext, yyleng);
+
+ in[yyleng-1] = '\0';
+ escapes(in+1, in);
+ yyleng = strlen(in);
+ yylval.sval = in;
SETSTATE(0);
return STRING;
}
@@ -51,8 +69,8 @@ int prc_lineno = 1;
"*" { BEGIN(0); return WILDCARD; }
<NAME>[^=;:, \t\r\n]+ {
- static char *in;
- static size_t ins;
+ static char *in = NULL;
+ static size_t ins = 0;
if ((size_t)yyleng + 1 > ins) {
ins = yyleng + 1;
@@ -220,9 +238,19 @@ options {/* EMPTY */}
-?[0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
[^=;:, \t\r\n]+ {
- escapes(yytext, yytext);
- yyleng = strlen(yytext);
- yylval.sval = yytext;
+ static char *in = NULL;
+ static size_t ins = 0;
+
+ if ((size_t)yyleng + 1 > ins) {
+ ins = yyleng + 1;
+ in = (char *)xrealloc(in, ins);
+ }
+ memcpy(in, yytext, yyleng);
+ in[yyleng] = '\0';
+
+ escapes(in, in);
+ yyleng = strlen(in);
+ yylval.sval = in;
return STRING;
}