From 69d2e5187613a41b0f883885fb3575a43f7f2226 Mon Sep 17 00:00:00 2001 From: "Carlos R. Mafra" Date: Thu, 19 Jan 2012 01:12:58 +0000 Subject: [PATCH] WPrefs: Remove trimstr() and use wtrimspace() from WINGs There's no need to have a private function while there's one in WINGs. Besides that, it does not remove trailing whitespaces appropriately as I just tested by adding trailing space in the shortcut captured by WPrefs. It is not trimmed before saving it: [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 --- WPrefs.app/KeyboardShortcuts.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c index 1d708545..4ea7fa4c 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; -- 2.11.4.GIT