From: Christophe CURIS <[email protected]>

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 <[email protected]>
---
 util/wmgenmenu.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/util/wmgenmenu.c b/util/wmgenmenu.c
index 95c20e5..21010f1 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 -> <category> -> 
<application> */
                                L3Menu = WMCreatePLArray(
                                        WMCreatePLString(_(list[i][0])),
-- 
2.0.0


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

Reply via email to