mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 10:48:03 +00:00
lib/clippy: bail out on newline inside string
While C compilers will generally process strings across lines, we really don't want that. I rather treat this as the indication of the typo it probably is warn about it than support this odd C edge case. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
9e92984f32
commit
be95afe196
@ -53,6 +53,7 @@ int comment_link;
|
|||||||
char string_end;
|
char string_end;
|
||||||
|
|
||||||
char *value;
|
char *value;
|
||||||
|
static const char *yyfilename;
|
||||||
|
|
||||||
static void extendbuf(char **what, const char *arg)
|
static void extendbuf(char **what, const char *arg)
|
||||||
{
|
{
|
||||||
@ -119,8 +120,17 @@ SPECIAL [(),]
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
<rstring>\\\n /* ignore */
|
<rstring>\\\n /* ignore */
|
||||||
|
<rstring>\n {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s:%d: string continues past the end of the line\n",
|
||||||
|
yyfilename, yylineno);
|
||||||
|
free(value);
|
||||||
|
value = NULL;
|
||||||
|
BEGIN(INITIAL);
|
||||||
|
return STRING;
|
||||||
|
}
|
||||||
<rstring>\\. extend(yytext);
|
<rstring>\\. extend(yytext);
|
||||||
<rstring>[^\\\"\']+ extend(yytext);
|
<rstring>[^\\\"\'\n]+ extend(yytext);
|
||||||
|
|
||||||
"DEFUN" value = strdup(yytext); return DEFUNNY;
|
"DEFUN" value = strdup(yytext); return DEFUNNY;
|
||||||
"DEFUN_NOSH" value = strdup(yytext); return DEFUNNY;
|
"DEFUN_NOSH" value = strdup(yytext); return DEFUNNY;
|
||||||
@ -235,6 +245,7 @@ PyObject *clippy_parse(PyObject *self, PyObject *args)
|
|||||||
int token;
|
int token;
|
||||||
yyin = fd;
|
yyin = fd;
|
||||||
value = NULL;
|
value = NULL;
|
||||||
|
yyfilename = filename;
|
||||||
|
|
||||||
PyObject *pyCont = PyDict_New();
|
PyObject *pyCont = PyDict_New();
|
||||||
PyObject *pyObj = PyList_New(0);
|
PyObject *pyObj = PyList_New(0);
|
||||||
@ -252,6 +263,7 @@ PyObject *clippy_parse(PyObject *self, PyObject *args)
|
|||||||
if (!pyArgs) {
|
if (!pyArgs) {
|
||||||
free(tval);
|
free(tval);
|
||||||
Py_DECREF(pyCont);
|
Py_DECREF(pyCont);
|
||||||
|
yyfilename = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pyItem = PyDict_New();
|
pyItem = PyDict_New();
|
||||||
@ -280,5 +292,6 @@ PyObject *clippy_parse(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
def_yylex_destroy();
|
def_yylex_destroy();
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
yyfilename = NULL;
|
||||||
return pyCont;
|
return pyCont;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user