mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-07 14:24:14 +01:00
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 <crmafra@gmail.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user