There's no need to have a private function while there's one in WINGs.

Besides that, it's buggy because it does not remove trailing whitespaces,
as I just tested:

[mafra@Pilar:Defaults]$ grep CloseKey WindowMaker
  CloseKey = "Mod1+C    ";

Using wtrimspace() fixes that and even saves 208 bytes of code:

[mafra@Pilar:WPrefs.app]$ size KeyboardShortcuts.o.*
   text    data     bss     dec     hex filename
   7703       0       0    7703    1e17 KeyboardShortcuts.o.new
   7911       0       0    7911    1ee7 KeyboardShortcuts.o.old

Signed-off-by: Carlos R. Mafra <[email protected]>
---
 WPrefs.app/KeyboardShortcuts.c |   21 ++-------------------
 1 files changed, 2 insertions(+), 19 deletions(-)

diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c
index 1d70854..4ea7fa4 100644
--- a/WPrefs.app/KeyboardShortcuts.c
+++ b/WPrefs.app/KeyboardShortcuts.c
@@ -359,23 +359,6 @@ static void listClick(WMWidget * w, void *data)
        WMSetTextFieldText(panel->shoT, panel->shortcuts[row]);
 }
 
-static char *trimstr(char *str)
-{
-       char *p = str;
-       int i;
-
-       while (isspace(*p))
-               p++;
-       p = wstrdup(p);
-       i = strlen(p);
-       while (isspace(p[i]) && i > 0) {
-               p[i] = 0;
-               i--;
-       }
-
-       return p;
-}
-
 static void showData(_Panel * panel)
 {
        char *str;
@@ -387,7 +370,7 @@ static void showData(_Panel * panel)
                if (panel->shortcuts[i])
                        wfree(panel->shortcuts[i]);
                if (str)
-                       panel->shortcuts[i] = trimstr(str);
+                       panel->shortcuts[i] = wtrimspace(str);
                else
                        panel->shortcuts[i] = NULL;
 
@@ -574,7 +557,7 @@ static void storeData(_Panel * panel)
        for (i = 0; i < panel->actionCount; i++) {
                str = NULL;
                if (panel->shortcuts[i]) {
-                       str = trimstr(panel->shortcuts[i]);
+                       str = wtrimspace(panel->shortcuts[i]);
                        if (strlen(str) == 0) {
                                wfree(str);
                                str = NULL;
-- 
1.7.3.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to