Rewrite uicb_exec

This commit is contained in:
Julien Danjou 2008-03-14 18:12:33 +01:00
parent 539636c77e
commit 6818a692d2

22
uicb.c
View file

@ -52,7 +52,6 @@ void
uicb_exec(int screen __attribute__ ((unused)), char *cmd) uicb_exec(int screen __attribute__ ((unused)), char *cmd)
{ {
Client *c; Client *c;
int args_pos;
char *args, *path; char *args, *path;
/* remap all clients since some WM won't handle them otherwise */ /* remap all clients since some WM won't handle them otherwise */
@ -61,23 +60,20 @@ uicb_exec(int screen __attribute__ ((unused)), char *cmd)
XSync(globalconf.display, False); XSync(globalconf.display, False);
if(globalconf.display)
close(ConnectionNumber(globalconf.display));
/* Ignore the leading spaces if any */ /* Ignore the leading spaces if any */
for(args_pos = 0; while(cmd[0] && cmd[0] == ' ')
args_pos < a_strlen(cmd) && cmd[args_pos] == ' '; cmd++;
++args_pos);
/* Get the beginning of the arguments */ /* Get the beginning of the arguments */
if((args = strchr(cmd + args_pos, ' ')) == NULL) args = strchr(cmd, ' ');
{
warn("invalid command %s\n", cmd); if(args)
return; path = strndup(cmd, args - cmd);
} else
path = strndup(cmd, a_strlen(cmd));
path = strndup(cmd + args_pos, args - (cmd + args_pos));
execlp(path, cmd, NULL); execlp(path, cmd, NULL);
p_delete(&path); p_delete(&path);
} }