diff options
author | Igor Böhm <igor@9lab.org> | 2022-02-09 00:11:44 +0000 |
---|---|---|
committer | Igor Böhm <igor@9lab.org> | 2022-02-09 00:11:44 +0000 |
commit | 876907a5306fc8c41536403185e3cafa23a2c7ed (patch) | |
tree | 61b72ae428002c919bb0d4e8d491c641cb5fb193 /sys | |
parent | 4ab2d149d46c6762c9b8d9fd24d0bf92b10704f6 (diff) |
rio: fix parsing of directory path (-cd) when creating a new window via wctl
Before applying this patch the following will fail to open ed
in the '/tmp/s p a c e' folder:
<snip>
% mkdir '/tmp/s p a c e'
% window -cd '/tmp/s p a c e' ed
!pwd
/tmp/s p a c e
!
q
<snap>
After applying the patch the above sequence works as expected,
opening ed in the '/tmp/s p a c e' folder, printing the present
working directory, and quitting ed.
The root cause was a faulty computation of the pointer `s`,
being off by one, leading to any arguments after the
directory path to be skipped.
This regression was introduced in revision:
• 614f1d6268fd986fc628eec3754bd4599363ad13
Thanks umbraticus for finding and reporting the issue.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/src/cmd/rio/wctl.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/sys/src/cmd/rio/wctl.c b/sys/src/cmd/rio/wctl.c index 7a3762646..eeb2a5fec 100644 --- a/sys/src/cmd/rio/wctl.c +++ b/sys/src/cmd/rio/wctl.c @@ -202,7 +202,7 @@ riostrtol(char *s, char **t) int parsewctl(char **argp, Rectangle r, Rectangle *rp, int *pidp, int *idp, int *hiddenp, int *scrollingp, char **cdp, char *s, char *err) { - int cmd, param, xy, sign; + int cmd, n, nt, param, xy, sign; char *f[2], *t; *pidp = 0; @@ -252,13 +252,12 @@ parsewctl(char **argp, Rectangle r, Rectangle *rp, int *pidp, int *idp, int *hid s++; if(param == Cd){ *cdp = s; - gettokens(*cdp, f, nelem(f), " \t\r\n\v\f"); - s += strlen(*cdp); - if((*cdp)[0] == '\'' && s[-1] == '\''){ - /* drop quotes */ - *cdp += 1; - s[-1] = '\0'; - } + if((nt = gettokens(*cdp, f, nelem(f), " \t\r\n\v\f")) < 1) + return -1; + n = strlen(*cdp); + if((*cdp)[0] == '\'' && (*cdp)[n-1] == '\'') + ((*cdp)++)[n-1] = '\0'; /* drop quotes */ + s += n+(nt-1); continue; } sign = 0; |