From ee442551e1531712226a3a3ba26afff466100bb5 Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Mon, 21 Jan 2008 07:57:32 +0000 Subject: passes gcc -Wall with no warnings other than des cryppt C_block sadness and getsid problem --- zwgc/X_driver.c | 12 +++++--- zwgc/X_fonts.c | 30 +++++++++---------- zwgc/X_gram.c | 25 +++++++++------- zwgc/X_gram.h | 1 + zwgc/character_class.c | 2 +- zwgc/file.c | 6 ++-- zwgc/formatter.c | 9 +++--- zwgc/lexer.c | 6 ++-- zwgc/main.c | 8 ++++-- zwgc/port.c | 6 ++-- zwgc/standard_ports.c | 12 +++++--- zwgc/string_dictionary_aux.c | 2 +- zwgc/subscriptions.c | 7 +++-- zwgc/substitute.c | 2 +- zwgc/text_operations.c | 8 +++--- zwgc/tty_filter.c | 68 ++++++++++++++++++++++++++------------------ zwgc/variables.c | 3 +- zwgc/xcut.c | 1 + zwgc/xmark.c | 2 +- zwgc/xrevstack.h | 2 +- zwgc/xselect.c | 7 +++-- zwgc/xshow.c | 1 - zwgc/zephyr.c | 6 ++-- zwgc/zephyr.h | 2 ++ 24 files changed, 136 insertions(+), 92 deletions(-) (limited to 'zwgc') diff --git a/zwgc/X_driver.c b/zwgc/X_driver.c index 2577966..e969eb7 100644 --- a/zwgc/X_driver.c +++ b/zwgc/X_driver.c @@ -38,6 +38,7 @@ static const char rcsid_X_driver_c[] = "$Id$"; #include "X_gram.h" #include "xselect.h" #include "unsigned_long_dictionary.h" +#include "zephyr.h" char *app_instance; @@ -294,7 +295,8 @@ open_display_and_load_resources(int *pargc, /* * Get XENVIRONMENT resources, if they exist, and merge */ - if (filename = getenv("XENVIRONMENT")) + filename = getenv("XENVIRONMENT"); + if (filename) { temp_db3 = XrmGetFileDatabase(filename); XrmMergeDatabases(temp_db3, &temp_db1); @@ -354,9 +356,11 @@ X_driver_init(char *drivername, /* * For now, set some useful variables using resources: */ - if (sync=get_bool_resource("synchronous", "Synchronous", 0)) - XSynchronize(dpy,sync); - if (temp = get_string_resource("geometry", "Geometry")) + sync = get_bool_resource("synchronous", "Synchronous", 0); + if (sync) + XSynchronize(dpy, sync); + temp = get_string_resource("geometry", "Geometry"); + if (temp) var_set_variable("default_X_geometry", temp); temp=strrchr(argv[0],'/'); diff --git a/zwgc/X_fonts.c b/zwgc/X_fonts.c index 95e21d5..0d8e2b7 100644 --- a/zwgc/X_fonts.c +++ b/zwgc/X_fonts.c @@ -231,9 +231,9 @@ complete_get_fontst(Display *dpy, char *family,*fontname; XFontStruct *fontst; - if (family=get_family(style,substyle)) - if (fontname=get_fontname(family,size,face)) - if (fontst=get_fontst(dpy,fontname)) + if ((family=get_family(style,substyle))) + if ((fontname=get_fontname(family,size,face))) + if ((fontst=get_fontst(dpy,fontname))) return(fontst); /* If any part fails, */ return(NULL); @@ -259,16 +259,16 @@ get_font(Display *dpy, if (size == SPECIAL_SIZE) { /* attempt to process @font explicitly */ - if (fontst=get_fontst(dpy,substyle)) + if ((fontst = get_fontst(dpy, substyle))) return(fontst); } else { - if (family=get_family(style,substyle)) { - if (fontname=get_fontname(family,size,face)) - if (fontst=get_fontst(dpy,fontname)) + if ((family = get_family(style, substyle))) { + if ((fontname = get_fontname(family, size,face))) + if ((fontst = get_fontst(dpy, fontname))) return(fontst); } else { - if (fontname=get_fontname(substyle,size,face)) - if (fontst=get_fontst(dpy,fontname)) + if ((fontname = get_fontname(substyle, size, face))) + if ((fontst = get_fontst(dpy, fontname))) return(fontst); } @@ -276,17 +276,17 @@ get_font(Display *dpy, of substyle being the fontfamily didn't happen, either. */ fontst=NULL; - if (!(fontst=complete_get_fontst(dpy,style,"text",size,face))) - if (!(fontst=complete_get_fontst(dpy,"default",substyle,size,face))) - if (!(fontst=complete_get_fontst(dpy,"default","text",size,face))) - if (fontname=get_fontname("default",size,face)) - fontst=get_fontst(dpy,fontname); + if (!(fontst = complete_get_fontst(dpy,style,"text",size,face))) + if (!(fontst = complete_get_fontst(dpy,"default",substyle,size,face))) + if (!(fontst = complete_get_fontst(dpy,"default","text",size,face))) + if ((fontname = get_fontname("default",size,face))) + fontst = get_fontst(dpy,fontname); if (fontst) return(fontst); } /* If all else fails, try fixed */ - if (fontst=get_fontst(dpy,"fixed")) return(fontst); + if ((fontst=get_fontst(dpy,"fixed"))) return(fontst); /* No fonts available. Die. */ diff --git a/zwgc/X_gram.c b/zwgc/X_gram.c index 96e8fb1..6ce4297 100644 --- a/zwgc/X_gram.c +++ b/zwgc/X_gram.c @@ -127,15 +127,18 @@ x_gram_init(Display *dpy) default_fgcolor = default_bgcolor; default_bgcolor = tc; } - if (temp = get_string_resource("foreground","Foreground")) - default_fgcolor = x_string_to_color(temp,default_fgcolor); - if (temp = get_string_resource("background","Background")) - default_bgcolor = x_string_to_color(temp,default_bgcolor); + temp = get_string_resource("foreground", "Foreground"); + if (temp) + default_fgcolor = x_string_to_color(temp, default_fgcolor); + temp = get_string_resource("background", "Background"); + if (temp) + default_bgcolor = x_string_to_color(temp, default_bgcolor); default_bordercolor = default_fgcolor; - if (temp = get_string_resource("borderColor","BorderColor")) - default_bordercolor = x_string_to_color(temp,default_bordercolor); + temp = get_string_resource("borderColor", "BorderColor"); + if (temp) + default_bordercolor = x_string_to_color(temp, default_bordercolor); - temp = get_string_resource("minTimeToLive","MinTimeToLive"); + temp = get_string_resource("minTimeToLive", "MinTimeToLive"); if (temp && atoi(temp)>=0) ttl = atoi(temp); @@ -302,15 +305,15 @@ x_gram_create(Display *dpy, xpos = WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xpos - xsize - 2*border_width; else if (xalign == 0) - xpos = (WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xsize - - 2*border_width)>>1 + xpos; + xpos = ((WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xsize + - 2*border_width)>>1) + xpos; if (yalign<0) ypos = HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ypos - ysize - 2*border_width; else if (yalign == 0) - ypos = (HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ysize - - 2*border_width)>>1 + ypos; + ypos = ((HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ysize + - 2*border_width)>>1) + ypos; /* * Create the window: diff --git a/zwgc/X_gram.h b/zwgc/X_gram.h index 5d3f5d0..ed1adf7 100644 --- a/zwgc/X_gram.h +++ b/zwgc/X_gram.h @@ -82,5 +82,6 @@ extern void x_gram_expose(Display *, Window, x_gram *, XExposeEvent *); extern void xshow(Display *, desctype *, int, int); extern void xcut(Display *, XEvent *, XContext); extern void x_get_input(Display *); +extern void xshowinit(void); #endif diff --git a/zwgc/character_class.c b/zwgc/character_class.c index a11aa86..2f3c433 100644 --- a/zwgc/character_class.c +++ b/zwgc/character_class.c @@ -37,7 +37,7 @@ string_to_character_class(string str) (void) memset(cache, 0, sizeof(cache)); for (i=0; icode=DT_STR; here->str=curstr; here->len=len; diff --git a/zwgc/lexer.c b/zwgc/lexer.c index 7e32086..e821eb9 100644 --- a/zwgc/lexer.c +++ b/zwgc/lexer.c @@ -470,7 +470,8 @@ handle_show(void) if (c!='\n') unput(c); - if (yylval.text = eat_til_endshow(start_line_no)) + yylval.text = eat_til_endshow(start_line_no); + if (yylval.text) return(SHOW); else return(ERROR); @@ -656,7 +657,8 @@ int yylex(void) * Handle constant strings: */ case '"': - if (yylval.text = eat_string(yylineno)) + yylval.text = eat_string(yylineno); + if (yylval.text) return(STRING); else return(ERROR); diff --git a/zwgc/main.c b/zwgc/main.c index 3568443..8584eca 100644 --- a/zwgc/main.c +++ b/zwgc/main.c @@ -114,6 +114,7 @@ fake_startup_packet(void) ZNotice_t notice; struct timezone tz; char msgbuf[BUFSIZ]; + extern void Z_gettimeofday(struct _ZTimeval *, struct timezone *); var_set_variable("version", zwgc_version_string); @@ -371,7 +372,8 @@ process_notice(ZNotice_t *notice, dprintf("Got a message\n"); - if (control_opcode = decode_notice(notice, hostname)) { + control_opcode = decode_notice(notice, hostname); + if (control_opcode) { #ifdef DEBUG printf("got control opcode <%s>.\n", control_opcode); #endif @@ -548,6 +550,7 @@ detach(void) * of finding the session leader; otherwise use the process group of * the parent process, which is a good guess. */ #if defined(HAVE_GETSID) + setpgid(0, getsid(0)); #elif defined(HAVE_GETPGID) setpgid(0, getpgid(getppid())); @@ -556,7 +559,8 @@ detach(void) #endif /* fork off and let parent exit... */ - if (i = fork()) { + i = fork(); + if (i) { if (i < 0) { perror("zwgc: cannot fork, aborting:"); exit(1); diff --git a/zwgc/port.c b/zwgc/port.c index 55d6274..3d73a69 100644 --- a/zwgc/port.c +++ b/zwgc/port.c @@ -105,7 +105,8 @@ port_close_input(port *p) if (!close_input_proc) return; - if (error = close_input_proc(p)) + error = close_input_proc(p); + if (error) var_set_variable("error", error); } @@ -123,7 +124,8 @@ port_close_output(port *p) if (!close_output_proc) return; - if (error = close_output_proc(p)) + error = close_output_proc(p); + if (error) var_set_variable("error", error); } diff --git a/zwgc/standard_ports.c b/zwgc/standard_ports.c index f679f4e..1c6d1ce 100644 --- a/zwgc/standard_ports.c +++ b/zwgc/standard_ports.c @@ -208,21 +208,25 @@ void init_standard_ports(int *pargc, current++; *pargc -= 2; if (!*current) usage(); - if (p = get_standard_port_info((string) *current)) + p = get_standard_port_info((string) *current); + if (p) p->port_setup_status = DISABLED; } else if (string_Eq((string) *current, "-default")) { current++; *pargc -= 2; if (!*current) usage(); default_port = (string) *current; - if (p = get_standard_port_info((string) *current)) + p = get_standard_port_info((string) *current); + if (p) p->port_setup_status = DEFAULT_OK; } else if (string_Eq((string) *current, "-ttymode")) { default_port = (string) "tty"; (*pargc)--; - if (p = get_standard_port_info(default_port)) { + p = get_standard_port_info(default_port); + if (p) { p->port_setup_status = DEFAULT_OK; - if (p = get_standard_port_info ((string) "X")) + p = get_standard_port_info ((string) "X"); + if (p) p->port_setup_status = DISABLED; } } else diff --git a/zwgc/string_dictionary_aux.c b/zwgc/string_dictionary_aux.c index daee49c..5dfd89d 100644 --- a/zwgc/string_dictionary_aux.c +++ b/zwgc/string_dictionary_aux.c @@ -12,7 +12,7 @@ */ #if (!defined(lint) && !defined(SABER)) -static char rcsid_string_dictionary_aux_c[] = "$Id$"; +static const char rcsid_string_dictionary_aux_c[] = "$Id$"; #endif /* diff --git a/zwgc/subscriptions.c b/zwgc/subscriptions.c index cfe932e..5123d5f 100644 --- a/zwgc/subscriptions.c +++ b/zwgc/subscriptions.c @@ -12,7 +12,7 @@ */ #if (!defined(lint) && !defined(SABER)) -static char rcsid_subscriptions_c[] = "$Id$"; +static const char rcsid_subscriptions_c[] = "$Id$"; #endif /****************************************************************************/ @@ -271,8 +271,9 @@ load_subscriptions_from_file(FILE *file) /* Parse line */ /* <<<>>> * The below does NOT work is the recipient field is "": - */ - if (temp = strchr(line, '#')) + */ + temp = strchr(line, '#'); + if (temp) *temp = '\0'; for (temp=line; *temp && *temp==' '; temp++) ; if (!*temp || *temp=='\n') diff --git a/zwgc/substitute.c b/zwgc/substitute.c index d50614c..26accc1 100644 --- a/zwgc/substitute.c +++ b/zwgc/substitute.c @@ -12,7 +12,7 @@ */ #if (!defined(lint) && !defined(SABER)) -static char rcsid_substitute_c[] = "$Id$"; +static const char rcsid_substitute_c[] = "$Id$"; #endif #include diff --git a/zwgc/text_operations.c b/zwgc/text_operations.c index 34f0d4c..16d9047 100644 --- a/zwgc/text_operations.c +++ b/zwgc/text_operations.c @@ -47,7 +47,7 @@ lbreak(string *text_ptr, string result, whats_left; char *p = *text_ptr; - while (*p && !set[*p]) p++; + while (*p && !set[(int)*p]) p++; result = string_CreateFromData(*text_ptr, p - *text_ptr); whats_left = string_Copy(p); @@ -64,7 +64,7 @@ lspan(string *text_ptr, string result, whats_left; char *p = *text_ptr; - while (*p && set[*p]) p++; + while (*p && set[(int)*p]) p++; result = string_CreateFromData(*text_ptr, p - *text_ptr); whats_left = string_Copy(p); @@ -100,7 +100,7 @@ rbreak(string *text_ptr, string text = *text_ptr; char *p = text + strlen(text); - while (text

