From 44f7e6691e04e724f9d299dde4e3a8d11965ba0c Mon Sep 17 00:00:00 2001 From: pcg Date: Fri, 13 Feb 2004 12:16:21 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 1 + src/callback.h | 144 +++++++++++----------- src/command.C | 2 +- src/command.h | 4 +- src/defaultfont.C | 6 +- src/defaultfont.h | 2 +- src/encoding.h | 2 +- src/feature.h | 2 +- src/grkelot.C | 146 +++++++++++----------- src/grkelot.h | 4 +- src/init.C | 304 +++++++++++++++++++++++----------------------- src/init.h | 10 +- src/iom.C | 6 +- src/iom.h | 20 +-- src/logging.C | 232 +++++++++++++++++------------------ src/main.C | 280 +++++++++++++++++++++--------------------- 16 files changed, 583 insertions(+), 582 deletions(-) diff --git a/Changes b/Changes index 4e8ad577..5848e229 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,7 @@ crashes when you kill your input method (xterm crashes, too). - fix bugs in x flushing, causing an empty screen after startup the first until the first event arives. + - fix ~15kb memleak per term in rxvtd. 1.8 Mon Feb 2 20:09:18 CET 2004 - almost total conversion to C++. Except for introducing diff --git a/src/callback.h b/src/callback.h index ec951883..8b9beeeb 100644 --- a/src/callback.h +++ b/src/callback.h @@ -32,17 +32,17 @@ class callback0 { struct object { }; void *obj; - R (object::*meth)(); + R (object::*meth) (); /* a proxy is a kind of recipe on how to call a specific class method */ struct proxy_base { - virtual R call (void *obj, R (object::*meth)()) = 0; + virtual R call (void *obj, R (object::*meth) ()) = 0; }; template struct proxy : proxy_base { - virtual R call (void *obj, R (object::*meth)()) + virtual R call (void *obj, R (object::*meth) ()) { - ((reinterpret_cast(obj)) ->* (reinterpret_cast(meth))) + ((reinterpret_cast (obj)) ->* (reinterpret_cast (meth))) (); } }; @@ -51,20 +51,20 @@ class callback0 { public: template - callback0 (O1 *object, R (O2::*method)()) + callback0 (O1 *object, R (O2::*method) ()) { static proxy p; - obj = reinterpret_cast(object); - meth = reinterpret_cast(method); + obj = reinterpret_cast (object); + meth = reinterpret_cast (method); prxy = &p; } - R call() const + R call () const { return prxy->call (obj, meth); } - R operator ()() const + R operator () () const { return call (); } @@ -75,17 +75,17 @@ class callback1 { struct object { }; void *obj; - R (object::*meth)(A1); + R (object::*meth) (A1); /* a proxy is a kind of recipe on how to call a specific class method */ struct proxy_base { - virtual R call (void *obj, R (object::*meth)(A1), A1 a1) = 0; + virtual R call (void *obj, R (object::*meth) (A1), A1 a1) = 0; }; template struct proxy : proxy_base { - virtual R call (void *obj, R (object::*meth)(A1), A1 a1) + virtual R call (void *obj, R (object::*meth) (A1), A1 a1) { - ((reinterpret_cast(obj)) ->* (reinterpret_cast(meth))) + ((reinterpret_cast (obj)) ->* (reinterpret_cast (meth))) (a1); } }; @@ -94,20 +94,20 @@ class callback1 { public: template - callback1 (O1 *object, R (O2::*method)(A1)) + callback1 (O1 *object, R (O2::*method) (A1)) { static proxy p; - obj = reinterpret_cast(object); - meth = reinterpret_cast(method); + obj = reinterpret_cast (object); + meth = reinterpret_cast (method); prxy = &p; } - R call(A1 a1) const + R call (A1 a1) const { return prxy->call (obj, meth, a1); } - R operator ()(A1 a1) const + R operator () (A1 a1) const { return call (a1); } @@ -118,17 +118,17 @@ class callback2 { struct object { }; void *obj; - R (object::*meth)(A1, A2); + R (object::*meth) (A1, A2); /* a proxy is a kind of recipe on how to call a specific class method */ struct proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) = 0; + virtual R call (void *obj, R (object::*meth) (A1, A2), A1 a1, A2 a2) = 0; }; template struct proxy : proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) + virtual R call (void *obj, R (object::*meth) (A1, A2), A1 a1, A2 a2) { - ((reinterpret_cast(obj)) ->* (reinterpret_cast(meth))) + ((reinterpret_cast (obj)) ->* (reinterpret_cast (meth))) (a1, a2); } }; @@ -137,20 +137,20 @@ class callback2 { public: template - callback2 (O1 *object, R (O2::*method)(A1, A2)) + callback2 (O1 *object, R (O2::*method) (A1, A2)) { static proxy p; - obj = reinterpret_cast(object); - meth = reinterpret_cast(method); + obj = reinterpret_cast (object); + meth = reinterpret_cast (method); prxy = &p; } - R call(A1 a1, A2 a2) const + R call (A1 a1, A2 a2) const { return prxy->call (obj, meth, a1, a2); } - R operator ()(A1 a1, A2 a2) const + R operator () (A1 a1, A2 a2) const { return call (a1, a2); } @@ -161,17 +161,17 @@ class callback3 { struct object { }; void *obj; - R (object::*meth)(A1, A2, A3); + R (object::*meth) (A1, A2, A3); /* a proxy is a kind of recipe on how to call a specific class method */ struct proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) = 0; + virtual R call (void *obj, R (object::*meth) (A1, A2, A3), A1 a1, A2 a2, A3 a3) = 0; }; template struct proxy : proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) + virtual R call (void *obj, R (object::*meth) (A1, A2, A3), A1 a1, A2 a2, A3 a3) { - ((reinterpret_cast(obj)) ->* (reinterpret_cast(meth))) + ((reinterpret_cast (obj)) ->* (reinterpret_cast (meth))) (a1, a2, a3); } }; @@ -180,20 +180,20 @@ class callback3 { public: template - callback3 (O1 *object, R (O2::*method)(A1, A2, A3)) + callback3 (O1 *object, R (O2::*method) (A1, A2, A3)) { static proxy p; - obj = reinterpret_cast(object); - meth = reinterpret_cast(method); + obj = reinterpret_cast (object); + meth = reinterpret_cast (method); prxy = &p; } - R call(A1 a1, A2 a2, A3 a3) const + R call (A1 a1, A2 a2, A3 a3) const { return prxy->call (obj, meth, a1, a2, a3); } - R operator ()(A1 a1, A2 a2, A3 a3) const + R operator () (A1 a1, A2 a2, A3 a3) const { return call (a1, a2, a3); } @@ -204,17 +204,17 @@ class callback4 { struct object { }; void *obj; - R (object::*meth)(A1, A2, A3, A4); + R (object::*meth) (A1, A2, A3, A4); /* a proxy is a kind of recipe on how to call a specific class method */ struct proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) = 0; + virtual R call (void *obj, R (object::*meth) (A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) = 0; }; template struct proxy : proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) + virtual R call (void *obj, R (object::*meth) (A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) { - ((reinterpret_cast(obj)) ->* (reinterpret_cast(meth))) + ((reinterpret_cast (obj)) ->* (reinterpret_cast (meth))) (a1, a2, a3, a4); } }; @@ -223,20 +223,20 @@ class callback4 { public: template - callback4 (O1 *object, R (O2::*method)(A1, A2, A3, A4)) + callback4 (O1 *object, R (O2::*method) (A1, A2, A3, A4)) { static proxy p; - obj = reinterpret_cast(object); - meth = reinterpret_cast(method); + obj = reinterpret_cast (object); + meth = reinterpret_cast (method); prxy = &p; } - R call(A1 a1, A2 a2, A3 a3, A4 a4) const + R call (A1 a1, A2 a2, A3 a3, A4 a4) const { return prxy->call (obj, meth, a1, a2, a3, a4); } - R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const + R operator () (A1 a1, A2 a2, A3 a3, A4 a4) const { return call (a1, a2, a3, a4); } @@ -247,17 +247,17 @@ class callback5 { struct object { }; void *obj; - R (object::*meth)(A1, A2, A3, A4, A5); + R (object::*meth) (A1, A2, A3, A4, A5); /* a proxy is a kind of recipe on how to call a specific class method */ struct proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) = 0; + virtual R call (void *obj, R (object::*meth) (A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) = 0; }; template struct proxy : proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) + virtual R call (void *obj, R (object::*meth) (A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { - ((reinterpret_cast(obj)) ->* (reinterpret_cast(meth))) + ((reinterpret_cast (obj)) ->* (reinterpret_cast (meth))) (a1, a2, a3, a4, a5); } }; @@ -266,20 +266,20 @@ class callback5 { public: template - callback5 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5)) + callback5 (O1 *object, R (O2::*method) (A1, A2, A3, A4, A5)) { static proxy p; - obj = reinterpret_cast(object); - meth = reinterpret_cast(method); + obj = reinterpret_cast (object); + meth = reinterpret_cast (method); prxy = &p; } - R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const + R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { return prxy->call (obj, meth, a1, a2, a3, a4, a5); } - R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const + R operator () (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { return call (a1, a2, a3, a4, a5); } @@ -290,17 +290,17 @@ class callback6 { struct object { }; void *obj; - R (object::*meth)(A1, A2, A3, A4, A5, A6); + R (object::*meth) (A1, A2, A3, A4, A5, A6); /* a proxy is a kind of recipe on how to call a specific class method */ struct proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) = 0; + virtual R call (void *obj, R (object::*meth) (A1, A2, A3, A4, A5, A6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) = 0; }; template struct proxy : proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) + virtual R call (void *obj, R (object::*meth) (A1, A2, A3, A4, A5, A6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { - ((reinterpret_cast(obj)) ->* (reinterpret_cast(meth))) + ((reinterpret_cast (obj)) ->* (reinterpret_cast (meth))) (a1, a2, a3, a4, a5, a6); } }; @@ -309,20 +309,20 @@ class callback6 { public: template - callback6 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6)) + callback6 (O1 *object, R (O2::*method) (A1, A2, A3, A4, A5, A6)) { static proxy p; - obj = reinterpret_cast(object); - meth = reinterpret_cast(method); + obj = reinterpret_cast (object); + meth = reinterpret_cast (method); prxy = &p; } - R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const + R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6); } - R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const + R operator () (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { return call (a1, a2, a3, a4, a5, a6); } @@ -333,17 +333,17 @@ class callback7 { struct object { }; void *obj; - R (object::*meth)(A1, A2, A3, A4, A5, A6, A7); + R (object::*meth) (A1, A2, A3, A4, A5, A6, A7); /* a proxy is a kind of recipe on how to call a specific class method */ struct proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) = 0; + virtual R call (void *obj, R (object::*meth) (A1, A2, A3, A4, A5, A6, A7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) = 0; }; template struct proxy : proxy_base { - virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) + virtual R call (void *obj, R (object::*meth) (A1, A2, A3, A4, A5, A6, A7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { - ((reinterpret_cast(obj)) ->* (reinterpret_cast(meth))) + ((reinterpret_cast (obj)) ->* (reinterpret_cast (meth))) (a1, a2, a3, a4, a5, a6, a7); } }; @@ -352,20 +352,20 @@ class callback7 { public: template - callback7 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7)) + callback7 (O1 *object, R (O2::*method) (A1, A2, A3, A4, A5, A6, A7)) { static proxy p; - obj = reinterpret_cast(object); - meth = reinterpret_cast(method); + obj = reinterpret_cast (object); + meth = reinterpret_cast (method); prxy = &p; } - R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const + R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const { return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7); } - R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const + R operator () (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const { return call (a1, a2, a3, a4, a5, a6, a7); } diff --git a/src/command.C b/src/command.C index 8c13ee9f..54c1e1a8 100644 --- a/src/command.C +++ b/src/command.C @@ -2371,7 +2371,7 @@ rxvt_term::process_escape_seq () if (cmd_getc () == '8') scr_E (); break; - case ' (': + case '(': scr_charset_set (0, (unsigned int)cmd_getc ()); break; case ')': diff --git a/src/command.h b/src/command.h index 50c7c90c..1765fac9 100644 --- a/src/command.h +++ b/src/command.h @@ -1,5 +1,5 @@ /* - * $Id: command.h,v 1.5 2004-01-17 01:20:01 pcg Exp $ + * $Id: command.h,v 1.6 2004-02-13 12:16:21 pcg Exp $ */ #ifndef COMMAND_H_ @@ -75,7 +75,7 @@ * software in question is broken enough to be case insensitive to the 'c' * character in the answerback string, we make the distinguishing * characteristic be capitalization of that character. The length of the - * two strings should be the same so that identical read(2) calls may be + * two strings should be the same so that identical read (2) calls may be * used. */ #define VT100_ANS "\033[?1;2c" /* vt100 answerback */ diff --git a/src/defaultfont.C b/src/defaultfont.C index a49c5489..6835eb91 100644 --- a/src/defaultfont.C +++ b/src/defaultfont.C @@ -944,7 +944,7 @@ rxvt_font_xft::draw (int x, int y, ///////////////////////////////////////////////////////////////////////////// rxvt_fontset::rxvt_fontset (rxvt_t r) -: r(r) +: r (r) { clear (); } @@ -957,7 +957,7 @@ rxvt_fontset::~rxvt_fontset () void rxvt_fontset::clear () { - for (rxvt_font **i = fonts.begin (); i != fonts.end(); i++) + for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) FONT_UNREF (*i); fonts.clear (); @@ -1086,7 +1086,7 @@ rxvt_fontset::populate (const char *desc) // we currently need a base-font, no matter what if ((int)fonts.size () <= base_id || !realize_font (base_id)) { - puts ("unable to load specified font(s), falling back to 'fixed'\n"); + puts ("unable to load specified font (s), falling back to 'fixed'\n"); add_fonts ("fixed"); base_id = fonts.size () - 1; } diff --git a/src/defaultfont.h b/src/defaultfont.h index ea0be955..5e14c768 100644 --- a/src/defaultfont.h +++ b/src/defaultfont.h @@ -80,7 +80,7 @@ struct rxvt_fontset { void populate (const char *desc); int find_font (uint32_t unicode); - rxvt_font *operator [](int id) const + rxvt_font *operator [] (int id) const { return fonts[id]; } diff --git a/src/encoding.h b/src/encoding.h index 7b4ff04a..51035235 100644 --- a/src/encoding.h +++ b/src/encoding.h @@ -61,7 +61,7 @@ codeset codeset_from_name (const char *name); enum { ZERO_WIDTH_CHAR = 0x200b, - NOCHAR = 65535, // must be invalid in ANY codeset(!) + NOCHAR = 65535, // must be invalid in ANY codeset (!) }; struct rxvt_codeset_conv { diff --git a/src/feature.h b/src/feature.h index 43874af1..90d6f773 100644 --- a/src/feature.h +++ b/src/feature.h @@ -112,7 +112,7 @@ #define COLOR_CURSOR_BACKGROUND NULL /* if NULL, use foreground colour */ /* - * Define to remove support for XCopyArea() support. XCopyArea() is useful + * Define to remove support for XCopyArea () support. XCopyArea () is useful * for scrolling on non-local X displays */ /* #define NO_SLOW_LINK_SUPPORT */ diff --git a/src/grkelot.C b/src/grkelot.C index 3422a841..e26ec26d 100644 --- a/src/grkelot.C +++ b/src/grkelot.C @@ -33,9 +33,9 @@ * * The FSM can have MAX_STATES states (change it for more). * Each state contains: - * 1. many tranlsation tables (registered via kstate_add_xlat()) + * 1. many tranlsation tables (registered via kstate_add_xlat ()) * 2. many switch codes for transition to other states (registered via - * kstate_add_switcher()) : limit is static now: MAX_SWITCHER + * kstate_add_switcher ()) : limit is static now: MAX_SWITCHER * 3. life: the number of xlations allowed in a state (0 = unlimited) * * Format of tranlation strings: @@ -166,13 +166,13 @@ static XLAT_TYPE *xlat_now = &xlat_type[GREEK_ELOT928]; #define NUM_XLAT_TYPES (sizeof(xlat_type) / sizeof(xlat_type[0])) -static void kstate_add_xlat(char *str); -static void kstate_add_switcher(char *str); -static void kstate_set_life(char *str); +static void kstate_add_xlat (char *str); +static void kstate_add_switcher (char *str); +static void kstate_set_life (char *str); /* --- Functions ------------- */ void -kstate_setcurr(int stateno) +kstate_setcurr (int stateno) { u_char prev_state; @@ -187,21 +187,21 @@ kstate_setcurr(int stateno) } void -kstate_init(void) +kstate_init (void) { pStateNow->num_xlat = pStateNow->num_switcher = pStateNow->life = pStateNow->prev_state = 0; pStateNow->xlat = NULL; } void -kstate_end(void) +kstate_end (void) { int i; for (i = 0; i < pStateNow->num_xlat; i++) - free(pStateNow->xlat[i].pval); + free (pStateNow->xlat[i].pval); if (pStateNow->num_xlat > 0) - free(pStateNow->xlat); + free (pStateNow->xlat); } /* @@ -209,65 +209,65 @@ kstate_end(void) * to support other remappers. */ void -kstate_init_all(int greek_mode) +kstate_init_all (int greek_mode) { /* the translation tables for the 4 FSM states for ELOT-928 mappings */ int i; for (i = 0; i < MAX_STATES; i++) { - kstate_setcurr(i); - kstate_init(); + kstate_setcurr (i); + kstate_init (); } if (greek_mode < 0 || greek_mode >= NUM_XLAT_TYPES) /* avoid death */ greek_mode = GREEK_ELOT928; xlat_now = &xlat_type[greek_mode]; - kstate_setcurr(0); - kstate_add_xlat(xlat_now->plain); - kstate_add_switcher("A;:1"); - kstate_add_switcher("A::2"); - kstate_set_life("L0"); - - kstate_setcurr(1); - kstate_add_xlat(xlat_now->accent); - kstate_add_xlat(xlat_now->accent_xtra); - kstate_add_switcher("A::3"); - kstate_set_life("L1"); - - kstate_setcurr(2); - kstate_add_xlat(xlat_now->umlaut); - kstate_add_switcher("A;:3"); - kstate_set_life("L1"); - - kstate_setcurr(3); - kstate_add_xlat(xlat_now->acc_uml); - kstate_set_life("L1"); + kstate_setcurr (0); + kstate_add_xlat (xlat_now->plain); + kstate_add_switcher ("A;:1"); + kstate_add_switcher ("A::2"); + kstate_set_life ("L0"); + + kstate_setcurr (1); + kstate_add_xlat (xlat_now->accent); + kstate_add_xlat (xlat_now->accent_xtra); + kstate_add_switcher ("A::3"); + kstate_set_life ("L1"); + + kstate_setcurr (2); + kstate_add_xlat (xlat_now->umlaut); + kstate_add_switcher ("A;:3"); + kstate_set_life ("L1"); + + kstate_setcurr (3); + kstate_add_xlat (xlat_now->acc_uml); + kstate_set_life ("L1"); } void -kstate_end_all(void) +kstate_end_all (void) { int i; for (i = 0; i < MAX_STATES; i++) { - kstate_setcurr(i); - kstate_end(); + kstate_setcurr (i); + kstate_end (); } - kstate_setcurr(0); + kstate_setcurr (0); } /* * reset FSM */ void -kstate_reset(void) +kstate_reset (void) { - kstate_setcurr(0); + kstate_setcurr (0); } void -kstate_add_xlat(char *str) +kstate_add_xlat (char *str) { K_XLAT *xlat; u_int *pval_tmp; @@ -279,22 +279,22 @@ kstate_add_xlat(char *str) /* add a new xlat table in state */ if (pStateNow->num_xlat == 0) { - pStateNow->xlat = malloc(sizeof(K_XLAT)); + pStateNow->xlat = malloc (sizeof (K_XLAT)); } else /* prefer contiguous data, realloc */ - pStateNow->xlat = realloc(pStateNow->xlat, (pStateNow->num_xlat + 1) * sizeof(K_XLAT)); + pStateNow->xlat = realloc (pStateNow->xlat, (pStateNow->num_xlat + 1) * sizeof (K_XLAT)); xlat = &pStateNow->xlat[pStateNow->num_xlat]; /* parse str and derive first, last, values */ - xlat->first = (u_int) atoi(strtok(str, "-")); - xlat->last = (u_int) atoi(strtok(NULL, ":")); + xlat->first = (u_int) atoi (strtok (str, "-")); + xlat->last = (u_int) atoi (strtok (NULL, ":")); i = 0; - pval_tmp = calloc(MAX_VAL, sizeof(K_XLAT)); - while ((sval = strtok(NULL, ",")) != NULL) - pval_tmp[i++] = (u_int) (atoi(sval)); - xlat->pval = calloc(i, sizeof(K_XLAT)); + pval_tmp = calloc (MAX_VAL, sizeof (K_XLAT)); + while ((sval = strtok (NULL, ",")) != NULL) + pval_tmp[i++] = (u_int) (atoi (sval)); + xlat->pval = calloc (i, sizeof (K_XLAT)); if (xlat->pval != NULL) - memcpy(xlat->pval, pval_tmp, i * sizeof(u_int)); - free(pval_tmp); + memcpy (xlat->pval, pval_tmp, i * sizeof (u_int)); + free (pval_tmp); pStateNow->num_xlat++; } @@ -302,7 +302,7 @@ kstate_add_xlat(char *str) * Ascii only for this implementation */ void -kstate_add_switcher(char *str) +kstate_add_switcher (char *str) { K_SWITCH *switcher; @@ -315,7 +315,7 @@ kstate_add_switcher(char *str) { case 'A': /* ascii eg: A;:2 */ switcher->code = str[1]; - switcher->nextstate = atoi(&str[3]); + switcher->nextstate = atoi (&str[3]); break; } switcher->on = 0; @@ -324,13 +324,13 @@ kstate_add_switcher(char *str) /* L1 or L0 */ void -kstate_set_life(char *str) +kstate_set_life (char *str) { - pStateNow->life = atoi(&str[1]); + pStateNow->life = atoi (&str[1]); } unsigned int -kstate_cxlat(unsigned int c) +kstate_cxlat (unsigned int c) { int i; @@ -339,7 +339,7 @@ kstate_cxlat(unsigned int c) if (pStateNow->switcher[i].type == 'A' && /* only ascii here */ c == pStateNow->switcher[i].code) { - kstate_setcurr(pStateNow->switcher[i].nextstate); + kstate_setcurr (pStateNow->switcher[i].nextstate); pStateNow->switcher[i].on = 1; return ((unsigned int)-1); } @@ -352,37 +352,37 @@ kstate_cxlat(unsigned int c) } /* switch back to previous state if life of current is 1 */ if (pStateNow->life == 1) - kstate_setcurr(pStateNow->prev_state); + kstate_setcurr (pStateNow->prev_state); return (c); } #ifdef RXVT void -greek_init(void) +greek_init (void) { - kstate_init_all(GreekMode); + kstate_init_all (GreekMode); } void -greek_end(void) +greek_end (void) { - kstate_end_all(); + kstate_end_all (); } void -greek_reset(void) +greek_reset (void) { - kstate_reset(); + kstate_reset (); } void -greek_setmode(int greek_mode) +greek_setmode (int greek_mode) { GreekMode = greek_mode; } int -greek_getmode(void) +greek_getmode (void) { return (GreekMode); } @@ -391,14 +391,14 @@ greek_getmode(void) * xlate a given string in-place - return new string length */ int -greek_xlat(char *s, int num_chars) +greek_xlat (char *s, int num_chars) { int i, count; unsigned int c; for (i = 0, count = 0; i < num_chars; i++) { - c = kstate_cxlat((unsigned int)s[i]); + c = kstate_cxlat ((unsigned int)s[i]); if (c != -1) s[count++] = (char)c; } @@ -409,16 +409,16 @@ greek_xlat(char *s, int num_chars) #ifdef TEST int -main(void) +main (void) { /*char text[] = "abcdef;aGDZXC"; */ char text[] = "abcdef;a:ibgdezhuiklmnjoprstyfxcv"; - kstate_init_all(GREEK_ELOT928); - printf("text: %s\n", text); - greek_xlat(text, strlen(text)); - printf("xlat'ed text: %s\n", text); - kstate_end_all(); + kstate_init_all (GREEK_ELOT928); + printf ("text: %s\n", text); + greek_xlat (text, strlen (text)); + printf ("xlat'ed text: %s\n", text); + kstate_end_all (); return 0; } #endif diff --git a/src/grkelot.h b/src/grkelot.h index 0c1d6670..a20e0f48 100644 --- a/src/grkelot.h +++ b/src/grkelot.h @@ -33,8 +33,8 @@ extern "C" { extern void greek_init (void); extern void greek_end (void); extern void greek_reset (void); - extern void greek_setmode(int greek_mode); - extern int greek_getmode(void); + extern void greek_setmode (int greek_mode); + extern int greek_getmode (void); extern int greek_xlat (char *s, int num_chars); #ifdef __cplusplus } diff --git a/src/init.C b/src/init.C index fcbc161c..e7b68c47 100644 --- a/src/init.C +++ b/src/init.C @@ -425,8 +425,8 @@ rxvt_term::init_vars () #ifdef MENUBAR menu_readonly = 1; -# if !(MENUBAR_MAX > 1) - CurrentBar = &(BarList); +# if ! (MENUBAR_MAX > 1) + CurrentBar = & (BarList); # endif /* (MENUBAR_MAX > 1) */ #endif @@ -477,7 +477,7 @@ rxvt_term::init_secondary () if (i == 4 || i == 7) continue; #endif - close(i); + close (i); } #endif } @@ -494,10 +494,10 @@ rxvt_term::init_resources (int argc, const char *const *argv) * Look for -exec option. Find => split and make cmd_argv[] of command args */ for (r_argc = 0; r_argc < argc; r_argc++) - if (!STRCMP (argv[r_argc], "-e") || !STRCMP(argv[r_argc], "-exec")) + if (!STRCMP (argv[r_argc], "-e") || !STRCMP (argv[r_argc], "-exec")) break; - r_argv = (const char **)rxvt_malloc (sizeof(char *) * (r_argc + 1)); + r_argv = (const char **)rxvt_malloc (sizeof (char *) * (r_argc + 1)); for (i = 0; i < r_argc; i++) r_argv[i] = (const char *)argv[i]; @@ -508,7 +508,7 @@ rxvt_term::init_resources (int argc, const char *const *argv) cmd_argv = NULL; else { - cmd_argv = (const char **)rxvt_malloc (sizeof(char *) * (argc - r_argc)); + cmd_argv = (const char **)rxvt_malloc (sizeof (char *) * (argc - r_argc)); for (i = 0; i < argc - r_argc - 1; i++) cmd_argv[i] = (const char *)argv[i + r_argc + 1]; @@ -520,7 +520,7 @@ rxvt_term::init_resources (int argc, const char *const *argv) for (i = 0; i < NUM_RESOURCES;) rs[i++] = NULL; - rs[Rs_name] = rxvt_r_basename(argv[0]); + rs[Rs_name] = rxvt_r_basename (argv[0]); /* * Open display, get options/resources and create the window @@ -543,7 +543,7 @@ rxvt_term::init_resources (int argc, const char *const *argv) #endif if (!display - && !(display = displays.get (rs[Rs_display_name]))) + && ! (display = displays.get (rs[Rs_display_name]))) { rxvt_print_error ("can't open display %s", rs[Rs_display_name]); exit (EXIT_FAILURE); @@ -557,7 +557,7 @@ rxvt_term::init_resources (int argc, const char *const *argv) if (cmd_argv && cmd_argv[0]) { if (!rs[Rs_title]) - rs[Rs_title] = rxvt_r_basename(cmd_argv[0]); + rs[Rs_title] = rxvt_r_basename (cmd_argv[0]); if (!rs[Rs_iconName]) rs[Rs_iconName] = rs[Rs_title]; } @@ -569,23 +569,23 @@ rxvt_term::init_resources (int argc, const char *const *argv) rs[Rs_iconName] = rs[Rs_name]; } - if (rs[Rs_saveLines] && (i = atoi(rs[Rs_saveLines])) >= 0) - TermWin.saveLines = BOUND_POSITIVE_INT16(i); + if (rs[Rs_saveLines] && (i = atoi (rs[Rs_saveLines])) >= 0) + TermWin.saveLines = BOUND_POSITIVE_INT16 (i); #ifndef NO_FRILLS - if (rs[Rs_int_bwidth] && (i = atoi(rs[Rs_int_bwidth])) >= 0) - TermWin.int_bwidth = min(i, 100); /* arbitrary limit */ - if (rs[Rs_ext_bwidth] && (i = atoi(rs[Rs_ext_bwidth])) >= 0) - TermWin.ext_bwidth = min(i, 100); /* arbitrary limit */ + if (rs[Rs_int_bwidth] && (i = atoi (rs[Rs_int_bwidth])) >= 0) + TermWin.int_bwidth = min (i, 100); /* arbitrary limit */ + if (rs[Rs_ext_bwidth] && (i = atoi (rs[Rs_ext_bwidth])) >= 0) + TermWin.ext_bwidth = min (i, 100); /* arbitrary limit */ #endif #ifndef NO_LINESPACE - if (rs[Rs_lineSpace] && (i = atoi(rs[Rs_lineSpace])) >= 0) - TermWin.lineSpace = min(i, 100); /* arbitrary limit */ + if (rs[Rs_lineSpace] && (i = atoi (rs[Rs_lineSpace])) >= 0) + TermWin.lineSpace = min (i, 100); /* arbitrary limit */ #endif #ifdef POINTER_BLANK - if (rs[Rs_pointerBlankDelay] && (i = atoi(rs[Rs_pointerBlankDelay])) >= 0) + if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0) pointerBlankDelay = i; else pointerBlankDelay = 2; @@ -606,9 +606,9 @@ rxvt_term::init_resources (int argc, const char *const *argv) #ifdef ACS_ASCII if (!rs[Rs_acs_chars]) rs[Rs_acs_chars] = ACS_CHARS; - if ((i = STRLEN(rs[Rs_acs_chars])) < 0x20) + if ((i = STRLEN (rs[Rs_acs_chars])) < 0x20) { - val = rxvt_realloc((void *)rs[Rs_acs_chars], 0x20); + val = rxvt_realloc ((void *)rs[Rs_acs_chars], 0x20); for (; i < 0x20; ) val[i] = ' '; rs[Rs_acs_chars] = val; @@ -624,9 +624,9 @@ rxvt_term::init_resources (int argc, const char *const *argv) # endif else { - val = STRDUP(rs[Rs_backspace_key]); - rxvt_Str_trim(val); - rxvt_Str_escaped(val); + val = STRDUP (rs[Rs_backspace_key]); + rxvt_Str_trim (val); + rxvt_Str_escaped (val); key_backspace = val; } #endif @@ -640,25 +640,25 @@ rxvt_term::init_resources (int argc, const char *const *argv) # endif else { - val = STRDUP(rs[Rs_delete_key]); - rxvt_Str_trim(val); - rxvt_Str_escaped(val); + val = STRDUP (rs[Rs_delete_key]); + rxvt_Str_trim (val); + rxvt_Str_escaped (val); key_delete = val; } #endif if (rs[Rs_answerbackstring]) { - rxvt_Str_trim((char *)rs[Rs_answerbackstring]); - rxvt_Str_escaped((char *)rs[Rs_answerbackstring]); + rxvt_Str_trim ((char *)rs[Rs_answerbackstring]); + rxvt_Str_escaped ((char *)rs[Rs_answerbackstring]); } if (rs[Rs_selectstyle]) { - if (STRNCASECMP(rs[Rs_selectstyle], "oldword", 7) == 0) + if (STRNCASECMP (rs[Rs_selectstyle], "oldword", 7) == 0) selection_style = OLD_WORD_SELECT; #ifndef NO_OLD_SELECTION - else if (STRNCASECMP(rs[Rs_selectstyle], "old", 3) == 0) + else if (STRNCASECMP (rs[Rs_selectstyle], "old", 3) == 0) selection_style = OLD_SELECT; #endif @@ -693,7 +693,7 @@ rxvt_term::init_resources (int argc, const char *const *argv) #ifndef XTERM_REVERSE_VIDEO /* this is how we implement reverseVideo */ if (Options & Opt_reverseVideo) - SWAP_IT(rs[Rs_color + Color_fg], rs[Rs_color + Color_bg], const char *); + SWAP_IT (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg], const char *); #endif /* convenient aliases for setting fg/bg to colors */ @@ -726,7 +726,7 @@ rxvt_term::init_env () /* Fixup display_name for export over pty to any interested terminal * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number * (for the first non-loopback interface) that we get from - * rxvt_network_display(). This is more "name-resolution-portable", if you + * rxvt_network_display (). This is more "name-resolution-portable", if you * will, and probably allows for faster x-client startup if your name * server is beyond a slow link or overloaded at client startup. Of * course that only helps the shell's child processes, not us. @@ -738,22 +738,22 @@ rxvt_term::init_env () if (val == NULL) #endif /* DISPLAY_IS_IP */ - val = XDisplayString(display->display); + val = XDisplayString (display->display); if (rs[Rs_display_name] == NULL) rs[Rs_display_name] = val; /* use broken `:0' value */ i = STRLEN (val); - env_display = (char *)rxvt_malloc ((i + 9) * sizeof(char)); + env_display = (char *)rxvt_malloc ((i + 9) * sizeof (char)); sprintf (env_display, "DISPLAY=%s", val); /* avoiding the math library: - * i = (int)(ceil(log10((unsigned int)TermWin.parent[0]))) */ + * i = (int) (ceil (log10 ((unsigned int)TermWin.parent[0]))) */ for (i = 0, u = (unsigned int)TermWin.parent[0]; u; u /= 10, i++) ; - MAX_IT(i, 1); - env_windowid = (char *)rxvt_malloc ((i + 10) * sizeof(char)); + MAX_IT (i, 1); + env_windowid = (char *)rxvt_malloc ((i + 10) * sizeof (char)); sprintf (env_windowid, "WINDOWID=%u", (unsigned int)TermWin.parent[0]); @@ -779,7 +779,7 @@ rxvt_term::init_env () if (rs[Rs_term_name] != NULL) { - env_term = (char *)rxvt_malloc ((STRLEN(rs[Rs_term_name]) + 6) * sizeof(char)); + env_term = (char *)rxvt_malloc ((STRLEN (rs[Rs_term_name]) + 6) * sizeof (char)); sprintf (env_term, "TERM=%s", rs[Rs_term_name]); putenv (env_term); } @@ -829,7 +829,7 @@ rxvt_term::init_xlocale () wmlocale = XInternAtom (display->display, "WM_LOCALE_NAME", False); XChangeProperty (display->display, TermWin.parent[0], wmlocale, XA_STRING, 8, PropModeReplace, - (unsigned char *)locale, STRLEN(locale)); + (unsigned char *)locale, STRLEN (locale)); if (!XSupportsLocale ()) { @@ -847,7 +847,7 @@ rxvt_term::init_xlocale () /*----------------------------------------------------------------------*/ void -rxvt_term::init_command(const char *const *argv) +rxvt_term::init_command (const char *const *argv) { /* * Initialize the command connection. @@ -856,11 +856,11 @@ rxvt_term::init_command(const char *const *argv) int i; for (i = 0; i < NUM_XA; i++) - xa[i] = XInternAtom(display->display, xa_names[i], False); + xa[i] = XInternAtom (display->display, xa_names[i], False); /* Enable delete window protocol */ XSetWMProtocols (display->display, TermWin.parent[0], - &(xa[XA_WMDELETEWINDOW]), 1); + & (xa[XA_WMDELETEWINDOW]), 1); #ifdef USING_W11LIB /* enable W11 callbacks */ @@ -873,15 +873,15 @@ rxvt_term::init_command(const char *const *argv) get_ourmods (); - if (!(Options & Opt_scrollTtyOutput)) + if (! (Options & Opt_scrollTtyOutput)) PrivateModes |= PrivMode_TtyOutputInh; if (Options & Opt_scrollTtyKeypress) PrivateModes |= PrivMode_Keypress; - if (!(Options & Opt_jumpScroll)) + if (! (Options & Opt_jumpScroll)) PrivateModes |= PrivMode_smoothScroll; #ifndef NO_BACKSPACE_KEY - if (STRCMP(key_backspace, "DEC") == 0) + if (STRCMP (key_backspace, "DEC") == 0) PrivateModes |= PrivMode_HaveBackSpace; #endif @@ -898,7 +898,7 @@ rxvt_term::init_command(const char *const *argv) } #ifdef GREEK_SUPPORT - greek_init(); + greek_init (); #endif #ifdef CURSOR_BLINK @@ -997,7 +997,7 @@ rxvt_term::Get_Colours () xcol[1] = PixColors[Color_scroll]; # ifdef PREFER_24BIT xcol[0].set (display, 65535, 65535, 65535); - /* XFreeColors(display->display, XCMAP, &(xcol[0].pixel), 1, ~0); */ + /* XFreeColors (display->display, XCMAP, & (xcol[0].pixel), 1, ~0); */ # else xcol[0].set (display, WhitePixel (display->display, display->screen)); # endif @@ -1028,9 +1028,9 @@ rxvt_term::Get_Colours () /*----------------------------------------------------------------------*/ /* color aliases, fg/bg bright-bold */ void -rxvt_term::color_aliases(int idx) +rxvt_term::color_aliases (int idx) { - if (rs[Rs_color + idx] && isdigit (*(rs[Rs_color + idx]))) + if (rs[Rs_color + idx] && isdigit (* (rs[Rs_color + idx]))) { int i = atoi (rs[Rs_color + idx]); @@ -1070,10 +1070,10 @@ rxvt_term::get_ourmods () requestedmeta = realmeta = realalt = 0; rsmod = rs[Rs_modifier]; if (rsmod - && STRCASECMP(rsmod, "mod1") >= 0 && STRCASECMP(rsmod, "mod5") <= 0) + && STRCASECMP (rsmod, "mod1") >= 0 && STRCASECMP (rsmod, "mod5") <= 0) requestedmeta = rsmod[3] - '0'; - map = XGetModifierMapping(display->display); + map = XGetModifierMapping (display->display); kc = map->modifiermap; for (i = 1; i < 6; i++) { @@ -1082,13 +1082,13 @@ rxvt_term::get_ourmods () { if (kc[k] == 0) break; - switch (XKeycodeToKeysym(display->display, kc[k], 0)) + switch (XKeycodeToKeysym (display->display, kc[k], 0)) { case XK_Num_Lock: ModNumLockMask = modmasks[i - 1]; /* FALLTHROUGH */ default: - continue; /* for(;;) */ + continue; /* for (;;) */ case XK_Meta_L: case XK_Meta_R: cm = "meta"; @@ -1108,11 +1108,11 @@ rxvt_term::get_ourmods () cm = "hyper"; break; } - if (rsmod && STRNCASECMP(rsmod, cm, STRLEN(cm)) == 0) + if (rsmod && STRNCASECMP (rsmod, cm, STRLEN (cm)) == 0) requestedmeta = i; } } - XFreeModifiermap(map); + XFreeModifiermap (map); i = (requestedmeta ? requestedmeta : (realmeta ? realmeta : (realalt ? realalt : 0))); @@ -1121,7 +1121,7 @@ rxvt_term::get_ourmods () } /*----------------------------------------------------------------------*/ -/* rxvt_Create_Windows() - Open and map the window */ +/* rxvt_Create_Windows () - Open and map the window */ void rxvt_term::create_windows (int argc, const char *const *argv) { @@ -1134,7 +1134,7 @@ rxvt_term::create_windows (int argc, const char *const *argv) if (Options & Opt_transparent) { - XGetWindowAttributes (display->display, RootWindow(display->display, display->screen), &gattr); + XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr); display->depth = gattr.depth; // doh //TODO, per-term not per-display? } @@ -1147,7 +1147,7 @@ rxvt_term::create_windows (int argc, const char *const *argv) old_height = szHint.height; /* parent window - reverse video so we can see placement errors - * sub-window placement & size in rxvt_resize_subwindows() + * sub-window placement & size in rxvt_resize_subwindows () */ #ifdef PREFER_24BIT @@ -1185,10 +1185,10 @@ rxvt_term::create_windows (int argc, const char *const *argv) : NormalState); wmHint.window_group = TermWin.parent[0]; - XSetWMProperties(display->display, TermWin.parent[0], NULL, NULL, + XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL, (char **)argv, argc, &szHint, &wmHint, &classHint); - XSelectInput(display->display, TermWin.parent[0], + XSelectInput (display->display, TermWin.parent[0], KeyPressMask #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) | KeyReleaseMask @@ -1198,11 +1198,11 @@ rxvt_term::create_windows (int argc, const char *const *argv) termwin_ev.start (display, TermWin.parent[0]); /* vt cursor: Black-on-White is standard, but this is more popular */ - TermWin_cursor = XCreateFontCursor(display->display, XC_xterm); + TermWin_cursor = XCreateFontCursor (display->display, XC_xterm); #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) /* cursor (menuBar/scrollBar): Black-on-White */ - leftptr_cursor = XCreateFontCursor(display->display, XC_left_ptr); + leftptr_cursor = XCreateFontCursor (display->display, XC_left_ptr); #endif #ifdef POINTER_BLANK @@ -1219,16 +1219,16 @@ rxvt_term::create_windows (int argc, const char *const *argv) #endif /* the vt window */ - TermWin.vt = XCreateSimpleWindow(display->display, TermWin.parent[0], + TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0], window_vt_x, window_vt_y, - TermWin_TotalWidth(), - TermWin_TotalHeight(), + TermWin_TotalWidth (), + TermWin_TotalHeight (), 0, PixColors[Color_fg], PixColors[Color_bg]); #ifdef DEBUG_X - XStoreName(display->display, TermWin.vt, "vt window"); + XStoreName (display->display, TermWin.vt, "vt window"); #endif vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask @@ -1243,26 +1243,26 @@ rxvt_term::create_windows (int argc, const char *const *argv) #endif vt_emask |= (Button1MotionMask | Button3MotionMask); - XSelectInput(display->display, TermWin.vt, vt_emask); + XSelectInput (display->display, TermWin.vt, vt_emask); vt_ev.start (display, TermWin.vt); #if defined(MENUBAR) && (MENUBAR_MAX > 1) - if (menuBar_height()) + if (menuBar_height ()) { - menuBar.win = XCreateSimpleWindow(display->display, TermWin.parent[0], + menuBar.win = XCreateSimpleWindow (display->display, TermWin.parent[0], window_vt_x, 0, - TermWin_TotalWidth(), - menuBar_TotalHeight(), + TermWin_TotalWidth (), + menuBar_TotalHeight (), 0, PixColors[Color_fg], PixColors[Color_scroll]); #ifdef DEBUG_X - XStoreName(display->display, menuBar.win, "menubar"); + XStoreName (display->display, menuBar.win, "menubar"); #endif - XDefineCursor(display->display, menuBar.win, pointer_leftptr); + XDefineCursor (display->display, menuBar.win, pointer_leftptr); - XSelectInput(display->display, menuBar.win, + XSelectInput (display->display, menuBar.win, (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask)); menubar_ev.start (display, menuBar.win); @@ -1271,11 +1271,11 @@ rxvt_term::create_windows (int argc, const char *const *argv) #ifdef XPM_BACKGROUND if (rs[Rs_backgroundPixmap] != NULL - && !(Options & Opt_transparent)) + && ! (Options & Opt_transparent)) { const char *p = rs[Rs_backgroundPixmap]; - if ((p = STRCHR(p, ';')) != NULL) + if ((p = STRCHR (p, ';')) != NULL) { p++; scale_pixmap (p); @@ -1289,20 +1289,20 @@ rxvt_term::create_windows (int argc, const char *const *argv) gcvalue.foreground = PixColors[Color_fg]; gcvalue.background = PixColors[Color_bg]; gcvalue.graphics_exposures = 1; - TermWin.gc = XCreateGC(display->display, TermWin.vt, + TermWin.gc = XCreateGC (display->display, TermWin.vt, GCForeground | GCBackground | GCGraphicsExposures, &gcvalue); #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) gcvalue.foreground = PixColors[Color_topShadow]; - topShadowGC = XCreateGC(display->display, TermWin.vt, + topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); gcvalue.foreground = PixColors[Color_bottomShadow]; - botShadowGC = XCreateGC(display->display, TermWin.vt, + botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); - gcvalue.foreground = PixColors[(XDEPTH <= 2 ? Color_fg + gcvalue.foreground = PixColors[ (XDEPTH <= 2 ? Color_fg : Color_scroll)]; - scrollbarGC = XCreateGC(display->display, TermWin.vt, + scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); #endif } @@ -1319,9 +1319,9 @@ rxvt_term::run_command (const char *const *argv) int cfd, er; /* get master (pty) */ - if ((cfd = rxvt_get_pty (&(tty_fd), &(ttydev))) < 0) + if ((cfd = rxvt_get_pty (& (tty_fd), & (ttydev))) < 0) { - rxvt_print_error("can't open pseudo-tty"); + rxvt_print_error ("can't open pseudo-tty"); return -1; } @@ -1336,29 +1336,29 @@ rxvt_term::run_command (const char *const *argv) if ((tty_fd = rxvt_get_tty (ttydev)) < 0) { - close(cfd); - rxvt_print_error("can't open slave tty %s", ttydev); + close (cfd); + rxvt_print_error ("can't open slave tty %s", ttydev); return -1; } } #ifndef NO_BACKSPACE_KEY if (key_backspace[0] && !key_backspace[1]) er = key_backspace[0]; - else if (STRCMP(key_backspace, "DEC") == 0) + else if (STRCMP (key_backspace, "DEC") == 0) er = '\177'; /* the initial state anyway */ else #endif er = -1; - rxvt_get_ttymode (&(tio), er); + rxvt_get_ttymode (& (tio), er); #ifndef __QNX__ /* spin off the command interpreter */ switch (cmd_pid = fork ()) { case -1: - rxvt_print_error("can't fork"); + rxvt_print_error ("can't fork"); return -1; case 0: close (cfd); /* only keep tty_fd and STDERR open */ @@ -1402,7 +1402,7 @@ rxvt_term::run_command (const char *const *argv) close (tty_fd); /* keep STDERR_FILENO, cmd_fd, display->fd () open */ break; } -#else /* __QNX__ uses qnxspawn() */ +#else /* __QNX__ uses qnxspawn () */ fchmod (tty_fd, 0622); fcntl (tty_fd, F_SETFD, FD_CLOEXEC); fcntl (cfd, F_SETFD, FD_CLOEXEC); @@ -1426,7 +1426,7 @@ rxvt_term::run_child (const char *const *argv) { char *login; - SET_TTYMODE (STDIN_FILENO, &(tio)); /* init terminal attributes */ + SET_TTYMODE (STDIN_FILENO, & (tio)); /* init terminal attributes */ if (Options & Opt_console) { /* be virtual console, fail silently */ @@ -1482,33 +1482,33 @@ rxvt_term::run_child (const char *const *argv) int i; for (i = 0; argv[i]; i++) - fprintf(stderr, "argv [%d] = \"%s\"\n", i, argv[i]); + fprintf (stderr, "argv [%d] = \"%s\"\n", i, argv[i]); # endif - execvp(argv[0], (char *const *)argv); + execvp (argv[0], (char *const *)argv); /* no error message: STDERR is closed! */ } else { const char *argv0, *shell; - if ((shell = getenv("SHELL")) == NULL || *shell == '\0') + if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') shell = "/bin/sh"; - argv0 = (const char *)rxvt_r_basename(shell); + argv0 = (const char *)rxvt_r_basename (shell); if (Options & Opt_loginShell) { - login = (char *)rxvt_malloc((STRLEN(argv0) + 2) * sizeof(char)); + login = (char *)rxvt_malloc ((STRLEN (argv0) + 2) * sizeof (char)); login[0] = '-'; - STRCPY(&login[1], argv0); + STRCPY (&login[1], argv0); argv0 = login; } - execlp(shell, argv0, NULL); + execlp (shell, argv0, NULL); /* no error message: STDERR is closed! */ } -#else /* __QNX__ uses qnxspawn() */ +#else /* __QNX__ uses qnxspawn () */ char iov_a[10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; char *command = NULL, fullcommand[_MAX_PATH]; @@ -1516,15 +1516,15 @@ rxvt_term::run_child (const char *const *argv) if (argv != NULL) { - if (access(argv[0], X_OK) == -1) + if (access (argv[0], X_OK) == -1) { - if (STRCHR(argv[0], '/') == NULL) + if (STRCHR (argv[0], '/') == NULL) { - searchenv(argv[0], "PATH", fullcommand); + searchenv (argv[0], "PATH", fullcommand); if (fullcommand[0] != '\0') command = fullcommand; } - if (access(command, X_OK) == -1) + if (access (command, X_OK) == -1) return -1; } else @@ -1533,28 +1533,28 @@ rxvt_term::run_child (const char *const *argv) } else { - if ((command = getenv("SHELL")) == NULL || *command == '\0') + if ((command = getenv ("SHELL")) == NULL || *command == '\0') command = "/bin/sh"; - arg_a[0] = my_basename(command); + arg_a[0] = my_basename (command); if (Options & Opt_loginShell) { - login = rxvt_malloc((STRLEN(arg_a[0]) + 2) * sizeof(char)); + login = rxvt_malloc ((STRLEN (arg_a[0]) + 2) * sizeof (char)); login[0] = '-'; - STRCPY(&login[1], arg_a[0]); + STRCPY (&login[1], arg_a[0]); arg_a[0] = login; } arg_v = arg_a; } iov_a[0] = iov_a[1] = iov_a[2] = tty_fd; - cmd_pid = qnx_spawn(0, 0, 0, -1, -1, + cmd_pid = qnx_spawn (0, 0, 0, -1, -1, _SPAWN_SETSID | _SPAWN_TCSETPGRP, command, arg_v, environ, iov_a, 0); if (login) - free(login); + free (login); - close(tty_fd); + close (tty_fd); return cmd_fd; #endif @@ -1564,16 +1564,16 @@ rxvt_term::run_child (const char *const *argv) /* ------------------------------------------------------------------------- * * GET TTY CURRENT STATE * * ------------------------------------------------------------------------- */ -/* rxvt_get_ttymode() */ +/* rxvt_get_ttymode () */ /* EXTPROTO */ void -rxvt_get_ttymode(ttymode_t *tio, int erase) +rxvt_get_ttymode (ttymode_t *tio, int erase) { #ifdef HAVE_TERMIOS_H /* * standard System V termios interface */ - if (GET_TERMIOS(STDIN_FILENO, tio) < 0) + if (GET_TERMIOS (STDIN_FILENO, tio) < 0) { /* return error - use system defaults */ tio->c_cc[VINTR] = CINTR; @@ -1657,7 +1657,7 @@ rxvt_get_ttymode(ttymode_t *tio, int erase) */ /* get parameters -- gtty */ - if (ioctl(STDIN_FILENO, TIOCGETP, &(tio->sg)) < 0) + if (ioctl (STDIN_FILENO, TIOCGETP, & (tio->sg)) < 0) { tio->sg.sg_erase = CERASE; /* ^H */ tio->sg.sg_kill = CKILL; /* ^U */ @@ -1668,7 +1668,7 @@ rxvt_get_ttymode(ttymode_t *tio, int erase) tio->sg.sg_flags = (CRMOD | ECHO | EVENP | ODDP); /* get special characters */ - if (ioctl(STDIN_FILENO, TIOCGETC, &(tio->tc)) < 0) + if (ioctl (STDIN_FILENO, TIOCGETC, & (tio->tc)) < 0) { tio->tc.t_intrc = CINTR; /* ^C */ tio->tc.t_quitc = CQUIT; /* ^\ */ @@ -1678,7 +1678,7 @@ rxvt_get_ttymode(ttymode_t *tio, int erase) tio->tc.t_brkc = -1; } /* get local special chars */ - if (ioctl(STDIN_FILENO, TIOCGLTC, &(tio->lc)) < 0) + if (ioctl (STDIN_FILENO, TIOCGLTC, & (tio->lc)) < 0) { tio->lc.t_suspc = CSUSP; /* ^Z */ tio->lc.t_dsuspc = CDSUSP; /* ^Y */ @@ -1688,7 +1688,7 @@ rxvt_get_ttymode(ttymode_t *tio, int erase) tio->lc.t_lnextc = CLNEXT; /* ^V */ } /* get line discipline */ - ioctl(STDIN_FILENO, TIOCGETD, &(tio->line)); + ioctl (STDIN_FILENO, TIOCGETD, & (tio->line)); # ifdef NTTYDISC tio->line = NTTYDISC; @@ -1703,7 +1703,7 @@ rxvt_get_ttymode(ttymode_t *tio, int erase) #ifdef DEBUG_TTYMODE #ifdef HAVE_TERMIOS_H /* c_iflag bits */ - fprintf(stderr, "Input flags\n"); + fprintf (stderr, "Input flags\n"); /* cpp token stringize doesn't work on all machines */ # define FOO(flag,name) \ @@ -1711,80 +1711,80 @@ rxvt_get_ttymode(ttymode_t *tio, int erase) fprintf (stderr, "%s ", name) /* c_iflag bits */ - FOO(IGNBRK, "IGNBRK"); - FOO(BRKINT, "BRKINT"); - FOO(IGNPAR, "IGNPAR"); - FOO(PARMRK, "PARMRK"); - FOO(INPCK, "INPCK"); - FOO(ISTRIP, "ISTRIP"); - FOO(INLCR, "INLCR"); - FOO(IGNCR, "IGNCR"); - FOO(ICRNL, "ICRNL"); - FOO(IXON, "IXON"); - FOO(IXOFF, "IXOFF"); + FOO (IGNBRK, "IGNBRK"); + FOO (BRKINT, "BRKINT"); + FOO (IGNPAR, "IGNPAR"); + FOO (PARMRK, "PARMRK"); + FOO (INPCK, "INPCK"); + FOO (ISTRIP, "ISTRIP"); + FOO (INLCR, "INLCR"); + FOO (IGNCR, "IGNCR"); + FOO (ICRNL, "ICRNL"); + FOO (IXON, "IXON"); + FOO (IXOFF, "IXOFF"); # ifdef IUCLC - FOO(IUCLC, "IUCLC"); + FOO (IUCLC, "IUCLC"); # endif # ifdef IXANY - FOO(IXANY, "IXANY"); + FOO (IXANY, "IXANY"); # endif # ifdef IMAXBEL - FOO(IMAXBEL, "IMAXBEL"); + FOO (IMAXBEL, "IMAXBEL"); # endif - fprintf(stderr, "\n"); + fprintf (stderr, "\n"); # undef FOO # define FOO(entry, name) \ - fprintf(stderr, "%-8s = %#04o\n", name, tio->c_cc [entry]) - - FOO(VINTR, "VINTR"); - FOO(VQUIT, "VQUIT"); - FOO(VERASE, "VERASE"); - FOO(VKILL, "VKILL"); - FOO(VEOF, "VEOF"); - FOO(VEOL, "VEOL"); + fprintf (stderr, "%-8s = %#04o\n", name, tio->c_cc [entry]) + + FOO (VINTR, "VINTR"); + FOO (VQUIT, "VQUIT"); + FOO (VERASE, "VERASE"); + FOO (VKILL, "VKILL"); + FOO (VEOF, "VEOF"); + FOO (VEOL, "VEOL"); # ifdef VEOL2 - FOO(VEOL2, "VEOL2"); + FOO (VEOL2, "VEOL2"); # endif # ifdef VSWTC - FOO(VSWTC, "VSWTC"); + FOO (VSWTC, "VSWTC"); # endif # ifdef VSWTCH - FOO(VSWTCH, "VSWTCH"); + FOO (VSWTCH, "VSWTCH"); # endif - FOO(VSTART, "VSTART"); - FOO(VSTOP, "VSTOP"); - FOO(VSUSP, "VSUSP"); + FOO (VSTART, "VSTART"); + FOO (VSTOP, "VSTOP"); + FOO (VSUSP, "VSUSP"); # ifdef VDSUSP - FOO(VDSUSP, "VDSUSP"); + FOO (VDSUSP, "VDSUSP"); # endif # ifdef VREPRINT - FOO(VREPRINT, "VREPRINT"); + FOO (VREPRINT, "VREPRINT"); # endif # ifdef VDISCRD - FOO(VDISCRD, "VDISCRD"); + FOO (VDISCRD, "VDISCRD"); # endif # ifdef VWERSE - FOO(VWERSE, "VWERSE"); + FOO (VWERSE, "VWERSE"); # endif # ifdef VLNEXT - FOO(VLNEXT, "VLNEXT"); + FOO (VLNEXT, "VLNEXT"); # endif - fprintf(stderr, "\n"); + fprintf (stderr, "\n"); # undef FOO # endif /* HAVE_TERMIOS_H */ #endif /* DEBUG_TTYMODE */ diff --git a/src/init.h b/src/init.h index e72ac224..7d5b63cd 100644 --- a/src/init.h +++ b/src/init.h @@ -55,11 +55,11 @@ # define SET_TTYMODE(fd,tt) \ tt->sg.sg_ispeed = tt->sg.sg_ospeed = BAUDRATE, \ - ioctl (fd, TIOCSETP, &(tt->sg)), \ - ioctl (fd, TIOCSETC, &(tt->tc)), \ - ioctl (fd, TIOCSLTC, &(tt->lc)), \ - ioctl (fd, TIOCSETD, &(tt->line)), \ - ioctl (fd, TIOCLSET, &(tt->local)) + ioctl (fd, TIOCSETP, & (tt->sg)), \ + ioctl (fd, TIOCSETC, & (tt->tc)), \ + ioctl (fd, TIOCSLTC, & (tt->lc)), \ + ioctl (fd, TIOCSETD, & (tt->line)), \ + ioctl (fd, TIOCLSET, & (tt->local)) #endif /* HAVE_TERMIOS_H */ /* use the fastest baud-rate */ diff --git a/src/iom.C b/src/iom.C index dd925c2a..c6cee009 100644 --- a/src/iom.C +++ b/src/iom.C @@ -23,7 +23,7 @@ #include -#if 1 // older unices need these includes for select(2) +#if 1 // older unices need these includes for select (2) # include # include #endif @@ -51,7 +51,7 @@ static struct tw0 : time_watcher abort (); } - tw0() + tw0 () : time_watcher (this, &tw0::cb) { }} tw0; @@ -168,7 +168,7 @@ void io_manager::loop () { double diff = next->at - NOW; tval.tv_sec = (int)diff; - tval.tv_usec = (int)((diff - tval.tv_sec) * 1000000); + tval.tv_usec = (int) ((diff - tval.tv_sec) * 1000000); to = &tval; } break; diff --git a/src/iom.h b/src/iom.h index 70a5837d..0ae3e25d 100644 --- a/src/iom.h +++ b/src/iom.h @@ -121,7 +121,7 @@ extern io_manager iom; // a singleton, together with it's construction/destructi struct watcher { int active; /* 0 == inactive, else index into respective vector */ - watcher() : active(0) { } + watcher () : active (0) { } }; #if IOM_IO @@ -139,8 +139,8 @@ struct io_watcher : watcher, callback2 { void stop () { iom.unreg (this); } template - io_watcher (O1 *object, void (O2::*method)(io_watcher &, short)) - : callback2(object,method) + io_watcher (O1 *object, void (O2::*method) (io_watcher &, short)) + : callback2 (object,method) { } ~io_watcher () { stop (); } }; @@ -153,14 +153,14 @@ struct time_watcher : watcher, callback1 { void trigger (); void set (tstamp when) { at = when; } - void operator ()() { trigger (); } + void operator () () { trigger (); } void start () { iom.reg (this); } void start (tstamp when) { set (when); iom.reg (this); } void stop () { iom.unreg (this); } template - time_watcher (O1 *object, void (O2::*method)(time_watcher &)) - : callback1(object,method), at(0) + time_watcher (O1 *object, void (O2::*method) (time_watcher &)) + : callback1 (object,method), at (0) { } ~time_watcher () { stop (); } }; @@ -173,8 +173,8 @@ struct check_watcher : watcher, callback1 { void stop () { iom.unreg (this); } template - check_watcher (O1 *object, void (O2::*method)(check_watcher &)) - : callback1(object,method) + check_watcher (O1 *object, void (O2::*method) (check_watcher &)) + : callback1 (object,method) { } ~check_watcher () { stop (); } }; @@ -187,8 +187,8 @@ struct idle_watcher : watcher, callback1 { void stop () { iom.unreg (this); } template - idle_watcher (O1 *object, void (O2::*method)(idle_watcher &)) - : callback1(object,method) + idle_watcher (O1 *object, void (O2::*method) (idle_watcher &)) + : callback1 (object,method) { } ~idle_watcher () { stop (); } }; diff --git a/src/logging.C b/src/logging.C index 3f4277ce..1e6efa23 100644 --- a/src/logging.C +++ b/src/logging.C @@ -59,102 +59,102 @@ void rxvt_term::makeutent (const char *pty, const char *hostname) { #ifdef HAVE_STRUCT_UTMP - struct utmp *ut = &(this->ut); + struct utmp *ut = & (this->ut); #endif #ifdef HAVE_STRUCT_UTMPX - struct utmpx *utx = &(this->utx); + struct utmpx *utx = & (this->utx); #endif #ifdef HAVE_UTMP_PID int i; #endif char ut_id[5]; - struct passwd *pwent = getpwuid(getuid()); + struct passwd *pwent = getpwuid (getuid ()); - if (!STRNCMP(pty, "/dev/", 5)) + if (!STRNCMP (pty, "/dev/", 5)) pty += 5; /* skip /dev/ prefix */ - if (!STRNCMP(pty, "pty", 3) || !STRNCMP(pty, "tty", 3)) + if (!STRNCMP (pty, "pty", 3) || !STRNCMP (pty, "tty", 3)) { - STRNCPY(ut_id, (pty + 3), sizeof(ut_id)); + STRNCPY (ut_id, (pty + 3), sizeof (ut_id)); } #ifdef HAVE_UTMP_PID - else if (sscanf(pty, "pts/%d", &i) == 1) - sprintf(ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ + else if (sscanf (pty, "pts/%d", &i) == 1) + sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ #endif - else if (STRNCMP(pty, "pty", 3) && STRNCMP(pty, "tty", 3)) + else if (STRNCMP (pty, "pty", 3) && STRNCMP (pty, "tty", 3)) { - rxvt_print_error("can't parse tty name \"%s\"", pty); + rxvt_print_error ("can't parse tty name \"%s\"", pty); return; } #ifdef HAVE_STRUCT_UTMP - MEMSET(ut, 0, sizeof(struct utmp)); + MEMSET (ut, 0, sizeof (struct utmp)); # ifdef HAVE_UTMP_PID - setutent(); - STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id)); + setutent (); + STRNCPY (ut->ut_id, ut_id, sizeof (ut->ut_id)); ut->ut_type = DEAD_PROCESS; - getutid(ut); /* position to entry in utmp file */ - STRNCPY(ut_id, ut_id, sizeof(ut_id)); + getutid (ut); /* position to entry in utmp file */ + STRNCPY (ut_id, ut_id, sizeof (ut_id)); # endif #endif #ifdef HAVE_STRUCT_UTMPX - MEMSET(utx, 0, sizeof(struct utmpx)); - setutxent(); - STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id)); + MEMSET (utx, 0, sizeof (struct utmpx)); + setutxent (); + STRNCPY (utx->ut_id, ut_id, sizeof (utx->ut_id)); utx->ut_type = DEAD_PROCESS; - getutxid(utx); /* position to entry in utmp file */ - STRNCPY(ut_id, ut_id, sizeof(ut_id)); + getutxid (utx); /* position to entry in utmp file */ + STRNCPY (ut_id, ut_id, sizeof (ut_id)); #endif #ifdef HAVE_STRUCT_UTMP - STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line)); - ut->ut_time = time(NULL); + STRNCPY (ut->ut_line, pty, sizeof (ut->ut_line)); + ut->ut_time = time (NULL); # ifdef HAVE_UTMP_PID - STRNCPY(ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", - sizeof(ut->ut_user)); - STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id)); - ut->ut_time = time(NULL); + STRNCPY (ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", + sizeof (ut->ut_user)); + STRNCPY (ut->ut_id, ut_id, sizeof (ut->ut_id)); + ut->ut_time = time (NULL); ut->ut_pid = cmd_pid; # ifdef HAVE_UTMP_HOST - STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host)); + STRNCPY (ut->ut_host, hostname, sizeof (ut->ut_host)); # endif ut->ut_type = USER_PROCESS; - pututline(ut); - endutent(); /* close the file */ + pututline (ut); + endutent (); /* close the file */ utmp_pos = 0; # else - STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?", - sizeof(ut->ut_name)); + STRNCPY (ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?", + sizeof (ut->ut_name)); # ifdef HAVE_UTMP_HOST - STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host)); + STRNCPY (ut->ut_host, hostname, sizeof (ut->ut_host)); # endif # endif #endif #ifdef HAVE_STRUCT_UTMPX - STRNCPY(utx->ut_line, pty, sizeof(utx->ut_line)); - STRNCPY(utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", - sizeof(utx->ut_user)); - STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id)); - utx->ut_session = getsid(0); - utx->ut_tv.tv_sec = time(NULL); + STRNCPY (utx->ut_line, pty, sizeof (utx->ut_line)); + STRNCPY (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", + sizeof (utx->ut_user)); + STRNCPY (utx->ut_id, ut_id, sizeof (utx->ut_id)); + utx->ut_session = getsid (0); + utx->ut_tv.tv_sec = time (NULL); utx->ut_tv.tv_usec = 0; utx->ut_pid = cmd_pid; # ifdef HAVE_UTMPX_HOST - STRNCPY(utx->ut_host, hostname, sizeof(utx->ut_host)); + STRNCPY (utx->ut_host, hostname, sizeof (utx->ut_host)); # if 0 { char *colon; - if ((colon = STRRCHR(ut->ut_host, ':')) != NULL) + if ((colon = STRRCHR (ut->ut_host, ':')) != NULL) *colon = '\0'; } # endif # endif utx->ut_type = USER_PROCESS; - pututxline(utx); - endutxent(); /* close the file */ + pututxline (utx); + endutxent (); /* close the file */ utmp_pos = 0; #endif @@ -163,32 +163,32 @@ rxvt_term::makeutent (const char *pty, const char *hostname) { int i; # ifdef HAVE_TTYSLOT - i = ttyslot(); - if (rxvt_write_bsd_utmp(i, ut)) + i = ttyslot (); + if (rxvt_write_bsd_utmp (i, ut)) utmp_pos = i; # else FILE *fd0; - if ((fd0 = fopen(TTYTAB_FILENAME, "r")) != NULL) + if ((fd0 = fopen (TTYTAB_FILENAME, "r")) != NULL) { char buf[256], name[256]; - buf[sizeof(buf) - 1] = '\0'; - for (i = 1; (fgets(buf, sizeof(buf) - 1, fd0) != NULL);) + buf[sizeof (buf) - 1] = '\0'; + for (i = 1; (fgets (buf, sizeof (buf) - 1, fd0) != NULL);) { - if (*buf == '#' || sscanf(buf, "%s", name) != 1) + if (*buf == '#' || sscanf (buf, "%s", name) != 1) continue; - if (!STRCMP(ut->ut_line, name)) + if (!STRCMP (ut->ut_line, name)) { - if (!rxvt_write_bsd_utmp(i, ut)) + if (!rxvt_write_bsd_utmp (i, ut)) i = 0; utmp_pos = i; - fclose(fd0); + fclose (fd0); break; } i++; } - fclose(fd0); + fclose (fd0); } # endif @@ -202,19 +202,19 @@ rxvt_term::makeutent (const char *pty, const char *hostname) { # ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UPDWTMP - updwtmp(RXVT_WTMP_FILE, ut); + updwtmp (RXVT_WTMP_FILE, ut); # else - rxvt_update_wtmp(RXVT_WTMP_FILE, ut); + rxvt_update_wtmp (RXVT_WTMP_FILE, ut); # endif # endif # ifdef HAVE_STRUCT_UTMPX - updwtmpx(RXVT_WTMPX_FILE, utx); + updwtmpx (RXVT_WTMPX_FILE, utx); # endif } #endif #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) if (Options & Opt_loginShell) - rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname); + rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname); #endif } @@ -226,44 +226,44 @@ void rxvt_term::cleanutent () { #ifdef HAVE_STRUCT_UTMP - struct utmp *ut = &(this->ut); + struct utmp *ut = & (this->ut); #endif #ifdef HAVE_STRUCT_UTMPX - struct utmpx *tmputx, *utx = &(this->utx); + struct utmpx *tmputx, *utx = & (this->utx); #endif #ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UTMP_PID - MEMSET(ut, 0, sizeof(struct utmp)); - setutent(); - STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id)); + MEMSET (ut, 0, sizeof (struct utmp)); + setutent (); + STRNCPY (ut->ut_id, ut_id, sizeof (ut->ut_id)); ut->ut_type = USER_PROCESS; { - struct utmp *tmput = getutid(ut); + struct utmp *tmput = getutid (ut); if (tmput) /* position to entry in utmp file */ ut = tmput; } ut->ut_type = DEAD_PROCESS; # else - MEMSET(ut->ut_name, 0, sizeof(ut->ut_name)); + MEMSET (ut->ut_name, 0, sizeof (ut->ut_name)); # ifdef HAVE_UTMP_HOST - MEMSET(ut->ut_host, 0, sizeof(ut->ut_host)); + MEMSET (ut->ut_host, 0, sizeof (ut->ut_host)); # endif # endif - ut->ut_time = time(NULL); + ut->ut_time = time (NULL); #endif #ifdef HAVE_STRUCT_UTMPX - MEMSET(utx, 0, sizeof(struct utmpx)); - setutxent(); - STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id)); + MEMSET (utx, 0, sizeof (struct utmpx)); + setutxent (); + STRNCPY (utx->ut_id, ut_id, sizeof (utx->ut_id)); utx->ut_type = USER_PROCESS; - if ((tmputx = getutxid(utx))) /* position to entry in utmp file */ + if ((tmputx = getutxid (utx))) /* position to entry in utmp file */ utx = tmputx; utx->ut_type = DEAD_PROCESS; - utx->ut_session = getsid(0); - utx->ut_tv.tv_sec = time(NULL); + utx->ut_session = getsid (0); + utx->ut_tv.tv_sec = time (NULL); utx->ut_tv.tv_usec = 0; #endif @@ -277,13 +277,13 @@ rxvt_term::cleanutent () { # ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UPDWTMP - updwtmp(RXVT_WTMP_FILE, ut); + updwtmp (RXVT_WTMP_FILE, ut); # else - rxvt_update_wtmp(RXVT_WTMP_FILE, ut); + rxvt_update_wtmp (RXVT_WTMP_FILE, ut); # endif # endif # ifdef HAVE_STRUCT_UTMPX - updwtmpx(RXVT_WTMPX_FILE, utx); + updwtmpx (RXVT_WTMPX_FILE, utx); # endif } #endif @@ -294,17 +294,17 @@ rxvt_term::cleanutent () #ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UTMP_PID if (ut->ut_pid == cmd_pid) - pututline(ut); - endutent(); + pututline (ut); + endutent (); # else - MEMSET(ut, 0, sizeof(struct utmp)); - rxvt_write_bsd_utmp(utmp_pos, ut); + MEMSET (ut, 0, sizeof (struct utmp)); + rxvt_write_bsd_utmp (utmp_pos, ut); # endif #endif #ifdef HAVE_STRUCT_UTMPX if (utx->ut_pid == cmd_pid) - pututxline(utx); - endutxent(); + pututxline (utx); + endutxent (); #endif } @@ -315,16 +315,16 @@ rxvt_term::cleanutent () #ifdef HAVE_UTMP_H /* INTPROTO */ int -rxvt_write_bsd_utmp(int utmp_pos, struct utmp *wu) +rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu) { int fd; - if (utmp_pos <= 0 || (fd = open(RXVT_UTMP_FILE, O_WRONLY)) == -1) + if (utmp_pos <= 0 || (fd = open (RXVT_UTMP_FILE, O_WRONLY)) == -1) return 0; - if (lseek(fd, (off_t) (utmp_pos * sizeof(struct utmp)), SEEK_SET) != -1) - write(fd, wu, sizeof(struct utmp)); - close(fd); + if (lseek (fd, (off_t) (utmp_pos * sizeof (struct utmp)), SEEK_SET) != -1) + write (fd, wu, sizeof (struct utmp)); + close (fd); return 1; } #endif @@ -336,13 +336,13 @@ rxvt_write_bsd_utmp(int utmp_pos, struct utmp *wu) #if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) /* INTPROTO */ void -rxvt_update_wtmp(const char *fname, const struct utmp *putmp) +rxvt_update_wtmp (const char *fname, const struct utmp *putmp) { int fd, gotlock, retry; struct flock lck; /* fcntl locking scheme */ struct stat sbuf; - if ((fd = open(fname, O_WRONLY | O_APPEND, 0)) < 0) + if ((fd = open (fname, O_WRONLY | O_APPEND, 0)) < 0) return; lck.l_whence = SEEK_END; /* start lock at current eof */ @@ -352,7 +352,7 @@ rxvt_update_wtmp(const char *fname, const struct utmp *putmp) /* attempt lock with F_SETLK; F_SETLKW would cause a deadlock! */ for (retry = 10, gotlock = 0; retry--;) - if (fcntl(fd, F_SETLK, &lck) != -1) + if (fcntl (fd, F_SETLK, &lck) != -1) { gotlock = 1; break; @@ -361,16 +361,16 @@ rxvt_update_wtmp(const char *fname, const struct utmp *putmp) break; if (!gotlock) { /* give it up */ - close(fd); + close (fd); return; } - if (fstat(fd, &sbuf) == 0) - if (write(fd, putmp, sizeof(struct utmp)) != sizeof(struct utmp)) - ftruncate(fd, sbuf.st_size); /* remove bad writes */ + if (fstat (fd, &sbuf) == 0) + if (write (fd, putmp, sizeof (struct utmp)) != sizeof (struct utmp)) + ftruncate (fd, sbuf.st_size); /* remove bad writes */ lck.l_type = F_UNLCK; /* unlocking the file */ - fcntl(fd, F_SETLK, &lck); - close(fd); + fcntl (fd, F_SETLK, &lck); + close (fd); } #endif @@ -378,7 +378,7 @@ rxvt_update_wtmp(const char *fname, const struct utmp *putmp) #ifdef LASTLOG_SUPPORT /* INTPROTO */ void -rxvt_update_lastlog(const char *fname, const char *pty, const char *host) +rxvt_update_lastlog (const char *fname, const char *pty, const char *host) { # ifdef HAVE_STRUCT_LASTLOGX struct lastlogx llx; @@ -393,43 +393,43 @@ rxvt_update_lastlog(const char *fname, const char *pty, const char *host) # endif # ifdef HAVE_STRUCT_LASTLOGX - MEMSET(&llx, 0, sizeof(llx)); - llx.ll_tv.tv_sec = time(NULL); + MEMSET (&llx, 0, sizeof (llx)); + llx.ll_tv.tv_sec = time (NULL); llx.ll_tv.tv_usec = 0; - STRNCPY(llx.ll_line, pty, sizeof(llx.ll_line)); - STRNCPY(llx.ll_host, host, sizeof(llx.ll_host)); - updlastlogx(RXVT_LASTLOGX_FILE, getuid(), &llx); + STRNCPY (llx.ll_line, pty, sizeof (llx.ll_line)); + STRNCPY (llx.ll_host, host, sizeof (llx.ll_host)); + updlastlogx (RXVT_LASTLOGX_FILE, getuid (), &llx); # endif # ifdef HAVE_STRUCT_LASTLOG - pwent = getpwuid(getuid()); + pwent = getpwuid (getuid ()); if (!pwent) { - rxvt_print_error("no entry in password file"); + rxvt_print_error ("no entry in password file"); return; } - MEMSET(&ll, 0, sizeof(ll)); - ll.ll_time = time(NULL); - STRNCPY(ll.ll_line, pty, sizeof(ll.ll_line)); - STRNCPY(ll.ll_host, host, sizeof(ll.ll_host)); + MEMSET (&ll, 0, sizeof (ll)); + ll.ll_time = time (NULL); + STRNCPY (ll.ll_line, pty, sizeof (ll.ll_line)); + STRNCPY (ll.ll_host, host, sizeof (ll.ll_host)); # ifdef LASTLOG_IS_DIR - sprintf(lastlogfile, "%.*s/%.*s", - sizeof(lastlogfile) - sizeof(pwent->pw_name) - 2, fname, - sizeof(pwent->pw_name), + sprintf (lastlogfile, "%.*s/%.*s", + sizeof (lastlogfile) - sizeof (pwent->pw_name) - 2, fname, + sizeof (pwent->pw_name), (!pwent->pw_name || pwent->pw_name[0] == '\0') ? "unknown" : pwent->pw_name); - if ((fd = open(lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0) + if ((fd = open (lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0) { - write(fd, &ll, sizeof(ll)); - close(fd); + write (fd, &ll, sizeof (ll)); + close (fd); } # else - if ((fd = open(fname, O_RDWR)) != -1) + if ((fd = open (fname, O_RDWR)) != -1) { - if (lseek(fd, (off_t) ((long)pwent->pw_uid * sizeof(ll)), + if (lseek (fd, (off_t) ((long)pwent->pw_uid * sizeof (ll)), SEEK_SET) != -1) - write(fd, &ll, sizeof(ll)); - close(fd); + write (fd, &ll, sizeof (ll)); + close (fd); } # endif /* LASTLOG_IS_DIR */ # endif /* HAVE_STRUCT_LASTLOG */ diff --git a/src/main.C b/src/main.C index c888af31..e771aba2 100644 --- a/src/main.C +++ b/src/main.C @@ -176,7 +176,7 @@ rxvt_term::destroy_cb (time_watcher &w) } /*----------------------------------------------------------------------*/ -/* rxvt_init() */ +/* rxvt_init () */ /* LIBPROTO */ rxvt_t rxvt_init (int argc, const char *const *argv) @@ -192,7 +192,7 @@ rxvt_init (int argc, const char *const *argv) return GET_R; } -static int (*old_xerror_handler)(Display *dpy, XErrorEvent *event); +static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); void rxvt_init_signals () @@ -200,7 +200,7 @@ rxvt_init_signals () /* install exit handler for cleanup */ #if 0 #ifdef HAVE_ATEXIT - atexit(rxvt_clean_exit); + atexit (rxvt_clean_exit); #else #endif #endif @@ -261,7 +261,7 @@ rxvt_term::init (int argc, const char *const *argv) #if 0 #ifdef DEBUG_X - XSynchronize(display->display, True); + XSynchronize (display->display, True); #endif #endif @@ -270,7 +270,7 @@ rxvt_term::init (int argc, const char *const *argv) resize_scrollbar (); /* create and map scrollbar */ #endif #if (MENUBAR_MAX) - if (menubar_visible(r)) + if (menubar_visible (r)) XMapWindow (display->display, menuBar.win); #endif #ifdef TRANSPARENT @@ -305,7 +305,7 @@ rxvt_term::init (int argc, const char *const *argv) /* ARGSUSED */ /* EXTPROTO */ RETSIGTYPE -rxvt_Child_signal(int sig __attribute__ ((unused))) +rxvt_Child_signal (int sig __attribute__ ((unused))) { int pid, save_errno = errno; while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) @@ -323,13 +323,13 @@ rxvt_Child_signal(int sig __attribute__ ((unused))) */ /* EXTPROTO */ RETSIGTYPE -rxvt_Exit_signal(int sig) +rxvt_Exit_signal (int sig) { signal (sig, SIG_DFL); #ifdef DEBUG_CMD rxvt_print_error ("signal %d", sig); #endif - rxvt_clean_exit(); + rxvt_clean_exit (); kill (getpid (), sig); } @@ -367,52 +367,52 @@ rxvt_clean_exit () * ------------------------------------------------------------------------- */ /* EXTPROTO */ void * -rxvt_malloc(size_t size) +rxvt_malloc (size_t size) { void *p; - p = malloc(size); + p = malloc (size); if (p) return p; - fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); - rxvt_clean_exit(); - exit(EXIT_FAILURE); + fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); + rxvt_clean_exit (); + exit (EXIT_FAILURE); /* NOTREACHED */ } /* EXTPROTO */ void * -rxvt_calloc(size_t number, size_t size) +rxvt_calloc (size_t number, size_t size) { void *p; - p = calloc(number, size); + p = calloc (number, size); if (p) return p; - fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); - rxvt_clean_exit(); - exit(EXIT_FAILURE); + fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); + rxvt_clean_exit (); + exit (EXIT_FAILURE); /* NOTREACHED */ } /* EXTPROTO */ void * -rxvt_realloc(void *ptr, size_t size) +rxvt_realloc (void *ptr, size_t size) { void *p; if (ptr) - p = realloc(ptr, size); + p = realloc (ptr, size); else - p = malloc(size); + p = malloc (size); if (p) return p; - fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); - rxvt_clean_exit(); - exit(EXIT_FAILURE); + fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); + rxvt_clean_exit (); + exit (EXIT_FAILURE); /* NOTREACHED */ } @@ -425,7 +425,7 @@ rxvt_term::privileges (int mode) { #if ! defined(__CYGWIN32__) # if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) - /* setreuid() is the poor man's setuid(), seteuid() */ + /* setreuid () is the poor man's setuid (), seteuid () */ # define seteuid(a) setreuid(-1, (a)) # define setegid(a) setregid(-1, (a)) # define HAVE_SETEUID @@ -438,24 +438,24 @@ rxvt_term::privileges (int mode) * change effective uid/gid - not real uid/gid - so we can switch * back to root later, as required */ - seteuid(getuid()); - setegid(getgid()); + seteuid (getuid ()); + setegid (getgid ()); break; case SAVE: - euid = geteuid(); - egid = getegid(); + euid = geteuid (); + egid = getegid (); break; case RESTORE: - seteuid(euid); - setegid(egid); + seteuid (euid); + setegid (egid); break; } # else switch (mode) { case IGNORE: - setuid(getuid()); - setgid(getgid()); + setuid (getuid ()); + setgid (getgid ()); /* FALLTHROUGH */ case SAVE: /* FALLTHROUGH */ @@ -470,8 +470,8 @@ rxvt_term::privileges (int mode) void rxvt_term::privileged_utmp (char action) { - D_MAIN((stderr, "rxvt_privileged_utmp(%c); waiting for: %c (pid: %d)", - action, next_utmp_action, getpid())); + D_MAIN ((stderr, "rxvt_privileged_utmp (%c); waiting for: %c (pid: %d)", + action, next_utmp_action, getpid ())); if (next_utmp_action != action || (action != SAVE && action != RESTORE) || (Options & Opt_utmpInhibit) || ttydev == NULL || *ttydev == '\0') @@ -496,9 +496,9 @@ rxvt_term::privileged_utmp (char action) void rxvt_term::privileged_ttydev (char action) { - D_MAIN((stderr, + D_MAIN ((stderr, "privileged_ttydev (%c); waiting for: %c (pid: %d)", - action, next_tty_action, getpid())); + action, next_tty_action, getpid ())); if (next_tty_action != action || (action != SAVE && action != RESTORE) || ttydev == NULL || *ttydev == '\0') return; @@ -509,17 +509,17 @@ rxvt_term::privileged_ttydev (char action) { next_tty_action = RESTORE; # ifndef RESET_TTY_TO_COMMON_DEFAULTS - /* store original tty status for restoration rxvt_clean_exit() -- rgg 04/12/95 */ - if (lstat(ttydev, &ttyfd_stat) < 0) /* you lose out */ + /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */ + if (lstat (ttydev, &ttyfd_stat) < 0) /* you lose out */ next_tty_action = IGNORE; else # endif { - chown(ttydev, getuid(), ttygid); /* fail silently */ - chmod(ttydev, ttymode); + chown (ttydev, getuid (), ttygid); /* fail silently */ + chmod (ttydev, ttymode); # ifdef HAVE_REVOKE - revoke(ttydev); + revoke (ttydev); # endif } @@ -528,12 +528,12 @@ rxvt_term::privileged_ttydev (char action) { /* action == RESTORE */ next_tty_action = IGNORE; # ifndef RESET_TTY_TO_COMMON_DEFAULTS - chmod(ttydev, ttyfd_stat.st_mode); - chown(ttydev, ttyfd_stat.st_uid, ttyfd_stat.st_gid); + chmod (ttydev, ttyfd_stat.st_mode); + chown (ttydev, ttyfd_stat.st_uid, ttyfd_stat.st_gid); # else - chmod(ttydev, + chmod (ttydev, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); - chown(ttydev, 0, 0); + chown (ttydev, 0, 0); # endif } @@ -541,7 +541,7 @@ rxvt_term::privileged_ttydev (char action) privileges (IGNORE); # ifndef RESET_TTY_TO_COMMON_DEFAULTS - D_MAIN((stderr, "%s \"%s\": mode %03o, uid %d, gid %d", + D_MAIN ((stderr, "%s \"%s\": mode %03o, uid %d, gid %d", action == RESTORE ? "Restoring" : (action == SAVE ? "Saving" : "UNKNOWN ERROR for"), ttydev, @@ -564,7 +564,7 @@ rxvt_term::window_calc (unsigned int width, unsigned int height) unsigned int w, h; unsigned int max_width, max_height; - D_SIZE((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", + D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", TermWin.ncol, TermWin.nrow, szHint.width, szHint.height)); szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; @@ -577,15 +577,15 @@ rxvt_term::window_calc (unsigned int width, unsigned int height) { parsed_geometry = 1; if (rs[Rs_geometry]) - flags = XParseGeometry(rs[Rs_geometry], &x, &y, &w, &h); + flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); if (flags & WidthValue) { - TermWin.ncol = BOUND_POSITIVE_INT16(w); + TermWin.ncol = BOUND_POSITIVE_INT16 (w); szHint.flags |= USSize; } if (flags & HeightValue) { - TermWin.nrow = BOUND_POSITIVE_INT16(h); + TermWin.nrow = BOUND_POSITIVE_INT16 (h); szHint.flags |= USSize; } if (flags & XValue) @@ -624,14 +624,14 @@ rxvt_term::window_calc (unsigned int width, unsigned int height) window_vt_x = window_vt_y = 0; if (scrollbar_visible ()) { - sb_w = scrollbar_TotalWidth(); + sb_w = scrollbar_TotalWidth (); szHint.base_width += sb_w; - if (!(Options & Opt_scrollBar_right)) + if (! (Options & Opt_scrollBar_right)) window_vt_x = sb_w; } if (menubar_visible ()) { - mb_h = menuBar_TotalHeight(); + mb_h = menuBar_TotalHeight (); szHint.base_height += mb_h; window_vt_y = mb_h; } @@ -647,7 +647,7 @@ rxvt_term::window_calc (unsigned int width, unsigned int height) } else { - MIN_IT(TermWin.width, max_width); + MIN_IT (TermWin.width, max_width); szHint.width = szHint.base_width + TermWin.width; } if (height && height - szHint.base_height < max_height) @@ -657,7 +657,7 @@ rxvt_term::window_calc (unsigned int width, unsigned int height) } else { - MIN_IT(TermWin.height, max_height); + MIN_IT (TermWin.height, max_height); szHint.height = szHint.base_height + TermWin.height; } if (scrollbar_visible () && (Options & Opt_scrollBar_right)) @@ -672,7 +672,7 @@ rxvt_term::window_calc (unsigned int width, unsigned int height) TermWin.ncol = TermWin.width / TermWin.fwidth; TermWin.nrow = TermWin.height / TermWin.fheight; - D_SIZE((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", + D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", TermWin.ncol, TermWin.nrow, szHint.width, szHint.height)); return; @@ -698,7 +698,7 @@ rxvt_term::tt_winch () (void)ioctl (cmd_fd, TIOCSWINSZ, &ws); #else if (ioctl (cmd_fd, TIOCSWINSZ, &ws) < 0) - D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); + D_SIZE ((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); # ifdef SIGWINCH else if (cmd_pid) /* force through to the command */ kill (cmd_pid, SIGWINCH); @@ -707,7 +707,7 @@ rxvt_term::tt_winch () } /*----------------------------------------------------------------------*/ -/* rxvt_change_font() - Switch to a new font */ +/* rxvt_change_font () - Switch to a new font */ /* * init = 1 - initialize * @@ -729,16 +729,16 @@ void rxvt_term::set_title (const char *str) { #ifndef SMART_WINDOW_TITLE - XStoreName(display->display, TermWin.parent[0], str); + XStoreName (display->display, TermWin.parent[0], str); #else char *name; - if (XFetchName(display->display, TermWin.parent[0], &name) == 0) + if (XFetchName (display->display, TermWin.parent[0], &name) == 0) name = NULL; - if (name == NULL || STRCMP(name, str)) - XStoreName(display->display, TermWin.parent[0], str); + if (name == NULL || STRCMP (name, str)) + XStoreName (display->display, TermWin.parent[0], str); if (name) - XFree(name); + XFree (name); #endif } @@ -746,16 +746,16 @@ void rxvt_term::set_iconName (const char *str) { #ifndef SMART_WINDOW_TITLE - XSetIconName(display->display, TermWin.parent[0], str); + XSetIconName (display->display, TermWin.parent[0], str); #else char *name; - if (XGetIconName(display->display, TermWin.parent[0], &name)) + if (XGetIconName (display->display, TermWin.parent[0], &name)) name = NULL; - if (name == NULL || STRCMP(name, str)) - XSetIconName(display->display, TermWin.parent[0], str); + if (name == NULL || STRCMP (name, str)) + XSetIconName (display->display, TermWin.parent[0], str); if (name) - XFree(name); + XFree (name); #endif } @@ -770,15 +770,15 @@ rxvt_term::set_window_color (int idx, const char *color) return; /* handle color aliases */ - if (isdigit(*color)) + if (isdigit (*color)) { - i = atoi(color); + i = atoi (color); if (i >= 8 && i <= 15) { /* bright colors */ i -= 8; # ifndef NO_BRIGHTCOLOR PixColors[idx] = PixColors[minBrightCOLOR + i]; - SET_PIXCOLOR(idx); + SET_PIXCOLOR (idx); goto Done; # endif @@ -786,7 +786,7 @@ rxvt_term::set_window_color (int idx, const char *color) if (i >= 0 && i <= 7) { /* normal colors */ PixColors[idx] = PixColors[minCOLOR + i]; - SET_PIXCOLOR(idx); + SET_PIXCOLOR (idx); goto Done; } } @@ -805,19 +805,19 @@ rxvt_term::set_window_color (int idx, const char *color) if (i > Color_White) { /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ - XFreeColors(display->display, XCMAP, (PixColors + idx), 1, - DisplayPlanes(display->display, display->screen)); + XFreeColors (display->display, XCMAP, (PixColors + idx), 1, + DisplayPlanes (display->display, display->screen)); } # endif PixColors[idx] = xcol; - SET_PIXCOLOR(idx); + SET_PIXCOLOR (idx); /* XSetWindowAttributes attr; */ /* Cursor cursor; */ Done: - if (idx == Color_bg && !(Options & Opt_transparent)) - XSetWindowBackground(display->display, TermWin.vt, + if (idx == Color_bg && ! (Options & Opt_transparent)) + XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); /* handle Color_BD, scrollbar background, etc. */ @@ -841,7 +841,7 @@ rxvt_term::recolour_cursor () xcol[0] = PixColors[Color_pointer]; xcol[1] = PixColors[Color_bg]; XQueryColors (display->display, XCMAP, xcol, 2); - XRecolorCursor (display->display, TermWin_cursor, &(xcol[0]), &(xcol[1])); + XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); #endif } @@ -854,38 +854,38 @@ rxvt_term::set_colorfgbg () { unsigned int i; const char *xpmb = "\0"; - char fstr[sizeof("default") + 1], bstr[sizeof("default") + 1]; + char fstr[sizeof ("default") + 1], bstr[sizeof ("default") + 1]; env_colorfgbg = - (char *)rxvt_malloc(sizeof("COLORFGBG=default;default;bg") + 1); - STRCPY(fstr, "default"); - STRCPY(bstr, "default"); + (char *)rxvt_malloc (sizeof ("COLORFGBG=default;default;bg") + 1); + STRCPY (fstr, "default"); + STRCPY (bstr, "default"); for (i = Color_Black; i <= Color_White; i++) if (PixColors[Color_fg] == PixColors[i]) { - sprintf(fstr, "%d", (i - Color_Black)); + sprintf (fstr, "%d", (i - Color_Black)); break; } for (i = Color_Black; i <= Color_White; i++) if (PixColors[Color_bg] == PixColors[i]) { - sprintf(bstr, "%d", (i - Color_Black)); + sprintf (bstr, "%d", (i - Color_Black)); #ifdef XPM_BACKGROUND xpmb = "default;"; #endif break; } - sprintf(env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); - putenv(env_colorfgbg); + sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); + putenv (env_colorfgbg); #ifndef NO_BRIGHTCOLOR colorfgbg = DEFAULT_RSTYLE; for (i = minCOLOR; i <= maxCOLOR; i++) { if (PixColors[Color_fg] == PixColors[i]) - colorfgbg = SET_FGCOLOR(colorfgbg, i); + colorfgbg = SET_FGCOLOR (colorfgbg, i); if (PixColors[Color_bg] == PixColors[i]) - colorfgbg = SET_BGCOLOR(colorfgbg, i); + colorfgbg = SET_BGCOLOR (colorfgbg, i); } #endif } @@ -901,7 +901,7 @@ rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) { if (!screen_in_out->set (display, colour)) { - rxvt_print_error("can't allocate colour: %s", colour); + rxvt_print_error ("can't allocate colour: %s", colour); return false; } @@ -1017,7 +1017,7 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno TermWin.ncol = ncol; } - scr_reset(); + scr_reset (); if (curr_screen >= 0) /* this is not the first time through */ { @@ -1045,7 +1045,7 @@ rxvt_term::set_widthheight (unsigned int width, unsigned int height) if (width == 0 || height == 0) { - XGetWindowAttributes(display->display, display->root, &wattr); + XGetWindowAttributes (display->display, display->root, &wattr); if (width == 0) width = wattr.width - szHint.base_width; if (height == 0) @@ -1069,8 +1069,8 @@ rxvt_term::im_set_size (XRectangle *size) { size->x = TermWin.int_bwidth; size->y = TermWin.int_bwidth; - size->width = Width2Pixel(TermWin.ncol); - size->height = Height2Pixel(TermWin.nrow); + size->width = Width2Pixel (TermWin.ncol); + size->height = Height2Pixel (TermWin.nrow); } void @@ -1090,15 +1090,15 @@ rxvt_term::IMisRunning () char server[IMBUFSIZ]; /* get current locale modifier */ - if ((p = XSetLocaleModifiers(NULL)) != NULL) + if ((p = XSetLocaleModifiers (NULL)) != NULL) { - STRCPY(server, "@server="); - STRNCAT(server, &(p[4]), IMBUFSIZ - 9); /* skip "@im=" */ - if ((p = STRCHR(server + 1, '@')) != NULL) /* first one only */ + STRCPY (server, "@server="); + STRNCAT (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ + if ((p = STRCHR (server + 1, '@')) != NULL) /* first one only */ *p = '\0'; - atom = XInternAtom(display->display, server, False); - win = XGetSelectionOwner(display->display, atom); + atom = XInternAtom (display->display, server, False); + win = XGetSelectionOwner (display->display, atom); if (win != None) return True; } @@ -1112,8 +1112,8 @@ rxvt_term::IMSendSpot () XVaNestedList preedit_attr; if (Input_Context == NULL - || !TermWin.focus || !(input_style & XIMPreeditPosition) - || !(event_type == KeyPress + || !TermWin.focus || ! (input_style & XIMPreeditPosition) + || ! (event_type == KeyPress || event_type == Expose || event_type == NoExpose || event_type == SelectionNotify @@ -1123,9 +1123,9 @@ rxvt_term::IMSendSpot () im_set_position (&spot); - preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); - XSetICValues(Input_Context, XNPreeditAttributes, preedit_attr, NULL); - XFree(preedit_attr); + preedit_attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL); + XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, NULL); + XFree (preedit_attr); } void @@ -1134,23 +1134,23 @@ rxvt_term::im_set_preedit_area (XRectangle * preedit_rect, XRectangle * status_r { int mbh, vtx = 0; - if (scrollbar_visible () && !(Options & Opt_scrollBar_right)) - vtx = scrollbar_TotalWidth(); + if (scrollbar_visible () && ! (Options & Opt_scrollBar_right)) + vtx = scrollbar_TotalWidth (); - mbh = menubar_visible () ? menuBar_TotalHeight() : 0; + mbh = menubar_visible () ? menuBar_TotalHeight () : 0; mbh -= TermWin.lineSpace; preedit_rect->x = needed_rect->width + vtx; - preedit_rect->y = Height2Pixel(TermWin.nrow - 1) + mbh; + preedit_rect->y = Height2Pixel (TermWin.nrow - 1) + mbh; - preedit_rect->width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width + vtx; - preedit_rect->height = Height2Pixel(1); + preedit_rect->width = Width2Pixel (TermWin.ncol + 1) - needed_rect->width + vtx; + preedit_rect->height = Height2Pixel (1); status_rect->x = vtx; - status_rect->y = Height2Pixel(TermWin.nrow - 1) + mbh; + status_rect->y = Height2Pixel (TermWin.nrow - 1) + mbh; - status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel(TermWin.ncol + 1); - status_rect->height = Height2Pixel(1); + status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel (TermWin.ncol + 1); + status_rect->height = Height2Pixel (1); } void @@ -1186,10 +1186,10 @@ rxvt_term::IM_get_IC (const char *modifiers) XIMStyles *xim_styles; XVaNestedList preedit_attr, status_attr; - if (!((p = XSetLocaleModifiers (modifiers)) && *p)) + if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) return false; - D_MAIN((stderr, "rxvt_IM_get_IC()")); + D_MAIN ((stderr, "rxvt_IM_get_IC ()")); input_method = display->get_xim (locale, modifiers); if (input_method == NULL) return false; @@ -1205,14 +1205,14 @@ rxvt_term::IM_get_IC (const char *modifiers) } p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root"; - s = rxvt_splitcommastring(p); + s = rxvt_splitcommastring (p); for (i = found = 0; !found && s[i]; i++) { - if (!STRCMP(s[i], "OverTheSpot")) + if (!STRCMP (s[i], "OverTheSpot")) input_style = (XIMPreeditPosition | XIMStatusNothing); - else if (!STRCMP(s[i], "OffTheSpot")) + else if (!STRCMP (s[i], "OffTheSpot")) input_style = (XIMPreeditArea | XIMStatusArea); - else if (!STRCMP(s[i], "Root")) + else if (!STRCMP (s[i], "Root")) input_style = (XIMPreeditNothing | XIMStatusNothing); for (j = 0; j < xim_styles->count_styles; j++) @@ -1243,7 +1243,7 @@ rxvt_term::IM_get_IC (const char *modifiers) im_set_position (&spot); im_set_color (&fg, &bg); - preedit_attr = XVaCreateNestedList(0, XNArea, &rect, + preedit_attr = XVaCreateNestedList (0, XNArea, &rect, XNSpotLocation, &spot, XNForeground, fg, XNBackground, bg, //XNFontSet, TermWin.fontset, @@ -1261,29 +1261,29 @@ rxvt_term::IM_get_IC (const char *modifiers) im_set_preedit_area (&rect, &status_rect, &needed_rect); - preedit_attr = XVaCreateNestedList(0, XNArea, &rect, + preedit_attr = XVaCreateNestedList (0, XNArea, &rect, XNForeground, fg, XNBackground, bg, //XNFontSet, TermWin.fontset, NULL); - status_attr = XVaCreateNestedList(0, XNArea, &status_rect, + status_attr = XVaCreateNestedList (0, XNArea, &status_rect, XNForeground, fg, XNBackground, bg, //XNFontSet, TermWin.fontset, NULL); } - Input_Context = XCreateIC(xim, XNInputStyle, input_style, + Input_Context = XCreateIC (xim, XNInputStyle, input_style, XNClientWindow, TermWin.parent[0], XNFocusWindow, TermWin.parent[0], preedit_attr ? XNPreeditAttributes : NULL, preedit_attr, status_attr ? XNStatusAttributes : NULL, status_attr, NULL); - if (preedit_attr) XFree(preedit_attr); - if (status_attr) XFree(status_attr); + if (preedit_attr) XFree (preedit_attr); + if (status_attr) XFree (status_attr); if (Input_Context == NULL) { - rxvt_print_error("failed to create input context"); + rxvt_print_error ("failed to create input context"); display->put_xim (input_method); return false; } @@ -1291,7 +1291,7 @@ rxvt_term::IM_get_IC (const char *modifiers) if (input_style & XIMPreeditArea) IMSetStatusPosition (); - D_MAIN((stderr, "rxvt_IM_get_IC() - successful connection")); + D_MAIN ((stderr, "rxvt_IM_get_IC () - successful connection")); return true; } @@ -1305,7 +1305,7 @@ rxvt_term::im_cb () im_destroy (); - D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); + D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); if (Input_Context) return; @@ -1334,8 +1334,8 @@ rxvt_term::im_cb () } } for (i = 0; s[i]; i++) - free(s[i]); - free(s); + free (s[i]); + free (s); if (found) goto done; @@ -1363,26 +1363,26 @@ rxvt_term::IMSetStatusPosition () XVaNestedList preedit_attr, status_attr; if (Input_Context == NULL - || !TermWin.focus || !(input_style & XIMPreeditArea) + || !TermWin.focus || ! (input_style & XIMPreeditArea) || !IMisRunning ()) return; /* Getting the necessary width of preedit area */ - status_attr = XVaCreateNestedList(0, XNAreaNeeded, &needed_rect, NULL); - XGetICValues(Input_Context, XNStatusAttributes, status_attr, NULL); - XFree(status_attr); + status_attr = XVaCreateNestedList (0, XNAreaNeeded, &needed_rect, NULL); + XGetICValues (Input_Context, XNStatusAttributes, status_attr, NULL); + XFree (status_attr); im_set_preedit_area (&preedit_rect, &status_rect, needed_rect); - preedit_attr = XVaCreateNestedList(0, XNArea, &preedit_rect, NULL); - status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL); + preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL); + status_attr = XVaCreateNestedList (0, XNArea, &status_rect, NULL); - XSetICValues(Input_Context, + XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, XNStatusAttributes, status_attr, NULL); - XFree(preedit_attr); - XFree(status_attr); + XFree (preedit_attr); + XFree (status_attr); } #endif /* USE_XIM */ -- 2.34.1