Skip to content

Commit b727ef4

Browse files
author
Daniel Kroening
committed
use run() in ansi-c/c_preprocess
1 parent 0e31f73 commit b727ef4

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/ansi-c/c_preprocess.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Author: Daniel Kroening, [email protected]
1010

1111
#include <util/c_types.h>
1212
#include <util/config.h>
13+
#include <util/run.h>
1314
#include <util/suffix.h>
1415
#include <util/tempfile.h>
1516
#include <util/unicode.h>
@@ -383,8 +384,9 @@ bool c_preprocess_visual_studio(
383384
command += " 2> \"" + stderr_file() + "\"";
384385

385386
// _popen isn't very reliable on WIN32
386-
// that's why we use system()
387-
int result=system(command.c_str());
387+
// that's why we use run()
388+
int result =
389+
run("cl", {"cl", "@" + command_file_name()}, "", tmpi(), stderr_file());
388390

389391
std::ifstream instream(tmpi());
390392

@@ -463,30 +465,30 @@ bool c_preprocess_codewarrior(
463465

464466
temporary_filet stderr_file("tmp.stderr", "");
465467

466-
std::string command;
467-
468-
command="mwcceppc -E -P -D__CPROVER__ -ppopt line -ppopt full";
468+
std::vector<std::string> command =
469+
{ "mwcceppc", "-E", "-P", "-D__CPROVER__", "-ppopt", "line", "-ppopt full" };
469470

470471
for(const auto &define : config.ansi_c.defines)
471-
command+=" -D"+shell_quote(define);
472+
command.push_back(" -D"+define);
472473

473474
for(const auto &include_path : config.ansi_c.include_paths)
474-
command+=" -I"+shell_quote(include_path);
475+
command.push_back(" -I"+include_path);
475476

476477
for(const auto &include_file : config.ansi_c.include_files)
477-
command+=" -include "+shell_quote(include_file);
478+
{
479+
command.push_back(" -include");
480+
command.push_back(include_file);
481+
}
478482

479483
for(const auto &opt : config.ansi_c.preprocessor_options)
480-
command+=" "+opt;
481-
482-
int result;
484+
command.push_back(opt);
483485

484486
temporary_filet tmpi("tmp.cl", "");
485-
command+=" \""+file+"\"";
486-
command += " -o \"" + tmpi() + "\"";
487-
command += " 2> \"" + stderr_file() + "\"";
487+
command.push_back(file);
488+
command.push_back("-o");
489+
command.push_back(tmpi());
488490

489-
result=system(command.c_str());
491+
int result = run(command[0], command, "", "", stderr_file());
490492

491493
std::ifstream stream_i(tmpi());
492494

@@ -667,7 +669,7 @@ bool c_preprocess_gcc_clang(
667669
command += " 2> \"" + stderr_file() + "\"";
668670

669671
// _popen isn't very reliable on WIN32
670-
// that's why we use system() and a temporary file
672+
// that's why we use run() and a temporary file
671673
result=system(command.c_str());
672674

673675
std::ifstream instream(tmpi());

0 commit comments

Comments
 (0)