Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Remeta one frame earlier



On Mon, 23 Feb 2015 14:51:09 +0100
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> +	    int remeta;
>  
>  	    if (l < 0) {
>  		zerr("corrupt history file %s", fn);
>  		break;
>  	    }
> +
> +	    /*
> +	     * Handle the special case that we're reading from an
> +	     * old shell with fewer meta characters, so we need to
> +	     * metafy some more.  (It's not clear why the history
> +	     * file is metafied at all; some would say this is plain
> +	     * stupid.  But we're stuck with it now without some
> +	     * hairy workarounds for compatibility).
> +	     *
> +	     * This is rare so doesn't need to be that efficient; just
> +	     * allocate space off the heap.
> +	     */
> +	    for (ptr = pt; *ptr; ptr++) {
> +		if (*ptr == Meta && ptr[1])
> +		    ptr++;
> +		else if (imeta(*ptr)) {
> +		    remeta = 1;
> +		    break;
> +		}
> +	    }
> +	    if (remeta) {
> +		unmetafy(pt, &remeta);
> +		pt = metafy(pt, remeta, META_USEHEAP);
> +	    }
> +

... except you haven't initialised remeta to 0.

If we do stick with the heap, I'm wondering if we need to free it more
often than we do.  Maybe the freeheap() below should be if (uselex ||
remeta), and maybe it should be right at the end of the loop for
safety.

Long discussion for moving a bit of code...

pws



Messages sorted by: Reverse Date, Date, Thread, Author