zsh-workers
 help / color / mirror / code / Atom feed
* The -~ bug
@ 2016-12-03  0:37 Bart Schaefer
  2016-12-03 19:57 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2016-12-03  0:37 UTC (permalink / raw)
  To: zsh-workers

The problem is that '-' is still tokenized as Dash on entry to filesubstr()
in subst.c.

This is going to break zstrtol() as well, for e.g. ~-3 counting backwards
in the stack, which is done very early before the rest of the filename has
been examined.

But we don't want to untokenize the entire file name; tokens like Brack
and Equals are still important.

Is it safe to do the following, which changes the string passed in via
*namptr?  Or is it necessary to dupstring()?

diff --git a/Src/subst.c b/Src/subst.c
index 06d2c9e..64b4400 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -650,6 +650,8 @@ filesubstr(char **namptr, int assign)
 	char *ptr, *tmp, *res, *ptr2;
 	int val;
 
+	if (str[1] == Dash)
+	    str[1] = '-';
 	val = zstrtol(str + 1, &ptr, 10);
 	if (isend(str[1])) {   /* ~ */
 	    *namptr = dyncat(home ? home : "", str + 1);


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: The -~ bug
  2016-12-03  0:37 The -~ bug Bart Schaefer
@ 2016-12-03 19:57 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2016-12-03 19:57 UTC (permalink / raw)
  To: zsh-workers

On Fri, 2 Dec 2016 16:37:30 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> Is it safe to do the following, which changes the string passed in via
> *namptr?  Or is it necessary to dupstring()?

Thanks, I think that's fine --- this always (unless there's a path I've
forgotten about) comes from parsed command line argument which are all
off the heap.

pws


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-03 19:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-03  0:37 The -~ bug Bart Schaefer
2016-12-03 19:57 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).