summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/Preprocessor.cpp80
-rw-r--r--cpp/src/slice2cpp/Main.cpp6
-rw-r--r--cpp/src/slice2cppe/Main.cpp6
-rw-r--r--cpp/src/slice2cs/Main.cpp8
-rw-r--r--cpp/src/slice2docbook/Main.cpp6
-rw-r--r--cpp/src/slice2freeze/Main.cpp6
-rw-r--r--cpp/src/slice2freezej/Main.cpp6
-rw-r--r--cpp/src/slice2html/Main.cpp6
-rw-r--r--cpp/src/slice2java/Main.cpp6
-rw-r--r--cpp/src/slice2javae/Main.cpp6
-rw-r--r--cpp/src/slice2py/Main.cpp6
-rw-r--r--cpp/src/slice2vb/Main.cpp6
12 files changed, 80 insertions, 68 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index b76d1054e3f..77b28ece361 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -6,18 +6,16 @@
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
-
-#include <Slice/Preprocessor.h>
+#include <Slice/Preprocessor.h>
+#include <IceUtil/StringUtil.h>
#include <algorithm>
#include <fstream>
-
-
#include <sys/types.h>
#include <sys/stat.h>
#ifndef _WIN32
-
+
# include <sys/wait.h>
#endif
@@ -53,6 +51,18 @@ Slice::Preprocessor::getBaseName()
return base;
}
+string
+Slice::Preprocessor::addQuotes(const string& arg)
+{
+ //
+ // Add quotes around the given argument to ensure that arguments
+ // with spaces (such as PATHs) 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.
+ //
+ return "\"" + IceUtil::escapeString(arg, "\\") + "\"";
+}
+
FILE*
Slice::Preprocessor::preprocess(bool keepComments)
{
@@ -232,37 +242,37 @@ Slice::Preprocessor::printMakefileDependencies(Language lang)
}
break;
}
- case VisualBasic:
- {
- //
- // Change .cpp suffix to .vb suffix.
- //
+ case VisualBasic:
+ {
+ //
+ // Change .cpp suffix to .vb suffix.
+ //
char buf[1024];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- char* dot;
- char* colon = strchr(buf, ':');
- if(colon != NULL)
- {
- *colon = '\0';
- dot = strrchr(buf, '.');
- *colon = ':';
- if(dot != NULL)
- {
- if(strncmp(dot, ".cpp:", 5) == 0)
- {
- *dot = '\0';
- fputs(buf, stdout);
- fputs(".vb", stdout);
- fputs(colon, stdout);
- continue;
- }
- }
- }
- fputs(buf, stdout);
- }
- break;
- }
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ char* dot;
+ char* colon = strchr(buf, ':');
+ if(colon != NULL)
+ {
+ *colon = '\0';
+ dot = strrchr(buf, '.');
+ *colon = ':';
+ if(dot != NULL)
+ {
+ if(strncmp(dot, ".cpp:", 5) == 0)
+ {
+ *dot = '\0';
+ fputs(buf, stdout);
+ fputs(".vb", stdout);
+ fputs(colon, stdout);
+ continue;
+ }
+ }
+ }
+ fputs(buf, stdout);
+ }
+ break;
+ }
default:
{
abort();
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp
index 83fe8c11903..4eb9898240c 100644
--- a/cpp/src/slice2cpp/Main.cpp
+++ b/cpp/src/slice2cpp/Main.cpp
@@ -101,20 +101,20 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths;
includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
diff --git a/cpp/src/slice2cppe/Main.cpp b/cpp/src/slice2cppe/Main.cpp
index 70d76cfd2fa..54f6fff32d6 100644
--- a/cpp/src/slice2cppe/Main.cpp
+++ b/cpp/src/slice2cppe/Main.cpp
@@ -97,19 +97,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index 8bebaabbe25..1efb85d7b35 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/Main.cpp
@@ -90,19 +90,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -143,6 +143,8 @@ main(int argc, char* argv[])
int status = EXIT_SUCCESS;
+ cerr << cppArgs << endl;
+
for(i = args.begin(); i != args.end(); ++i)
{
if(depend)
diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp
index 257ffe6667c..33e6aea578c 100644
--- a/cpp/src/slice2docbook/Main.cpp
+++ b/cpp/src/slice2docbook/Main.cpp
@@ -86,19 +86,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("I");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index 986eb48d485..bb00db0f207 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -1229,19 +1229,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess= opts.isSet("E");
diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp
index c229ca0ed1f..13cf8b68335 100644
--- a/cpp/src/slice2freezej/Main.cpp
+++ b/cpp/src/slice2freezej/Main.cpp
@@ -1120,19 +1120,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp
index a230bd0eb47..546ed59fe5d 100644
--- a/cpp/src/slice2html/Main.cpp
+++ b/cpp/src/slice2html/Main.cpp
@@ -86,19 +86,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("I");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp
index 98eeb83202d..538d2391d8c 100644
--- a/cpp/src/slice2java/Main.cpp
+++ b/cpp/src/slice2java/Main.cpp
@@ -96,19 +96,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
diff --git a/cpp/src/slice2javae/Main.cpp b/cpp/src/slice2javae/Main.cpp
index a43da812fab..43b2a934e11 100644
--- a/cpp/src/slice2javae/Main.cpp
+++ b/cpp/src/slice2javae/Main.cpp
@@ -86,19 +86,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp
index 9e4def18ab9..47b72e8bb4c 100644
--- a/cpp/src/slice2py/Main.cpp
+++ b/cpp/src/slice2py/Main.cpp
@@ -429,19 +429,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
diff --git a/cpp/src/slice2vb/Main.cpp b/cpp/src/slice2vb/Main.cpp
index 35b15a95bfb..2a71ec3c78e 100644
--- a/cpp/src/slice2vb/Main.cpp
+++ b/cpp/src/slice2vb/Main.cpp
@@ -90,19 +90,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D\"" + *i + "\"";
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U\"" + *i + "\"";
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I\"" + *i + "\"";
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");