Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions extern/btyacc/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ char *get_line() {

/* VM: Process %include line */
if(strncmp(&line[0], "%include ", 9)==0) {
int ii=0;
for(i=9; line[i]!='\n' && line[i]!=' '; i++, ii++) {
inc_file_name[ii] = line[i];
}
inc_file_name[ii] = 0;

char *inc_file_name = line+9;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inc_file_name is already declared as global variable at line 26 above.
It is used later in other functions.
This change break it, AFAIU

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right, the consequences of breaking a global variable "inc_file_name", are unpredictable.

The PR to the btyacc original source tree was intended to clarify the initial understanding regarding the handling of "\r\n" characters.

However, an attempt to integrate the original code from the btyacc source was failed...

My original idea was to handle only "\r\n" EndOfLine characters without touching anything else:

-- for(i=9; line[i]!='\n' && line[i]!=' '; i++, ii++) {
++ for(i=9; line[i]!='\n' && line[i]!=' ' && !(line[i] =='\r' && line[i+1]=='\n'); i++, ii++) {

Is this acceptable?

while (isspace(*inc_file_name)) inc_file_name++;
i = strlen(inc_file_name);
while (i > 0 && isspace(inc_file_name[i-1])) --i;
inc_file_name[i] = 0;

if(inc_file) {
error(lineno, 0, 0, "Nested include lines are not allowed");
}
Expand Down
Loading