static char*
get_string_out(int delim)
{
- int last = delim;
int i = 0;
int c;
char buf[BUFSIZE];
- while ((c = getc(conf)) != delim || last == '\\'){
- if (last=='\\' && c != delim)
- buf[i-1] = c;
- else {
- buf[i] = c;
- i++;
- }
- last = c;
+ while ((c = getc(conf)) != delim){
+ if (c == '\\') {
+ c = getc(conf);
+ if (c == EOF)
+ parse_err("Unbounded string, %c missing", delim);
+ buf[i++] = c;
+ } else if (c == '\n' || c == EOF)
+ parse_err("Unbounded string, %c missing", delim);
+ else
+ buf[i++] = c;
+
if (i >= BUFSIZE-1)
parse_err("Too long string, max allowed length is %d",BUFSIZE-1);
}
if (i >= BUFSIZE-1)
parse_err("Too long number");
}
- ungetc(c,conf);
+ if (c != EOF)
+ ungetc(c,conf);
buf[i] = 0;
yylval.str = xstrdup(buf);
if (i >= BUFSIZE-1)
parse_err("Too long identifier, max allowed length is %d",BUFSIZE-1);
}
+ if (!i)
+ parse_err("Variable identifier must not be empty");
if (c > 0)
ungetc(c,conf);
buf[i] = 0;