From 8cb297a6715dd27dd2dd0135116936c1ffad3aa2 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 10 Oct 2001 18:52:14 +0000 Subject: [PATCH] small cleanup --- src/wdefaults.c | 27 ++++++++++++++++----------- src/winspector.c | 27 ++++++++++++--------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/wdefaults.c b/src/wdefaults.c index 2865ff16..322a202f 100644 --- a/src/wdefaults.c +++ b/src/wdefaults.c @@ -202,12 +202,15 @@ wDefaultFillAttributes(WScreen *scr, char *instance, char *class, if (class && instance) { - char *buffer = NULL; - buffer = wmalloc(strlen(class)+strlen(instance)+4); - key1 = WMCreatePLString(strcat(strcat(strcpy(buffer,instance),"."),class)); - wfree(buffer); - } else - key1 = NULL; + char *buffer; + + buffer = wmalloc(strlen(class)+strlen(instance)+2); + sprintf(buffer, "%s.%s", instance, class); + key1 = WMCreatePLString(buffer); + wfree(buffer); + } else { + key1 = NULL; + } if (instance) key2 = WMCreatePLString(instance); @@ -342,13 +345,15 @@ get_generic_value(WScreen *scr, char *instance, char *class, WMPropList *option, WMPLSetCaseSensitive(True); if (class && instance) { - char *buffer = NULL; - buffer = wmalloc(strlen(class)+strlen(instance)+4); - key = WMCreatePLString(strcat(strcat(strcpy(buffer,instance),"."),class)); + char *buffer; + + buffer = wmalloc(strlen(class)+strlen(instance)+2); + sprintf(buffer, "%s.%s", instance, class); + key = WMCreatePLString(buffer); + wfree(buffer); dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key); WMReleasePropList(key); - wfree(buffer); if (dict) { value = WMGetFromPLDictionary(dict, option); @@ -508,7 +513,7 @@ wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file) if (instance && class) { char *buffer; buffer = wmalloc(strlen(instance) + strlen(class) + 2); - strcat(strcat(strcpy(buffer, instance), "."), class); + sprintf(buffer, "%s.%s", instance, class); key = WMCreatePLString(buffer); wfree(buffer); } else if (instance) { diff --git a/src/winspector.c b/src/winspector.c index fab9d045..173979c5 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -525,10 +525,10 @@ saveSettings(WMButton *button, InspectorPanel *panel) else if (WMGetButtonSelected(panel->clsRb) != 0) key = WMCreatePLString(wwin->wm_class); else if (WMGetButtonSelected(panel->bothRb) != 0) { - char *buffer; + char *buffer; - buffer = wmalloc(strlen(wwin->wm_instance)+strlen(wwin->wm_class)+4); - strcat(strcat(strcpy(buffer, wwin->wm_instance), "."), wwin->wm_class); + buffer = wmalloc(strlen(wwin->wm_instance)+strlen(wwin->wm_class)+2); + sprintf(buffer, "%s.%s", wwin->wm_instance, wwin->wm_class); key = WMCreatePLString(buffer); wfree(buffer); } else if (WMGetButtonSelected(panel->defaultRb) != 0) { @@ -682,25 +682,22 @@ saveSettings(WMButton *button, InspectorPanel *panel) wapp = wApplicationOf(panel->inspected->main_window); if (wapp) { - char *iconFile; - char *buffer; + char *instance = wapp->main_window_desc->wm_instance; + char *class = wapp->main_window_desc->wm_class; + char *iconFile, *buffer; appDic = WMCreatePLDictionary(NULL, NULL, NULL); - assert(wapp->main_window_desc->wm_instance!=NULL); - assert(wapp->main_window_desc->wm_class!=NULL); + assert(instance!=NULL); + assert(class!=NULL); - buffer = wmalloc(strlen(wapp->main_window_desc->wm_instance) - +strlen(wapp->main_window_desc->wm_class)+4); - strcat(strcpy(buffer, wapp->main_window_desc->wm_instance), "."); - strcat(buffer, wapp->main_window_desc->wm_class); + buffer = wmalloc(strlen(instance)+strlen(class)+2); + sprintf(buffer, "%s.%s", instance, class); key = WMCreatePLString(buffer); wfree(buffer); - iconFile = wDefaultGetIconFile(wwin->screen_ptr, - wapp->main_window_desc->wm_instance, - wapp->main_window_desc->wm_class, - False); + iconFile = wDefaultGetIconFile(wwin->screen_ptr, + instance, class, False); if (iconFile && iconFile[0]!=0) { value = WMCreatePLString(iconFile); -- 2.11.4.GIT