aboutsummaryrefslogtreecommitdiffstats
path: root/rcfile_l.l
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2010-04-10 18:16:11 +0200
committerMatthias Andree <matthias.andree@gmx.de>2010-04-13 00:53:54 +0200
commit24747c1afe7c3c2df648eba7f6964d987460acbd (patch)
treebd17dd92445596758ac3cbaad7f80032db9f39f9 /rcfile_l.l
parent145f7cb73021da462dcee6e8645130c4402afa3d (diff)
downloadfetchmail-24747c1afe7c3c2df648eba7f6964d987460acbd.tar.gz
fetchmail-24747c1afe7c3c2df648eba7f6964d987460acbd.tar.bz2
fetchmail-24747c1afe7c3c2df648eba7f6964d987460acbd.zip
Remove static string buffers, use xstrndup().
Diffstat (limited to 'rcfile_l.l')
-rw-r--r--rcfile_l.l60
1 files changed, 8 insertions, 52 deletions
diff --git a/rcfile_l.l b/rcfile_l.l
index 6854851b..b8ee31eb 100644
--- a/rcfile_l.l
+++ b/rcfile_l.l
@@ -9,6 +9,7 @@
#include "config.h"
#include "fetchmail.h"
+#include "xmalloc.h"
#include "rcfile_y.h"
int prc_lineno = 1;
@@ -31,57 +32,22 @@ int prc_lineno = 1;
%%
-\"[^\"]*\" {
- 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;
- }
+\"[^\"]*\" |
\'[^\']*\' {
- 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);
+ char *in = xstrndup(yytext+1, yyleng-2);
+ escapes(in, in);
yylval.sval = in;
- SETSTATE(0);
+ SETSTATE(0);
return STRING;
}
"*" { BEGIN(0); return WILDCARD; }
<NAME>[^=;:, \t\r\n]+ {
- 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';
+ char *in = xstrdup(yytext);
escapes(in, in);
- yyleng = strlen(in);
yylval.sval = in;
- SETSTATE(0);
+ SETSTATE(0);
return STRING;
}
@@ -238,18 +204,8 @@ options {/* EMPTY */}
-?[0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
[^=;:, \t\r\n]+ {
- 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';
-
+ char *in = xstrdup(yytext);
escapes(in, in);
- yyleng = strlen(in);
yylval.sval = in;
return STRING;
}