The function StrConcatDot is used in application.c and defaults.c
to simplify the code.
---
 src/application.c |   23 ++++-------------------
 src/wdefaults.c   |    3 +--
 2 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/src/application.c b/src/application.c
index 0b82078..90ce7e1 100644
--- a/src/application.c
+++ b/src/application.c
@@ -128,25 +128,10 @@ void wApplicationSaveIconPathFor(char *iconPath, char 
*wm_instance, char *wm_cla
        WMPropList *dict = WDWindowAttributes->dictionary;
        WMPropList *adict, *key, *iconk;
        WMPropList *val;
-       char *tmp;
-       int i;
-
-       i = 0;
-       if (wm_instance)
-               i += strlen(wm_instance);
-       if (wm_class)
-               i += strlen(wm_class);
-
-       tmp = wmalloc(i + 8);
-       *tmp = 0;
-       if (wm_class && wm_instance) {
-               sprintf(tmp, "%s.%s", wm_instance, wm_class);
-       } else {
-               if (wm_instance)
-                       strcat(tmp, wm_instance);
-               if (wm_class)
-                       strcat(tmp, wm_class);
-       }
+       char *tmp = NULL;
+
+       if (wm_class || wm_instance)
+               tmp = StrConcatDot(wm_instance, wm_class, False);
 
        key = WMCreatePLString(tmp);
        wfree(tmp);
diff --git a/src/wdefaults.c b/src/wdefaults.c
index d97d438..3491572 100644
--- a/src/wdefaults.c
+++ b/src/wdefaults.c
@@ -330,8 +330,7 @@ static WMPropList *get_generic_value(WScreen *scr, char 
*instance, char *class,
        if (class && instance) {
                char *buffer;
 
-               buffer = wmalloc(strlen(class) + strlen(instance) + 2);
-               sprintf(buffer, "%s.%s", instance, class);
+               buffer = StrConcatDot(instance, class, True);
                key = WMCreatePLString(buffer);
                wfree(buffer);
 
-- 
1.7.9.1

>From 22b45c23002a313f108df19f6f9479847b9af0b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sat, 14 Apr 2012 12:08:49 +0200
Subject: [PATCH 11/16] WindowMaker: StrConcatDot used in application.c
 wdefaults.c

The function StrConcatDot is used in application.c and defaults.c
to simplify the code.
---
 src/application.c |   23 ++++-------------------
 src/wdefaults.c   |    3 +--
 2 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/src/application.c b/src/application.c
index 0b82078..90ce7e1 100644
--- a/src/application.c
+++ b/src/application.c
@@ -128,25 +128,10 @@ void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char *wm_cla
 	WMPropList *dict = WDWindowAttributes->dictionary;
 	WMPropList *adict, *key, *iconk;
 	WMPropList *val;
-	char *tmp;
-	int i;
-
-	i = 0;
-	if (wm_instance)
-		i += strlen(wm_instance);
-	if (wm_class)
-		i += strlen(wm_class);
-
-	tmp = wmalloc(i + 8);
-	*tmp = 0;
-	if (wm_class && wm_instance) {
-		sprintf(tmp, "%s.%s", wm_instance, wm_class);
-	} else {
-		if (wm_instance)
-			strcat(tmp, wm_instance);
-		if (wm_class)
-			strcat(tmp, wm_class);
-	}
+	char *tmp = NULL;
+
+	if (wm_class || wm_instance)
+		tmp = StrConcatDot(wm_instance, wm_class, False);
 
 	key = WMCreatePLString(tmp);
 	wfree(tmp);
diff --git a/src/wdefaults.c b/src/wdefaults.c
index d97d438..3491572 100644
--- a/src/wdefaults.c
+++ b/src/wdefaults.c
@@ -330,8 +330,7 @@ static WMPropList *get_generic_value(WScreen *scr, char *instance, char *class,
 	if (class && instance) {
 		char *buffer;
 
-		buffer = wmalloc(strlen(class) + strlen(instance) + 2);
-		sprintf(buffer, "%s.%s", instance, class);
+		buffer = StrConcatDot(instance, class, True);
 		key = WMCreatePLString(buffer);
 		wfree(buffer);
 
-- 
1.7.9.1

Reply via email to