+#else +#ifdef HAVE_TERM_H +#include +#endif #endif #include "new_memory.h" @@ -138,59 +142,65 @@ tty_filter_init(char *drivername, tmp = tgetstr("pc", &p); PC = (tmp) ? *tmp : 0; - if (tmp = tgetstr("md",&p)) { /* bold ? */ + tmp = tgetstr("md", &p); + if (tmp) { /* bold ? */ EXPAND("B.bold"); tmp = tgetstr("me",&p); EXPAND("E.bold"); } - if (tmp = tgetstr("mr",&p)) { /* reverse video? */ + tmp = tgetstr("mr", &p); + if (tmp) { /* reverse video? */ EXPAND("B.rw"); - tmp = tgetstr("me",&p); + tmp = tgetstr("me", &p); EXPAND("E.rw"); } - if (tmp = tgetstr("bl",&p)) { /* Bell ? */ + tmp = tgetstr("bl", &p); + if (tmp) { /* Bell ? */ EXPAND("B.bell"); TD_SET("E.bell", NULL); } - if (tmp = tgetstr("mb",&p)) { /* Blink ? */ + tmp = tgetstr("mb", &p); + if (tmp) { /* Blink ? */ EXPAND("B.blink"); - tmp = tgetstr("me",&p); + tmp = tgetstr("me", &p); EXPAND("E.blink"); } - if (tmp = tgetstr("us",&p)) { /* Underline ? */ + tmp = tgetstr("us", &p); + if (tmp) { /* Underline ? */ EXPAND("B.u"); - tmp = tgetstr("ue",&p); + tmp = tgetstr("ue", &p); EXPAND("E.u"); } - if (tmp = tgetstr("so",&p)) { /* Standout ? */ + tmp = tgetstr("so", &p); + if (tmp) { /* Standout ? */ EXPAND("B.so"); - tmp = tgetstr("se",&p); + tmp = tgetstr("se", &p); EXPAND("E.so"); } } /* Step 2: alias others to the nearest substitute */ /* Bold = so, else rv, else ul */ - if (NULL == string_dictionary_Lookup(termcap_dict,"B.bold")) { - if(b = string_dictionary_Lookup(termcap_dict,"B.so")) { - TD_SET("B.bold",b->value); + if (NULL == string_dictionary_Lookup(termcap_dict, "B.bold")) { + if((b = string_dictionary_Lookup(termcap_dict, "B.so"))) { + TD_SET("B.bold", b->value); TD_SET("E.bold", - string_dictionary_Lookup(termcap_dict,"E.so")->value); - } else if (b = string_dictionary_Lookup(termcap_dict,"B.rv")) { - TD_SET("B.bold",b->value); + string_dictionary_Lookup(termcap_dict, "E.so")->value); + } else if ((b = string_dictionary_Lookup(termcap_dict, "B.rv"))) { + TD_SET("B.bold", b->value); TD_SET("E.bold", - string_dictionary_Lookup(termcap_dict,"E.rv")->value); - } else if (b = string_dictionary_Lookup(termcap_dict,"B.u")) { - TD_SET("B.bold",b->value); + string_dictionary_Lookup(termcap_dict, "E.rv")->value); + } else if ((b = string_dictionary_Lookup(termcap_dict,"B.u"))) { + TD_SET("B.bold", b->value); TD_SET("E.bold", - string_dictionary_Lookup(termcap_dict,"E.u")->value); + string_dictionary_Lookup(termcap_dict, "E.u")->value); } } /* Bell = ^G */ - if (NULL == string_dictionary_Lookup(termcap_dict,"B.bell")) { - TD_SET("B.bell","\007"); - TD_SET("E.bell",NULL); + if (NULL == string_dictionary_Lookup(termcap_dict, "B.bell")) { + TD_SET("B.bell", "\007"); + TD_SET("E.bell", NULL); } /* Underline -> nothing */ @@ -486,10 +496,12 @@ tty_filter(string text, item = string_Copy(""); if (info->bold_p && use_fonts) { - if (temp = string_dictionary_Fetch(termcap_dict, "B.bold")) + temp = string_dictionary_Fetch(termcap_dict, "B.bold"); + if (temp) item = string_Concat2(item, temp); } else if (info->italic_p && use_fonts) { - if (temp = string_dictionary_Fetch(termcap_dict, "B.u")) + temp = string_dictionary_Fetch(termcap_dict, "B.u"); + if (temp) item = string_Concat2(item, temp); } temp = string_CreateFromData(info->str, info->len); @@ -497,10 +509,12 @@ tty_filter(string text, free(temp); if (info->bold_p && use_fonts) { - if (temp = string_dictionary_Fetch(termcap_dict, "E.bold")) + temp = string_dictionary_Fetch(termcap_dict, "E.bold"); + if (temp) item = string_Concat2(item, temp); } else if (info->italic_p && use_fonts) { - if (temp = string_dictionary_Fetch(termcap_dict, "E.u")) + temp = string_dictionary_Fetch(termcap_dict, "E.u"); + if (temp) item = string_Concat2(item, temp); } diff --git a/zwgc/variables.c b/zwgc/variables.c index a444b44..3368c1f 100644 --- a/zwgc/variables.c +++ b/zwgc/variables.c @@ -113,7 +113,8 @@ var_get_variable(string name) static string last_get_field_call_result = NULL; if (is_number_variable(name)) { - if (result = string_dictionary_Fetch(number_variable_dict, name)) + result = string_dictionary_Fetch(number_variable_dict, name); + if (result) return(result); /* diff --git a/zwgc/xcut.c b/zwgc/xcut.c index b6019a9..4fad2a7 100644 --- a/zwgc/xcut.c +++ b/zwgc/xcut.c @@ -37,6 +37,7 @@ static const char rcsid_xcut_c[] = "$Id$"; #include "xmark.h" #include "error.h" #include "xrevstack.h" +#include "X_driver.h" /* * diff --git a/zwgc/xmark.c b/zwgc/xmark.c index 7285834..6a6a7a0 100644 --- a/zwgc/xmark.c +++ b/zwgc/xmark.c @@ -12,7 +12,7 @@ */ #if (!defined(lint) && !defined(SABER)) -static char rcsid_xmark_c[] = "$Id$"; +static const char rcsid_xmark_c[] = "$Id$"; #endif #include diff --git a/zwgc/xrevstack.h b/zwgc/xrevstack.h index 0976821..20d1fe9 100644 --- a/zwgc/xrevstack.h +++ b/zwgc/xrevstack.h @@ -15,7 +15,7 @@ #define _XREVSTACK_H_ #if (!defined(lint) && !defined(SABER)) -static char rcsid_xrevstack_h[] = "$Id$"; +static const char rcsid_xrevstack_h[] = "$Id$"; #endif #include diff --git a/zwgc/xselect.c b/zwgc/xselect.c index 2579dc4..2192182 100644 --- a/zwgc/xselect.c +++ b/zwgc/xselect.c @@ -118,7 +118,8 @@ xselSetProperties(Display *dpy, } else if (target==XA_STRING) { char *selected; - if (selected = getSelectedText()) { + selected = getSelectedText(); + if (selected) { ChangeProp(XA_STRING,8,selected,string_Length(selected)); } else { /* This should only happen if the pasting client is out of @@ -179,8 +180,8 @@ xselProcessSelection(Display *dpy, #endif if ((ownership_start == CurrentTime) || - ((selreq->time != CurrentTime) && - (selreq->time < ownership_start) || + (((selreq->time != CurrentTime) && + (selreq->time < ownership_start)) || ((ownership_end != CurrentTime) && (ownership_end > ownership_start) && (selreq->time > ownership_end)))) diff --git a/zwgc/xshow.c b/zwgc/xshow.c index 68c64eb..6667013 100644 --- a/zwgc/xshow.c +++ b/zwgc/xshow.c @@ -38,7 +38,6 @@ static const char rcsid_xshow_c[] = "$Id$"; #define max(a,b) ((a)>(b)?(a):(b)) XContext desc_context; -static pointer_dictionary colorname_dict = NULL; extern int internal_border_width; extern unsigned long default_bgcolor; diff --git a/zwgc/zephyr.c b/zwgc/zephyr.c index e1497d4..f672d84 100644 --- a/zwgc/zephyr.c +++ b/zwgc/zephyr.c @@ -64,7 +64,8 @@ get_zwgc_port_number_filename(void) static char buffer[40]; char *temp; - if (temp = getenv("WGFILE")) + temp = getenv("WGFILE"); + if (temp) return(temp); else { sprintf(buffer, "/tmp/wg.%d", getuid()); @@ -170,7 +171,8 @@ void zephyr_init(void (*notice_handler)(ZNotice_t *)) * not one of the allowed ones, print an error and treat it as * EXPOSE_NONE. */ - if (temp = ZGetVariable("exposure")) { + temp = ZGetVariable("exposure"); + if (temp) { if (!(exposure = ZParseExposureLevel(temp))) { ERROR2("invalid exposure level %s, using exposure level none instead.\n", temp); exposure = EXPOSE_NONE; diff --git a/zwgc/zephyr.h b/zwgc/zephyr.h index e821bfd..1e714a3 100644 --- a/zwgc/zephyr.h +++ b/zwgc/zephyr.h @@ -17,6 +17,8 @@ #ifndef zephyr_MODULE #define zephyr_MODULE +#include + extern void zephyr_init(void(*)(ZNotice_t *)); extern void finalize_zephyr(void); extern void write_wgfile(void); -- cgit v1.2.3