summaryrefslogtreecommitdiff
path: root/otk/util.cc
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-01-11 11:16:36 +0000
committerDana Jansens <danakj@orodu.net>2003-01-11 11:16:36 +0000
commite8f5cf2940667a60698d28fe0cae208792357676 (patch)
tree2dc2879b9c6e1e6c303ac0595d3eb6cfcbc113b5 /otk/util.cc
parentbc88d310fea71823fb2c61d071ff499579bffaba (diff)
valgrind fixes, and fixes for writing shit all over the environment. yay~!!!!!!!
Diffstat (limited to 'otk/util.cc')
-rw-r--r--otk/util.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/otk/util.cc b/otk/util.cc
index ebca51d5..a3ec0034 100644
--- a/otk/util.cc
+++ b/otk/util.cc
@@ -23,6 +23,9 @@ extern "C" {
# include <process.h>
#endif // HAVE_PROCESS_H __EMX__
+#include "gettext.h"
+#define _(str) gettext(str)
+
#include <assert.h>
}
@@ -48,9 +51,8 @@ void bexec(const string& command, const string& displaystring) {
#ifndef __EMX__
if (! fork()) {
setsid();
- int ret = putenv(const_cast<char *>(displaystring.c_str()));
- assert(ret != -1);
- ret = execl("/bin/sh", "/bin/sh", "-c", command.c_str(), NULL);
+ putenv(displaystring);
+ int ret = execl("/bin/sh", "/bin/sh", "-c", command.c_str(), NULL);
exit(ret);
}
#else // __EMX__
@@ -101,6 +103,19 @@ string itostring(long i) {
return tmp;
}
+void putenv(const std::string &data)
+{
+ char *c = new char[data.size() + 1];
+ std::string::size_type i, max;
+ for (i = 0, max = data.size(); i < max; ++i)
+ c[i] = data[i];
+ c[i] = 0;
+ if (::putenv(c)) {
+ printf(_("warning: couldn't set environment variable\n"));
+ perror("putenv()");
+ }
+}
+
string basename (const string& path) {
string::size_type slash = path.rfind('/');
if (slash == string::npos)