Skip to content

Commit c47a972

Browse files
committed
gcc: refine response-file tokenizer visibility and whitespace handling
Follow-up to the quoted @response-file support: - make split_gnu_response_file_args private (only used within gcc.rs) - split on ASCII whitespace only, matching the compilers' tokenizers so a non-ASCII Unicode space in a filename does not break an argument - clarify the empty-"" behavior (matches Clang, not GCC's buildargv)
1 parent b78ba27 commit c47a972

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/compiler/gcc.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,15 +1145,20 @@ impl Iterator for ExpandIncludeFile<'_> {
11451145
/// - A backslash escapes the following character, which is taken literally.
11461146
/// Backslashes are literal inside single quotes, but still escape inside
11471147
/// double quotes.
1148-
/// - Empty quoted strings (`""`) produce no argument, matching the compiler.
1149-
pub fn split_gnu_response_file_args(contents: &str) -> Vec<OsString> {
1148+
/// - Empty quoted strings (`""`) produce no argument. This matches Clang;
1149+
/// GCC's `buildargv` would instead emit an empty argument, but a bare `""`
1150+
/// argument is meaningless to a compiler so the difference is immaterial.
1151+
///
1152+
/// Whitespace is restricted to ASCII, matching the compilers' own tokenizers
1153+
/// (a non-ASCII Unicode space inside a filename must not split an argument).
1154+
fn split_gnu_response_file_args(contents: &str) -> Vec<OsString> {
11501155
let mut args = Vec::new();
11511156
let mut token = String::new();
11521157
let mut chars = contents.chars();
11531158

11541159
while let Some(c) = chars.next() {
11551160
match c {
1156-
c if c.is_whitespace() => {
1161+
c if c.is_ascii_whitespace() => {
11571162
if !token.is_empty() {
11581163
args.push(OsString::from(std::mem::take(&mut token)));
11591164
}

0 commit comments

Comments
 (0)