From 8bff65bbd2da7f07c97371faf271d6dd5b66db21 Mon Sep 17 00:00:00 2001 From: Joseph Carter Date: Sun, 1 Jul 2001 08:59:49 +0000 Subject: [PATCH] A little more cleanup of the sys stuff, at least for unix. I don't want to mess with the win32 stuff just now without coordinating with Coderjoe, which I don't have time for just now.. --- nq/source/sys_unix.c | 82 +----------------------- nq/source/sys_unixd.c | 143 +----------------------------------------- 2 files changed, 5 insertions(+), 220 deletions(-) diff --git a/nq/source/sys_unix.c b/nq/source/sys_unix.c index 58132950c..6196acc09 100644 --- a/nq/source/sys_unix.c +++ b/nq/source/sys_unix.c @@ -81,54 +81,11 @@ Sys_DebugLog (char *file, char *fmt, ...) close (fd); } -void -Sys_EditFile (char *filename) -{ - char cmd[256]; - char *term; - char *editor; - - term = getenv ("TERM"); - if (term && !strcmp (term, "xterm")) { - editor = getenv ("VISUAL"); - if (!editor) - editor = getenv ("EDITOR"); - if (!editor) - editor = getenv ("EDIT"); - if (!editor) - editor = "vi"; - snprintf (cmd, sizeof (cmd), "xterm -e %s %s", editor, filename); - system (cmd); - } -} /* * System I/O */ -void -Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length) -{ - int r; - unsigned long addr; - int psize = getpagesize (); - - addr = (startaddr & ~(psize - 1)) - psize; - -// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr, -// addr, startaddr+length, length); - - r = mprotect ((char *) addr, length + startaddr - addr + psize, 7); - - if (r < 0) - Sys_Error ("Protection change failed\n"); - -} - -void -Sys_DebugNumber (int y, int val) -{ -} void Sys_Error (const char *error, ...) @@ -166,34 +123,6 @@ Sys_Init (void) #endif } -void -Sys_Warn (char *warning, ...) -{ - va_list argptr; - char string[1024]; - - va_start (argptr, warning); - vsnprintf (string, sizeof (string), warning, argptr); - va_end (argptr); - fprintf (stderr, "Warning: %s", string); -} - -// ======================================================================= -// Sleeps for microseconds -// ======================================================================= - -static volatile int oktogo; - -void -alarm_handler (int x) -{ - oktogo = 1; -} - -void -Sys_LineRefresh (void) -{ -} void floating_point_exception_handler (int whatever) @@ -202,7 +131,7 @@ floating_point_exception_handler (int whatever) signal (SIGFPE, floating_point_exception_handler); } -char * +char * Sys_ConsoleInput (void) { static char text[256]; @@ -242,7 +171,7 @@ Sys_LowFPPrecision (void) #endif int -main (int c, char **v) +main (int c, char *v[]) { double time, oldtime, newtime; @@ -251,9 +180,6 @@ main (int c, char **v) extern int recording; int j; -// static char cwd[1024]; - -// signal(SIGFPE, floating_point_exception_handler); signal (SIGFPE, SIG_IGN); memset (&parms, 0, sizeof (parms)); @@ -310,9 +236,7 @@ main (int c, char **v) Host_Frame (time); -// graphic debugging aids -// if (sys_linerefresh->value) -// Sys_LineRefresh (); } } + diff --git a/nq/source/sys_unixd.c b/nq/source/sys_unixd.c index 5d900a05d..c97f36852 100644 --- a/nq/source/sys_unixd.c +++ b/nq/source/sys_unixd.c @@ -71,75 +71,6 @@ cvar_t *sys_linerefresh; cvar_t *timestamps; cvar_t *timeformat; -/* The translation table between the graphical font and plain ASCII --KB */ -static char qfont_table[256] = { - '\0', '#', '#', '#', '#', '.', '#', '#', - '#', 9, 10, '#', ' ', 13, '.', '.', - '[', ']', '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', '.', '<', '=', '>', - ' ', '!', '"', '#', '$', '%', '&', '\'', - '(', ')', '*', '+', ',', '-', '.', '/', - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', ':', ';', '<', '=', '>', '?', - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', - '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', '{', '|', '}', '~', '<', - - '<', '=', '>', '#', '#', '.', '#', '#', - '#', '#', ' ', '#', ' ', '>', '.', '.', - '[', ']', '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', '.', '<', '=', '>', - ' ', '!', '"', '#', '$', '%', '&', '\'', - '(', ')', '*', '+', ',', '-', '.', '/', - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', ':', ';', '<', '=', '>', '?', - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', - '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', '{', '|', '}', '~', '<' -}; - - -/* - * File I/O - */ - -/* - Sys_FileTime - - Returns -1 if file not present -*/ -int -Sys_FileTime (char *path) -{ - struct stat buf; - - if (stat (path, &buf) == -1) - return -1; - - return buf.st_mtime; -} - -/* - Sys_mkdir - - Creates a directory -*/ -void -Sys_mkdir (char *path) -{ - mkdir (path, 0777); -} - int Sys_FileOpenRead (char *path, int *handle) { @@ -212,41 +143,6 @@ Sys_DebugLog (char *file, char *fmt, ...) close (fd); } -void -Sys_EditFile (char *filename) -{ - char cmd[256]; - char *term; - char *editor; - - term = getenv ("TERM"); - if (term && !strcmp (term, "xterm")) { - editor = getenv ("VISUAL"); - if (!editor) - editor = getenv ("EDITOR"); - if (!editor) - editor = getenv ("EDIT"); - if (!editor) - editor = "vi"; - snprintf (cmd, sizeof (cmd), "xterm -e %s %s", editor, filename); - system (cmd); - } -} - -/* - * System I/O - */ - -void -Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length) -{ -} - -void -Sys_DebugNumber (int y, int val) -{ -} - #define MAX_PRINT_MSG 4096 void Sys_Printf (char *fmt, ...) @@ -321,18 +217,6 @@ Sys_Init (void) #endif } -void -Sys_Warn (char *warning, ...) -{ - va_list argptr; - char string[1024]; - - va_start (argptr, warning); - vsnprintf (string, sizeof (string), warning, argptr); - va_end (argptr); - fprintf (stderr, "Warning: %s", string); -} - double Sys_DoubleTime (void) { @@ -350,31 +234,8 @@ Sys_DoubleTime (void) return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0; } -// ======================================================================= -// Sleeps for microseconds -// ======================================================================= -static volatile int oktogo; - -void -alarm_handler (int x) -{ - oktogo = 1; -} - -void -Sys_LineRefresh (void) -{ -} - -void -floating_point_exception_handler (int whatever) -{ -// Sys_Warn("floating point exception\n"); - signal (SIGFPE, floating_point_exception_handler); -} - -char * +char * Sys_ConsoleInput (void) { static char text[256]; @@ -421,7 +282,6 @@ main (int argc, char *argv[]) char *newargv[256]; int j; -// signal (SIGFPE, floating_point_exception_handler); signal (SIGFPE, SIG_IGN); memset (&parms, 0, sizeof (parms)); @@ -469,3 +329,4 @@ main (int argc, char *argv[]) } return true; // return success } +