From 03de8fcc4bf528479396943624d0271901de9c65 Mon Sep 17 00:00:00 2001 From: "Alexander S. Aganichev" Date: Thu, 3 Apr 2003 14:20:58 +0000 Subject: [PATCH] Fix formatting/cleaning --- golded3/gemsgid.cpp | 2 +- goldlib/gall/gfilutil.h | 2 +- goldlib/gall/gkbdbase.cpp | 40 +++++++++--------------- goldlib/gall/gkbdunix.cpp | 64 ++++++++++++--------------------------- goldlib/gall/gutlunix.cpp | 5 ++- goldlib/gall/gutlvers.cpp | 19 ++++++------ 6 files changed, 47 insertions(+), 85 deletions(-) diff --git a/golded3/gemsgid.cpp b/golded3/gemsgid.cpp index 565e3b5..ef08c00 100755 --- a/golded3/gemsgid.cpp +++ b/golded3/gemsgid.cpp @@ -44,7 +44,7 @@ ulong getMsgId() { ulong id; char *err; - if(CFG->seqmsgid and not (CFG->seqmsgid == MAYBE and *CFG->seqdir == NUL)) { + if(CFG->seqmsgid and not ((CFG->seqmsgid == MAYBE) and (*CFG->seqdir == NUL))) { id = GenMsgIdEx(CFG->seqdir, CFG->seqoutrun, getClassicMsgId, &err); if(err) { LOG.printf("* Warning, SeqMsgId failed: %s, fall to classic algorythm!", err); diff --git a/goldlib/gall/gfilutil.h b/goldlib/gall/gfilutil.h index 0eaa267..00f40bf 100644 --- a/goldlib/gall/gfilutil.h +++ b/goldlib/gall/gfilutil.h @@ -52,7 +52,7 @@ // ------------------------------------------------------------------M #if defined(__UNIX__) -#if not defined(__BEOS__) +#if !defined(__BEOS__) #define O_TEXT 0 #define O_BINARY 0 #endif diff --git a/goldlib/gall/gkbdbase.cpp b/goldlib/gall/gkbdbase.cpp index 82bf2b5..e11bb2c 100644 --- a/goldlib/gall/gkbdbase.cpp +++ b/goldlib/gall/gkbdbase.cpp @@ -180,7 +180,7 @@ GKbd::GKbd() { Init(); - #if defined(__UNIX__) && !defined(__USE_NCURSES__) && !defined(__BEOS__) + #if defined(__UNIX__) && !defined(__USE_NCURSES__) && !defined(__BEOS__) gkbd_keymap_init(); @@ -221,11 +221,11 @@ GKbd::GKbd() { gkbd_define_keysym("\033[5~", Key_PgUp); gkbd_define_keysym("\033[6~", Key_PgDn); - gkbd_define_keysym("\033[[A", Key_F1); - gkbd_define_keysym("\033[[B", Key_F2); - gkbd_define_keysym("\033[[C", Key_F3); - gkbd_define_keysym("\033[[D", Key_F4); - gkbd_define_keysym("\033[[E", Key_F5); + gkbd_define_keysym("\033[[A", Key_F1); + gkbd_define_keysym("\033[[B", Key_F2); + gkbd_define_keysym("\033[[C", Key_F3); + gkbd_define_keysym("\033[[D", Key_F4); + gkbd_define_keysym("\033[[E", Key_F5); gkbd_define_keysym("\033[17~", Key_F6); gkbd_define_keysym("\033[18~", Key_F7); gkbd_define_keysym("\033[19~", Key_F8); @@ -306,7 +306,7 @@ GKbd::GKbd() { gkbd_define_keysym(escseq, (n < 128) ? (scancode_table[n]|n) : n); } - // gkbd_define_keysym("^@", 0); ????????? + // gkbd_define_keysym("^@", 0); ????????? gkbd_define_keysym("\033[A", Key_Up); gkbd_define_keysym("\033[B", Key_Dwn); @@ -319,13 +319,13 @@ GKbd::GKbd() { gkbd_define_keysym("\033[5~", Key_PgUp); gkbd_define_keysym("\033[6~", Key_PgDn); -// gkbd_define_keysym("\033[3~", Key_Del); + // gkbd_define_keysym("\033[3~", Key_Del); - gkbd_define_keysym("\033[11~", Key_F1); - gkbd_define_keysym("\033[12~", Key_F2); - gkbd_define_keysym("\033[13~", Key_F3); - gkbd_define_keysym("\033[14~", Key_F4); - gkbd_define_keysym("\033[15~", Key_F5); + gkbd_define_keysym("\033[11~", Key_F1); + gkbd_define_keysym("\033[12~", Key_F2); + gkbd_define_keysym("\033[13~", Key_F3); + gkbd_define_keysym("\033[14~", Key_F4); + gkbd_define_keysym("\033[15~", Key_F5); gkbd_define_keysym("\033[16~", Key_F6); gkbd_define_keysym("\033[17~", Key_F7); gkbd_define_keysym("\033[18~", Key_F8); @@ -1508,7 +1508,7 @@ gkey kbxget_raw(int mode) { case Key_PgDn: k = Key_A_PgDn; break; case Key_PgUp: k = Key_A_PgUp; break; case Key_End: k = Key_A_End; break; - // case Key_: k=Key_A_; break; + // case Key_: k=Key_A_; break; default: break; } else if(shifts & (LSHIFT | RSHIFT)) @@ -1556,17 +1556,7 @@ gkey kbxget_raw(int mode) { case Key_F12: k=Key_C_F12; break; } } - } /*else if(k == Key_BS) { - // Under Linux we could use TIOCLINUX fn. 6 to read shift states on console - // Of course it is very unportable but should produce good results :-) - int shifts = 6; - if(ioctl(fileno(stdin), TIOCLINUX, &shifts) == -1) - shifts = 0; - if(shifts & ALT) - k = Key_A_BS; - else if(shifts & GCTRL) - k = Key_C_BS; - }*/ + } #endif return k; diff --git a/goldlib/gall/gkbdunix.cpp b/goldlib/gall/gkbdunix.cpp index 1cff9bc..62afe40 100644 --- a/goldlib/gall/gkbdunix.cpp +++ b/goldlib/gall/gkbdunix.cpp @@ -41,12 +41,6 @@ #include #include -#ifdef __BEOS__ -//sz: some undocumented call that behaves in same manner as select ... -extern "C" int waiton( int, fd_set *, fd_set *, fd_set *, bigtime_t); -#endif - - // ------------------------------------------------------------------ int gkbd_stdin = -1; @@ -186,51 +180,31 @@ int gkbd_sys_input_pending(int tsecs) { return select(gkbd_stdin+1, &read_fd_set, NULL, NULL, &wait); #else - //bigtime_t t= bigtime_t(secs) * 1000000L + usecs; - ///*return*/ waiton(gkbd_stdin+1, &read_fd_set, NULL, NULL, 0/*t * 1000*/); - //return 0; + struct termios term, oterm; + int fd = gkbd_stdin; + int c = 0; - struct termios term, oterm; - int fd = gkbd_stdin; - int c = 0; + // get the terminal settings + tcgetattr(fd, &oterm); - /* get the terminal settings */ - tcgetattr(fd, &oterm); + // get a copy of the settings, which we modify + memcpy(&term, &oterm, sizeof(term)); - /* get a copy of the settings, which we modify */ - memcpy(&term, &oterm, sizeof(term)); + // put the terminal in non-canonical mode, any + // reads timeout after 0.1 seconds or when a + // single character is read + term.c_lflag = term.c_lflag & (!ICANON); + term.c_cc[VMIN] = 0; + term.c_cc[VTIME] = 1; + tcsetattr(fd, TCSANOW, &term); - /* put the terminal in non-canonical mode, any - reads timeout after 0.1 seconds or when a - single character is read */ - term.c_lflag = term.c_lflag & (!ICANON); - term.c_cc[VMIN] = 0; - term.c_cc[VTIME] = 1; - tcsetattr(fd, TCSANOW, &term); + int bytes = -1; + ioctl(fd, TCWAITEVENT, &bytes); - /* get input - timeout after 0.1 seconds or - when one character is read. If timed out - getchar() returns -1, otherwise it returns - the character */ -/* c=getchar(); -*/ -int bytes = -1; -ioctl(fd, TCWAITEVENT, &bytes); - - /* reset the terminal to original state */ - tcsetattr(fd, TCSANOW, &oterm); - - /* if we retrieved a character, put it back on - the input stream */ -/* if (c != -1) - ungetc(c, stdin); - - /* return 1 if the keyboard was hit, or 0 if it - was not hit */ -/* return ((c!=-1)?1:0); -*/ -return bytes; + // reset the terminal to original state + tcsetattr(fd, TCSANOW, &oterm); + return bytes; #endif } diff --git a/goldlib/gall/gutlunix.cpp b/goldlib/gall/gutlunix.cpp index 3cf40c3..0bc1c6d 100644 --- a/goldlib/gall/gutlunix.cpp +++ b/goldlib/gall/gutlunix.cpp @@ -86,12 +86,11 @@ void g_increase_priority(void) { void g_set_ostitle(char* title, word dx) { - NW(dx); + NW(dx); #ifndef __BEOS__ NW(title); #else - char fmt[]={'\x1b','\x5d','\x32','\x3b', '%', 's', '\x07', 0}; - fprintf(stdout, fmt, title); + printf("\x1b\x5d\x32\x3b%s\x07", title); fflush(stdout); #endif } diff --git a/goldlib/gall/gutlvers.cpp b/goldlib/gall/gutlvers.cpp index fc0e442..2f588e0 100644 --- a/goldlib/gall/gutlvers.cpp +++ b/goldlib/gall/gutlvers.cpp @@ -52,23 +52,22 @@ char* ggetosstring(void) { struct utsname info; - if(uname(&info) != -1) + if(uname(&info) != -1) { #if defined(__EMX__) sprintf(osstring, "%s %s.%s %s", info.sysname, info.version, info.release, info.machine); #elif defined(__DJGPP__) sprintf(osstring, "%s %s.%s %s", info.sysname, info.release, info.version, info.machine); #elif defined(__BEOS__) - { - BAppFileInfo appFileInfo; - version_info sys_ver = {0}; - BFile file("/boot/beos/system/lib/libbe.so", B_READ_ONLY); - appFileInfo.SetTo(&file); - appFileInfo.GetVersionInfo(&sys_ver, B_APP_VERSION_KIND); - sprintf(osstring, "%s %s %s", info.sysname, sys_ver.short_info, info.machine); - } - #else + BAppFileInfo appFileInfo; + version_info sys_ver = {0}; + BFile file("/boot/beos/system/lib/libbe.so", B_READ_ONLY); + appFileInfo.SetTo(&file); + appFileInfo.GetVersionInfo(&sys_ver, B_APP_VERSION_KIND); + sprintf(osstring, "%s %s %s", info.sysname, sys_ver.short_info, info.machine); + #else sprintf(osstring, "%s %s %s", info.sysname, info.release, info.machine); #endif + } else strcpy(osstring, "unknown");