summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Preprocessor.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2004-07-14 18:02:04 +0000
committerMark Spruiell <mes@zeroc.com>2004-07-14 18:02:04 +0000
commit2d5e3c8567cc1496a4689fb2629d755ad217bb98 (patch)
tree32275a414508c143ce192c957ddb6e02afd10470 /cpp/src/Slice/Preprocessor.cpp
parentRemoved DOS line endings. (diff)
downloadice-2d5e3c8567cc1496a4689fb2629d755ad217bb98.tar.bz2
ice-2d5e3c8567cc1496a4689fb2629d755ad217bb98.tar.xz
ice-2d5e3c8567cc1496a4689fb2629d755ad217bb98.zip
revising Java dependency output
Diffstat (limited to 'cpp/src/Slice/Preprocessor.cpp')
-rw-r--r--cpp/src/Slice/Preprocessor.cpp58
1 files changed, 49 insertions, 9 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index 390e524f7e1..1a6b716fe55 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -143,20 +143,60 @@ Slice::Preprocessor::printMakefileDependencies(Language lang)
}
case Java:
{
+ //
+ // We want to shift the files left one position, so that
+ // "x.cpp: x.ice y.ice" becomes "x.ice: y.ice".
+ //
+ // Since the pipe input can be returned a line at a time, we collect
+ // all of the output into one string before manipulating it.
+ //
+ string deps;
char buf[1024];
while(fgets(buf, sizeof(buf), cppHandle) != NULL)
{
- //
- // Change the extension of the leading file from .cpp to .ice.
- // This filename is ignored by Slice2JavaTask.
- //
- char* p = strstr(buf, ".cpp:");
- if(p != NULL)
+ deps.append(buf, strlen(buf));
+ }
+
+ //
+ // Remove the first file.
+ //
+ string::size_type start = deps.find(".cpp:");
+ assert(start != string::npos);
+ start = deps.find_first_not_of(" \t\r\n\\", start + 5); // Skip to beginning of next file.
+ assert(start != string::npos);
+ deps.erase(0, start);
+
+ //
+ // Find end of next file.
+ //
+ string::size_type pos = 0;
+ while((pos = deps.find_first_of(" :\t\r\n\\", pos + 1)) != string::npos)
+ {
+ if(deps[pos] == ':')
{
- strncpy(p + 1, "ice", 3);
+ deps.insert(pos, 1, '\\'); // Escape colons.
+ ++pos;
}
- fputs(buf, stdout);
- }
+ else if(deps[pos] == '\\') // Ignore escaped characters.
+ {
+ ++pos;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if(pos == string::npos)
+ {
+ deps.append(":");
+ }
+ else
+ {
+ deps.insert(pos, 1, ':');
+ }
+
+ fputs(deps.c_str(), stdout);
break;
}
case CSharp: