mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
sync with src changes
This commit is contained in:
parent
421bf22ac7
commit
866f5af9c7
29
parse.y
29
parse.y
|
@ -42,8 +42,7 @@ static struct file {
|
||||||
char *name;
|
char *name;
|
||||||
int lineno;
|
int lineno;
|
||||||
int errors;
|
int errors;
|
||||||
} *file;
|
} *file, *topfile;
|
||||||
|
|
||||||
struct file *pushfile(const char *);
|
struct file *pushfile(const char *);
|
||||||
int popfile(void);
|
int popfile(void);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
|
@ -308,8 +307,9 @@ lgetc(int quotec)
|
||||||
|
|
||||||
if (quotec) {
|
if (quotec) {
|
||||||
if ((c = getc(file->stream)) == EOF) {
|
if ((c = getc(file->stream)) == EOF) {
|
||||||
yyerror("reached end of file while parsing quoted string");
|
yyerror("reached end of file while parsing "
|
||||||
if (popfile() == EOF)
|
"quoted string");
|
||||||
|
if (file == topfile || popfile() == EOF)
|
||||||
return (EOF);
|
return (EOF);
|
||||||
return (quotec);
|
return (quotec);
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ lgetc(int quotec)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (c == EOF) {
|
while (c == EOF) {
|
||||||
if (popfile() == EOF)
|
if (file == topfile || popfile() == EOF)
|
||||||
return (EOF);
|
return (EOF);
|
||||||
c = getc(file->stream);
|
c = getc(file->stream);
|
||||||
}
|
}
|
||||||
|
@ -356,10 +356,12 @@ findeol(void)
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
parsebuf = NULL;
|
parsebuf = NULL;
|
||||||
pushback_index = 0;
|
|
||||||
|
|
||||||
/* skip to either EOF or the first real EOL */
|
/* skip to either EOF or the first real EOL */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
if (pushback_index)
|
||||||
|
c = pushback_buffer[--pushback_index];
|
||||||
|
else
|
||||||
c = lgetc(0);
|
c = lgetc(0);
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
file->lineno++;
|
file->lineno++;
|
||||||
|
@ -461,9 +463,10 @@ nodigits:
|
||||||
#define allowed_in_string(x) \
|
#define allowed_in_string(x) \
|
||||||
(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
|
(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
|
||||||
x != '{' && x != '}' && x != '<' && x != '>' && \
|
x != '{' && x != '}' && x != '<' && x != '>' && \
|
||||||
x != '!' && x != '=' && x != '#' && x != ','))
|
x != '!' && x != '=' && x != '/' && x != '#' && \
|
||||||
|
x != ','))
|
||||||
|
|
||||||
if (isalnum(c) || c == ':' || c == '_' || c == '*' || c == '/') {
|
if (isalnum(c) || c == ':' || c == '_' || c == '*') {
|
||||||
do {
|
do {
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
if ((unsigned)(p-buf) >= sizeof(buf)) {
|
if ((unsigned)(p-buf) >= sizeof(buf)) {
|
||||||
|
@ -495,6 +498,7 @@ pushfile(const char *name)
|
||||||
nfile->name = xstrdup(name);
|
nfile->name = xstrdup(name);
|
||||||
|
|
||||||
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
|
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
|
||||||
|
warn("%s", nfile->name);
|
||||||
free(nfile->name);
|
free(nfile->name);
|
||||||
free(nfile);
|
free(nfile);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -509,16 +513,15 @@ popfile(void)
|
||||||
{
|
{
|
||||||
struct file *prev;
|
struct file *prev;
|
||||||
|
|
||||||
if ((prev = TAILQ_PREV(file, files, entry)) != NULL) {
|
if ((prev = TAILQ_PREV(file, files, entry)) != NULL)
|
||||||
prev->errors += file->errors;
|
prev->errors += file->errors;
|
||||||
|
|
||||||
TAILQ_REMOVE(&files, file, entry);
|
TAILQ_REMOVE(&files, file, entry);
|
||||||
fclose(file->stream);
|
fclose(file->stream);
|
||||||
free(file->name);
|
free(file->name);
|
||||||
free(file);
|
free(file);
|
||||||
file = prev;
|
file = prev;
|
||||||
return (0);
|
return (file ? 0 : EOF);
|
||||||
}
|
|
||||||
return (EOF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -532,12 +535,12 @@ parse_config(const char *filename, struct conf *xconf)
|
||||||
free(conf);
|
free(conf);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
topfile = file;
|
||||||
|
|
||||||
conf_init(conf);
|
conf_init(conf);
|
||||||
|
|
||||||
yyparse();
|
yyparse();
|
||||||
errors = file->errors;
|
errors = file->errors;
|
||||||
file->errors = 0;
|
|
||||||
popfile();
|
popfile();
|
||||||
|
|
||||||
if (errors) {
|
if (errors) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user