summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/driver_unified.cpp5
-rw-r--r--src/main/main.h2
-rw-r--r--src/main/util.cpp12
-rw-r--r--src/util/safe_print.cpp7
-rw-r--r--src/util/statistics.cpp4
-rw-r--r--src/util/statistics_registry.h2
6 files changed, 16 insertions, 16 deletions
diff --git a/src/main/driver_unified.cpp b/src/main/driver_unified.cpp
index 6de4f9ff4..5113bab10 100644
--- a/src/main/driver_unified.cpp
+++ b/src/main/driver_unified.cpp
@@ -61,7 +61,7 @@ namespace CVC4 {
const char *progPath;
/** Just the basename component of argv[0] */
- const char *progName;
+ const std::string *progName;
/** A pointer to the CommandExecutor (the signal handlers need it) */
CVC4::main::CommandExecutor* pExecutor = NULL;
@@ -112,7 +112,8 @@ int runCvc4(int argc, char* argv[], Options& opts) {
}
# endif
- progName = opts.getBinaryName().c_str();
+ string progNameStr = opts.getBinaryName();
+ progName = &progNameStr;
if( opts.getHelp() ) {
printUsage(opts, true);
diff --git a/src/main/main.h b/src/main/main.h
index 8277d366a..e4723a743 100644
--- a/src/main/main.h
+++ b/src/main/main.h
@@ -38,7 +38,7 @@ class CommandExecutor;
extern const char* progPath;
/** Just the basename component of argv[0] */
-extern const char* progName;
+extern const std::string* progName;
/** A reference for use by the signal handlers to print statistics */
extern CVC4::main::CommandExecutor* pExecutor;
diff --git a/src/main/util.cpp b/src/main/util.cpp
index 744122cc8..9dc5049a9 100644
--- a/src/main/util.cpp
+++ b/src/main/util.cpp
@@ -112,14 +112,14 @@ void segv_handler(int sig, siginfo_t* info, void* c) {
safe_print(STDERR_FILENO,
"Spinning so that a debugger can be connected.\n");
safe_print(STDERR_FILENO, "Try: gdb ");
- safe_print(STDERR_FILENO, progName);
+ safe_print(STDERR_FILENO, *progName);
safe_print(STDERR_FILENO, " ");
safe_print<int64_t>(STDERR_FILENO, getpid());
safe_print(STDERR_FILENO, "\n");
safe_print(STDERR_FILENO, " or: gdb --pid=");
safe_print<int64_t>(STDERR_FILENO, getpid());
safe_print(STDERR_FILENO, " ");
- safe_print(STDERR_FILENO, progName);
+ safe_print(STDERR_FILENO, *progName);
safe_print(STDERR_FILENO, "\n");
for(;;) {
sleep(60);
@@ -156,14 +156,14 @@ void ill_handler(int sig, siginfo_t* info, void*) {
safe_print(STDERR_FILENO,
"Spinning so that a debugger can be connected.\n");
safe_print(STDERR_FILENO, "Try: gdb ");
- safe_print(STDERR_FILENO, progName);
+ safe_print(STDERR_FILENO, *progName);
safe_print(STDERR_FILENO, " ");
safe_print<int64_t>(STDERR_FILENO, getpid());
safe_print(STDERR_FILENO, "\n");
safe_print(STDERR_FILENO, " or: gdb --pid=");
safe_print<int64_t>(STDERR_FILENO, getpid());
safe_print(STDERR_FILENO, " ");
- safe_print(STDERR_FILENO, progName);
+ safe_print(STDERR_FILENO, *progName);
safe_print(STDERR_FILENO, "\n");
for(;;) {
sleep(60);
@@ -206,14 +206,14 @@ void cvc4unexpected() {
safe_print(STDERR_FILENO,
"Spinning so that a debugger can be connected.\n");
safe_print(STDERR_FILENO, "Try: gdb ");
- safe_print(STDERR_FILENO, progName);
+ safe_print(STDERR_FILENO, *progName);
safe_print(STDERR_FILENO, " ");
safe_print<int64_t>(STDERR_FILENO, getpid());
safe_print(STDERR_FILENO, "\n");
safe_print(STDERR_FILENO, " or: gdb --pid=");
safe_print<int64_t>(STDERR_FILENO, getpid());
safe_print(STDERR_FILENO, " ");
- safe_print(STDERR_FILENO, progName);
+ safe_print(STDERR_FILENO, *progName);
safe_print(STDERR_FILENO, "\n");
for(;;) {
sleep(60);
diff --git a/src/util/safe_print.cpp b/src/util/safe_print.cpp
index ff5a7aa7e..dc986e251 100644
--- a/src/util/safe_print.cpp
+++ b/src/util/safe_print.cpp
@@ -128,9 +128,8 @@ void safe_print(int fd, const double& _d) {
d -= c;
i++;
}
- if (i == 0) {
- safe_print(fd, "0");
- } else if (write(fd, buf, i) != i) {
+
+ if (write(fd, buf, i) != i) {
abort();
}
}
@@ -172,7 +171,7 @@ void safe_print_hex(int fd, uint64_t i) {
// This loop fills the buffer from the end. The number of elements in the
// buffer is BUFER_SIZE - idx - 1 and they start at position idx + 1.
- size_t idx = BUFFER_SIZE - 1;
+ ssize_t idx = BUFFER_SIZE - 1;
while (i != 0 && idx >= 0) {
char current = i % 16;
if (current <= 9) {
diff --git a/src/util/statistics.cpp b/src/util/statistics.cpp
index 73ea5b1b1..9423c9379 100644
--- a/src/util/statistics.cpp
+++ b/src/util/statistics.cpp
@@ -122,8 +122,8 @@ void StatisticsBase::safeFlushInformation(int fd) const {
for (StatSet::iterator i = d_stats.begin(); i != d_stats.end(); ++i) {
Stat* s = *i;
if (d_prefix.size() != 0) {
- safe_print(fd, d_prefix.c_str());
- safe_print(fd, s_regDelim.c_str());
+ safe_print(fd, d_prefix);
+ safe_print(fd, s_regDelim);
}
s->safeFlushStat(fd);
safe_print(fd, "\n");
diff --git a/src/util/statistics_registry.h b/src/util/statistics_registry.h
index 1206a3e4a..bd7f87b44 100644
--- a/src/util/statistics_registry.h
+++ b/src/util/statistics_registry.h
@@ -137,7 +137,7 @@ public:
*/
virtual void safeFlushStat(int fd) const {
if (__CVC4_USE_STATISTICS) {
- safe_print(fd, d_name.c_str());
+ safe_print(fd, d_name);
safe_print(fd, ", ");
safeFlushInformation(fd);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback