aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-09-04 21:06:23 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-09-04 21:06:23 +0000
commit75068e7d753cf6cbe45a4bf294000dca9bd41d8b (patch)
treec6274cc10caab08349b5585206034f41ca4a575f /src/libutil/util.cc
parentaab88127321344d5818d823bff515d127108d058 (diff)
* Use a proper namespace.
* Optimise header file usage a bit. * Compile the parser as C++.
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 54cfc6c7f..44b39f8c6 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -9,17 +9,16 @@
#include <cstdio>
#include <sstream>
-#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
-#include <unistd.h>
-#include <dirent.h>
#include <fcntl.h>
-#include <signal.h>
#include "util.hh"
+namespace nix {
+
+
Error::Error(const format & f)
{
err = f.str();
@@ -368,8 +367,8 @@ void Nest::open(Verbosity level, const format & f)
{
if (level <= verbosity) {
if (logType == ltEscapes)
- cerr << "\033[" << escVerbosity(level) << "p"
- << f.str() << "\n";
+ std::cerr << "\033[" << escVerbosity(level) << "p"
+ << f.str() << "\n";
else
printMsg_(level, f);
nest = true;
@@ -383,7 +382,7 @@ void Nest::close()
if (nest) {
nestingLevel--;
if (logType == ltEscapes)
- cerr << "\033[q";
+ std::cerr << "\033[q";
nest = false;
}
}
@@ -697,8 +696,8 @@ string runProgram(Path program)
execl(program.c_str(), program.c_str(), (char *) 0);
throw SysError(format("executing `%1%'") % program);
- } catch (exception & e) {
- cerr << "error: " << e.what() << endl;
+ } catch (std::exception & e) {
+ std::cerr << "error: " << e.what() << std::endl;
}
quickExit(1);
}
@@ -743,7 +742,7 @@ void _interrupted()
/* Block user interrupts while an exception is being handled.
Throwing an exception while another exception is being handled
kills the program! */
- if (!uncaught_exception()) {
+ if (!std::uncaught_exception()) {
_isInterrupted = 0;
throw Error("interrupted by the user");
}
@@ -837,7 +836,7 @@ bool statusOk(int status)
string int2String(int n)
{
- ostringstream str;
+ std::ostringstream str;
str << n;
return str.str();
}
@@ -845,7 +844,10 @@ string int2String(int n)
bool string2Int(const string & s, int & n)
{
- istringstream str(s);
+ std::istringstream str(s);
str >> n;
return str && str.get() == EOF;
}
+
+
+}