aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/util/io.h12
-rw-r--r--src/handler.cc3
-rw-r--r--src/util/io.cc12
3 files changed, 13 insertions, 14 deletions
diff --git a/include/util/io.h b/include/util/io.h
index 52984c5..aaeac02 100644
--- a/include/util/io.h
+++ b/include/util/io.h
@@ -25,16 +25,16 @@ struct LogVoidify { void operator&(std::ostream&) const {} };
inline constexpr int DECIMAL = 10;
inline constexpr int LENGTH = 32;
-void safe_print(char *s, bool ignore_wrap = false);
+void safe_print(const char *s, bool ignore_wrap = false);
void safe_print(int x);
-void safe_debug(char *s, bool ignore_wrap = false);
+void safe_debug(const char *s, bool ignore_wrap = false);
void safe_debug(int x);
-bool isnum(char *s);
-void reverse(char str[], int length);
+bool isnum(const char *s);
+void reverse(char *str, int length);
char *itoa(int num, char* str, int base);
void usage(void);
-void unix_error(char *msg);
-void app_error(char *msg);
+void unix_error(const char *msg);
+void app_error(const char *msg);
}
diff --git a/src/handler.cc b/src/handler.cc
index 64d63e7..2e966f6 100644
--- a/src/handler.cc
+++ b/src/handler.cc
@@ -134,9 +134,8 @@ void sigint_handler([[maybe_unused]] int sig)
{
kill(-pid, SIGINT);
} else {
- char *buf = "\n";
tcflush(STDIN_FILENO, TCIFLUSH);
- ioctl(STDIN_FILENO, TIOCSTI, buf);
+ ioctl(STDIN_FILENO, TIOCSTI, "\n");
}
sigprocmask(SIG_SETMASK, &prev, nullptr);
diff --git a/src/util/io.cc b/src/util/io.cc
index 152271c..1fe37e5 100644
--- a/src/util/io.cc
+++ b/src/util/io.cc
@@ -5,7 +5,7 @@ using namespace std;
namespace ov4
{
-void safe_print(char *s, bool ignore_wrap)
+void safe_print(const char *s, bool ignore_wrap)
{
int errno_old = errno;
if (ignore_wrap)
@@ -28,7 +28,7 @@ void safe_print(int x)
errno = errno_old;
}
-void reverse(char str[], int length)
+void reverse(char *str, int length)
{
int errno_old = errno;
int start = 0;
@@ -43,7 +43,7 @@ void reverse(char str[], int length)
errno = errno_old;
}
-void safe_debug(char *s, bool ignore_wrap)
+void safe_debug(const char *s, bool ignore_wrap)
{
int errno_old = errno;
if (verbose && GLOBAL_DEBUG) safe_print(s, ignore_wrap);
@@ -57,7 +57,7 @@ void safe_debug(int x)
errno = errno_old;
}
-bool isnum(char *s)
+bool isnum(const char *s)
{
int errno_old = errno;
for (int i = 0; s[i] != 0; i++)
@@ -125,7 +125,7 @@ void usage(void)
/*
* unix_error - unix-style error routine
*/
-void unix_error(char *msg)
+void unix_error(const char *msg)
{
fprintf(stdout, "%s: %s\n", msg, strerror(errno));
exit(1);
@@ -134,7 +134,7 @@ void unix_error(char *msg)
/*
* app_error - application-style error routine
*/
-void app_error(char *msg)
+void app_error(const char *msg)
{
fprintf(stdout, "%s\n", msg);
exit(1);