From d9463a1dc3b61614ae5ddc2351944dd28e73b949 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Wed, 19 Jan 2022 11:52:00 +0000 Subject: [PATCH] goto-cc: newlines in command files are just whitespace GCC's doc says that options are separated by whitespace, with no particular significance of newlines. Therefore, process the entire file at once rather than line-by-line. Fixes: #6592 --- regression/goto-gcc/at_files/args | 2 ++ src/goto-cc/gcc_cmdline.cpp | 17 ++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/regression/goto-gcc/at_files/args b/regression/goto-gcc/at_files/args index c151b9c1fb2..19fad839ff8 100644 --- a/regression/goto-gcc/at_files/args +++ b/regression/goto-gcc/at_files/args @@ -1 +1,3 @@ +-o +test.gb other.c diff --git a/src/goto-cc/gcc_cmdline.cpp b/src/goto-cc/gcc_cmdline.cpp index a2592713a5b..ca767a2f9b5 100644 --- a/src/goto-cc/gcc_cmdline.cpp +++ b/src/goto-cc/gcc_cmdline.cpp @@ -12,8 +12,9 @@ Author: CM Wintersteiger, 2006 #include "gcc_cmdline.h" #include -#include #include +#include +#include #include @@ -256,16 +257,18 @@ bool gcc_cmdlinet::parse_arguments( if(has_prefix(argv_i, "@")) { std::ifstream opts_file(argv_i.substr(1)); + std::ostringstream all_lines; std::string line; while(std::getline(opts_file, line)) - { - // erase leading whitespace - line.erase(0, line.find_first_not_of("\t ")); + all_lines << ' ' << line; - if(!line.empty()) - parse_specs_line(line, false); - } + line = all_lines.str(); + // erase leading whitespace + line.erase(0, line.find_first_not_of("\t ")); + + if(!line.empty()) + parse_specs_line(line, false); continue; }