Skip to content

scanner: don't drop or echo lone backslashes in @include paths - #317

Open
affan-arch wants to merge 1 commit into
hyperrealm:masterfrom
affan-arch:include-path-backslash
Open

affan-arch wants to merge 1 commit into
hyperrealm:masterfrom
affan-arch:include-path-backslash

Conversation

@affan-arch

Copy link
Copy Markdown
Contributor

inside @include "..." the scanner only has rules for \\ and \", so a lone backslash as in @include "conf.d\extra.cfg" or a windows path like C:\cfg\app.cfg falls through to flex's default rule, which echoes it to the application's stdout and drops it from the path, so config_read_file()/config_read_string() open conf.dextra.cfg (or the drive-relative C:cfgapp.cfg) instead of what was written; the docs do ask for \\ there, but a missed escape shouldn't print to stdout or quietly swap the file, so it's now kept literally the way <STRING>\\ already handles it, flex -s no longer reports a reachable default rule, scanner.c/scanner.h are regenerated with flex 2.6.4 (regenerating master reproduces the checked-in files byte for byte, so that diff is only the new rule), and the new IncludePathBackslash test fails without the fix.

The INCLUDE start condition only has rules for the \\ and \" escapes,
so a backslash followed by any other character, as in
@include "conf.d\extra.cfg" or a Windows path like
@include "C:\cfg\app.cfg", matches nothing and falls through to flex's
default rule. That rule ECHOes the byte to yyout, which is the host
process's stdout, and leaves it out of the path. config_read_file()
and config_read_string() then write config-controlled bytes to the
application's stdout and open a different file than the one named:
conf.dextra.cfg, or on Windows C:cfgapp.cfg, a drive-relative path
resolved against the process's current directory.

Keep a lone backslash literally, as the STRING state already does with
its own \\ rule. With this rule in place, flex -s no longer reports
that the default rule can be matched. scanner.c and scanner.h are
regenerated with flex 2.6.4. The new IncludePathBackslash test fails
without the fix.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant