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.cpp80
1 files changed, 45 insertions, 35 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();