From b75ac967d9d880c59e2f5316f69373f5b12ee12e Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Fri, 4 Jul 2014 23:28:47 +0200 Subject: [PATCH] util: clarify a bit of the code for parsing commands in wmgenmenu When a command is given for a menu to be run through a terminal, there is a piece of code that removes everything from a '!' to the end of the line. The original code was too dense and not really optimal, so this patch proposes a more explicit code, mainly for maintainability. Signed-off-by: Christophe CURIS --- util/wmgenmenu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/util/wmgenmenu.c b/util/wmgenmenu.c index 95c20e5c..21010f1e 100644 --- a/util/wmgenmenu.c +++ b/util/wmgenmenu.c @@ -424,9 +424,16 @@ static void find_and_write(const char *group, char *list[][2], int this_is_termi /* delete character " !" from the command */ ptr = strchr(comm, '!'); - while (ptr >= comm && (*ptr == '!' || isspace(*ptr))) - *ptr-- = '\0'; + if (ptr != NULL) { + while (ptr > comm) { + if (!isspace(ptr[-1])) + break; + ptr--; + } + *ptr = '\0'; + } snprintf(buf, sizeof(buf), "%s -e %s", terminal ? terminal : "xterm" , comm); + /* Root -> Applications -> -> */ L3Menu = WMCreatePLArray( WMCreatePLString(_(list[i][0])), -- 2.11.4.GIT