summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Preprocessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Slice/Preprocessor.cpp')
-rw-r--r--cpp/src/Slice/Preprocessor.cpp53
1 files changed, 33 insertions, 20 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index 73b6222aa1b..9ed4eee10ab 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -13,7 +13,9 @@
#include <IceUtil/StringConverter.h>
#include <IceUtil/FileUtil.h>
#include <IceUtil/UUID.h>
+#include <IceUtil/ConsoleUtil.h>
#include <algorithm>
+#include <iterator>
#include <vector>
#include <fstream>
#include <sys/types.h>
@@ -26,6 +28,7 @@
using namespace std;
using namespace Slice;
+using namespace IceUtilInternal;
//
// mcpp defines
@@ -82,11 +85,9 @@ Slice::Preprocessor::addQuotes(const string& arg)
{
//
// Add quotes around the given argument to ensure that arguments
- // with spaces will be preserved as a single argument. We also
- // escape the "\" character to ensure that we don't end up with a
- // \" at the end of the string.
+ // with spaces will be preserved as a single argument
//
- return "\"" + IceUtilInternal::escapeString(arg, "\\") + "\"";
+ return "\"" + escapeString(arg, "", IceUtilInternal::Unicode) + "\"";
}
string
@@ -140,7 +141,7 @@ namespace
{
vector<string>
-baseArgs(vector<string> args, bool keepComments, const string& extraArgs, const string& fileName)
+baseArgs(vector<string> args, bool keepComments, const vector<string>& extraArgs, const string& fileName)
{
if(keepComments)
{
@@ -161,10 +162,7 @@ baseArgs(vector<string> args, bool keepComments, const string& extraArgs, const
args.push_back(os.str());
}
- if(!extraArgs.empty())
- {
- args.push_back(extraArgs);
- }
+ copy(extraArgs.begin(), extraArgs.end(), back_inserter(args));
args.push_back(fileName);
return args;
}
@@ -172,7 +170,15 @@ baseArgs(vector<string> args, bool keepComments, const string& extraArgs, const
}
FILE*
-Slice::Preprocessor::preprocess(bool keepComments, const string& extraArgs)
+Slice::Preprocessor::preprocess(bool keepComments, const string& extraArg)
+{
+ vector<string> args;
+ args.push_back(extraArg);
+ return preprocess(keepComments, args);
+}
+
+FILE*
+Slice::Preprocessor::preprocess(bool keepComments, const vector<string>& extraArgs)
{
if(!checkInputFile())
{
@@ -270,10 +276,7 @@ Slice::Preprocessor::preprocess(bool keepComments, const string& extraArgs)
}
else
{
- ostream& os = getErrorStream();
- os << _path << ": error: could not open temporary file: ";
- os << _cppFile;
- os << endl;
+ consoleErr << _path << ": error: could not open temporary file: " << _cppFile << endl;
}
}
@@ -287,7 +290,17 @@ Slice::Preprocessor::preprocess(bool keepComments, const string& extraArgs)
bool
Slice::Preprocessor::printMakefileDependencies(ostream& out, Language lang, const vector<string>& includePaths,
- const string& extraArgs, const string& cppSourceExt,
+ const string& extraArg, const string& cppSourceExt,
+ const string& optValue)
+{
+ vector<string> extraArgs;
+ extraArgs.push_back(extraArg);
+ return printMakefileDependencies(out, lang, includePaths, extraArgs, cppSourceExt, optValue);
+}
+
+bool
+Slice::Preprocessor::printMakefileDependencies(ostream& out, Language lang, const vector<string>& includePaths,
+ const vector<string>& extraArgs, const string& cppSourceExt,
const string& optValue)
{
if(!checkInputFile())
@@ -379,7 +392,7 @@ Slice::Preprocessor::printMakefileDependencies(ostream& out, Language lang, cons
// /foo/A.ice /foo/B.ice becomes
// /foo/A.ice
// /foo/B.ice
- //
+ //
// C:\foo\A.ice C:\foo\B.ice becomes
// C:\foo\A.ice
// C:\foo\B.ice
@@ -704,7 +717,7 @@ Slice::Preprocessor::printMakefileDependencies(ostream& out, Language lang, cons
}
default:
{
- abort();
+ assert(false);
break;
}
}
@@ -750,14 +763,14 @@ Slice::Preprocessor::checkInputFile()
}
if(suffix != ".ice")
{
- getErrorStream() << _path << ": error: input files must end with `.ice'" << endl;
+ consoleErr << _path << ": error: input files must end with `.ice'" << endl;
return false;
}
- IceUtilInternal::ifstream test(_fileName);
+ ifstream test(IceUtilInternal::streamFilename(_fileName).c_str());
if(!test)
{
- getErrorStream() << _path << ": error: cannot open `" << _fileName << "' for reading" << endl;
+ consoleErr << _path << ": error: cannot open `" << _fileName << "' for reading" << endl;
return false;
}
test.close();