summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2006-01-30 04:11:45 +0000
committerMichi Henning <michi@zeroc.com>2006-01-30 04:11:45 +0000
commit179f9a587877580d06a9bec54ccd0c955c614c6c (patch)
tree89519d6c7f545404bc2063bc946e067bf0890f60 /cpp/src
parentfix for path with mixed separators (diff)
downloadice-179f9a587877580d06a9bec54ccd0c955c614c6c.tar.bz2
ice-179f9a587877580d06a9bec54ccd0c955c614c6c.tar.xz
ice-179f9a587877580d06a9bec54ccd0c955c614c6c.zip
Bug 838.
Diffstat (limited to 'cpp/src')
-rwxr-xr-xcpp/src/slice2cs/Gen.cpp53
-rw-r--r--cpp/src/slice2cs/Gen.h1
-rwxr-xr-xcpp/src/slice2vb/Gen.cpp51
-rw-r--r--cpp/src/slice2vb/Gen.h1
4 files changed, 27 insertions, 79 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 986b98cf354..38a009798fd 100755
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -849,49 +849,24 @@ Slice::CsVisitor::emitAttributes(const ContainedPtr& p)
Slice::Gen::Gen(const string& name, const string& base, const vector<string>& includePaths, const string& dir,
bool impl, bool implTie, bool stream)
- : _base(base),
- _includePaths(includePaths),
+ : _includePaths(includePaths),
_stream(stream)
{
- string file = base + ".cs";
- string fileImpl = base + "I.cs";
+ string fileBase = base;
+ string::size_type pos = base.find_last_of("/\\");
+ if(pos != string::npos)
+ {
+ fileBase = base.substr(pos + 1);
+ }
+ string file = fileBase + ".cs";
+ string fileImpl = fileBase + "I.cs";
if(!dir.empty())
{
- //
- // Get the working directory and look at the returned path
- // to find out whether we need to use a forward or backward slash
- // as a path separator. (This seems to be one of the very few
- // portable ways to get the correct separator.)
- //
- char* p;
-#if defined(_MSC_VER)
- p = _getcwd(0, 0);
-#else
- p = getcwd(0, 0);
-#endif
- if(p == 0)
- {
- cerr << name << ": cannot get working directory: " << strerror(errno) << endl;
- return;
- }
- string cwd(p);
- string slash = cwd.find('/') == string::npos ? "\\" : "/";
- free(p);
-
- string::size_type pos = base.find_last_of("/\\");
- if(pos != string::npos)
- {
- string fileBase(base, pos + 1);
- file = dir + slash + fileBase + ".cs";
- fileImpl = dir + slash + fileBase + "I.cs";
- }
- else
- {
- file = dir + slash + file;
- fileImpl = dir + slash + fileImpl;
- }
+ file = dir + '/' + file;
+ fileImpl = dir + '/' + fileImpl;
}
+
_out.open(file.c_str());
if(!_out)
{
@@ -900,7 +875,7 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
}
printHeader();
- _out << nl << "// Generated from file `" << base << ".ice'";
+ _out << nl << "// Generated from file `" << fileBase << ".ice'";
_out << sp << nl << "using _System = System;";
_out << nl << "using _Microsoft = Microsoft;";
@@ -910,7 +885,7 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
struct stat st;
if(stat(fileImpl.c_str(), &st) == 0)
{
- cerr << name << ": `" << fileImpl << "' already exists - will not overwrite" << endl;
+ cerr << name << ": `" << fileImpl << "' already exists--will not overwrite" << endl;
return;
}
_impl.open(fileImpl.c_str());
diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h
index 568c8bc6350..d6946c7e29a 100644
--- a/cpp/src/slice2cs/Gen.h
+++ b/cpp/src/slice2cs/Gen.h
@@ -66,7 +66,6 @@ private:
IceUtil::Output _out;
IceUtil::Output _impl;
- std::string _base;
std::vector<std::string> _includePaths;
bool _stream;
diff --git a/cpp/src/slice2vb/Gen.cpp b/cpp/src/slice2vb/Gen.cpp
index 07062dde0c3..7ff9b51533c 100755
--- a/cpp/src/slice2vb/Gen.cpp
+++ b/cpp/src/slice2vb/Gen.cpp
@@ -831,49 +831,24 @@ Slice::VbVisitor::emitAttributes(const ContainedPtr& p)
Slice::Gen::Gen(const string& name, const string& base, const vector<string>& includePaths, const string& dir,
bool impl, bool implTie, bool stream)
- : _base(base),
- _includePaths(includePaths),
+ : _includePaths(includePaths),
_stream(stream)
{
- string file = base + ".vb";
- string fileImpl = base + "I.vb";
+ string fileBase = base;
+ string::size_type pos = base.find_last_of("/\\");
+ if(pos != string::npos)
+ {
+ fileBase = base.substr(pos + 1);
+ }
+ string file = fileBase + ".vb";
+ string fileImpl = fileBase + "I.vb";
if(!dir.empty())
{
- //
- // Get the working directory and look at the returned path
- // to find out whether we need to use a forward or backward slash
- // as a path separator. (This seems to be one of the very few
- // portable ways to get the correct separator.)
- //
- char* p;
-#if defined(_MSC_VER)
- p = _getcwd(0, 0);
-#else
- p = getcwd(0, 0);
-#endif
- if(p == 0)
- {
- cerr << name << ": cannot get working directory: " << strerror(errno) << endl;
- return;
- }
- string cwd(p);
- string slash = cwd.find('/') == string::npos ? "\\" : "/";
- free(p);
-
- string::size_type pos = base.find_last_of("/\\");
- if(pos != string::npos)
- {
- string fileBase(base, pos + 1);
- file = dir + slash + fileBase + ".vb";
- fileImpl = dir + slash + fileBase + "I.vb";
- }
- else
- {
- file = dir + slash + file;
- fileImpl = dir + slash + fileImpl;
- }
+ file = dir + '/' + file;
+ fileImpl = dir + '/' + fileImpl;
}
+
_out.open(file.c_str());
if(!_out)
{
@@ -882,7 +857,7 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
}
printHeader();
- _out << nl << "' Generated from file `" << base << ".ice'";
+ _out << nl << "' Generated from file `" << fileBase << ".ice'";
_out << sp << nl << "Imports _System = System";
_out << nl << "Imports _Microsoft = Microsoft";
diff --git a/cpp/src/slice2vb/Gen.h b/cpp/src/slice2vb/Gen.h
index dd8dc0ca1cc..77d3c5987b3 100644
--- a/cpp/src/slice2vb/Gen.h
+++ b/cpp/src/slice2vb/Gen.h
@@ -65,7 +65,6 @@ private:
IceUtil::Output _out;
IceUtil::Output _impl;
- std::string _base;
std::vector<std::string> _includePaths;
bool _stream;