Check for garbage in #pragma and #include
This commit is contained in:
parent
72fcc53c49
commit
589f3a3e35
2 changed files with 31 additions and 3 deletions
|
@ -312,7 +312,9 @@ do_include()
|
||||||
filenm = (char *)0;
|
filenm = (char *)0;
|
||||||
}
|
}
|
||||||
AccFileSpecifier = 0;
|
AccFileSpecifier = 0;
|
||||||
SkipToNewLine();
|
if (SkipToNewLine()) {
|
||||||
|
error("bad include syntax");
|
||||||
|
}
|
||||||
inctable[0] = WorkingDir;
|
inctable[0] = WorkingDir;
|
||||||
if (filenm) {
|
if (filenm) {
|
||||||
if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){
|
if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){
|
||||||
|
|
|
@ -49,12 +49,35 @@ do_pragma()
|
||||||
char *cur_line = Malloc(size);
|
char *cur_line = Malloc(size);
|
||||||
register char *c_ptr = cur_line;
|
register char *c_ptr = cur_line;
|
||||||
register int c = GetChar();
|
register int c = GetChar();
|
||||||
|
register int delim = 0;
|
||||||
|
|
||||||
*c_ptr = '\0';
|
|
||||||
while(c != '\n') {
|
while(c != '\n') {
|
||||||
if (c_ptr + 1 - cur_line == size) {
|
if (c_ptr + 1 - cur_line == size) {
|
||||||
cur_line = Realloc(cur_line, (unsigned)(size += ITEXTSIZE));
|
cur_line = Realloc(cur_line, (unsigned)(size + ITEXTSIZE));
|
||||||
c_ptr = cur_line + size - 1;
|
c_ptr = cur_line + size - 1;
|
||||||
|
size += ITEXTSIZE;
|
||||||
|
}
|
||||||
|
if (delim) {
|
||||||
|
if (c == delim) {
|
||||||
|
delim = 0;
|
||||||
|
}
|
||||||
|
else if (c == '\\') {
|
||||||
|
*c_ptr++ = c;
|
||||||
|
c = GetChar();
|
||||||
|
if (c == '\n') break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (c == '\'' || c == '"') {
|
||||||
|
delim = c;
|
||||||
|
}
|
||||||
|
else if (c == '/') {
|
||||||
|
if ((c = GetChar()) != '*' || InputLevel) {
|
||||||
|
*c_ptr++ = '/';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipcomment();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*c_ptr++ = c;
|
*c_ptr++ = c;
|
||||||
c = GetChar();
|
c = GetChar();
|
||||||
|
@ -66,6 +89,9 @@ do_pragma()
|
||||||
pragma_tab = (struct prag_info *)Realloc((char *)pragma_tab
|
pragma_tab = (struct prag_info *)Realloc((char *)pragma_tab
|
||||||
, (unsigned)(sizeof(struct prag_info) * (pragma_nr+1)));
|
, (unsigned)(sizeof(struct prag_info) * (pragma_nr+1)));
|
||||||
}
|
}
|
||||||
|
if (delim) {
|
||||||
|
error("unclosed opening %c", delim);
|
||||||
|
}
|
||||||
pragma_tab[pragma_nr].pr_linnr = LineNumber;
|
pragma_tab[pragma_nr].pr_linnr = LineNumber;
|
||||||
pragma_tab[pragma_nr].pr_fil = FileName;
|
pragma_tab[pragma_nr].pr_fil = FileName;
|
||||||
pragma_tab[pragma_nr].pr_text = cur_line;
|
pragma_tab[pragma_nr].pr_text = cur_line;
|
||||||
|
|
Loading…
Reference in a new issue