1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-21 05:18:06 +01:00

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 <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-07-04 23:28:47 +02:00
committed by Carlos R. Mafra
parent f90df24915
commit b75ac967d9

View File

@@ -424,9 +424,16 @@ static void find_and_write(const char *group, char *list[][2], int this_is_termi
/* delete character " !" from the command */ /* delete character " !" from the command */
ptr = strchr(comm, '!'); ptr = strchr(comm, '!');
while (ptr >= comm && (*ptr == '!' || isspace(*ptr))) if (ptr != NULL) {
*ptr-- = '\0'; while (ptr > comm) {
if (!isspace(ptr[-1]))
break;
ptr--;
}
*ptr = '\0';
}
snprintf(buf, sizeof(buf), "%s -e %s", terminal ? terminal : "xterm" , comm); snprintf(buf, sizeof(buf), "%s -e %s", terminal ? terminal : "xterm" , comm);
/* Root -> Applications -> <category> -> <application> */ /* Root -> Applications -> <category> -> <application> */
L3Menu = WMCreatePLArray( L3Menu = WMCreatePLArray(
WMCreatePLString(_(list[i][0])), WMCreatePLString(_(list[i][0])),