zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <zefram@dcs.warwick.ac.uk>
To: zsh-workers@math.gatech.edu
Subject: Re: 3 bugs for zsh3.0.0
Date: Mon, 17 Mar 1997 18:18:51 GMT	[thread overview]
Message-ID: <5269.199703171818@stone.dcs.warwick.ac.uk> (raw)

-----BEGIN PGP SIGNED MESSAGE-----

>2) bus error on:
>local undefined
>echo ${undefined#crap}

The parameter code, when asked for the value of an undefined parameter,
is returning a constant empty string.  The glob code assumes that it can
write into any parameter value.  The real solution would be to stop the
glob code writing into strings that it shouldn't modify, and I'd like
to do this as part of making zsh const-correct.  But for the moment it
will suffice to make the parameter code return an allocated empty string,
as it already does in some cases.

 -zefram

      *** Src/params.c	1997/03/17 00:38:10	1.36
      --- Src/params.c	1997/03/17 13:16:13
      ***************
      *** 677,685 ****
            char *s, **ss;
            static char buf[(SIZEOF_LONG * 8) + 4];
        
      -     if (!v)
      - 	return "";
            HEAPALLOC {
        	if (v->inv) {
        	    sprintf(buf, "%d", v->a);
        	    s = dupstring(buf);
      --- 677,685 ----
            char *s, **ss;
            static char buf[(SIZEOF_LONG * 8) + 4];
        
            HEAPALLOC {
      + 	if (!v)
      + 	    return dupstring("");
        	if (v->inv) {
        	    sprintf(buf, "%d", v->a);
        	    s = dupstring(buf);
      ***************
      *** 694,700 ****
        		ss = v->pm->gets.afn(v->pm);
        		if (v->a < 0)
        		    v->a += arrlen(ss);
      ! 		s = (v->a >= arrlen(ss) || v->a < 0) ? "" : ss[v->a];
        	    }
        	    LASTALLOC_RETURN s;
        	case PM_INTEGER:
      --- 694,700 ----
        		ss = v->pm->gets.afn(v->pm);
        		if (v->a < 0)
        		    v->a += arrlen(ss);
      ! 		s = (v->a >= arrlen(ss) || v->a < 0) ? dupstring("") : ss[v->a];
        	    }
        	    LASTALLOC_RETURN s;
        	case PM_INTEGER:
      ***************
      *** 1188,1194 ****
        char *
        strgetfn(Param pm)
        {
      !     return pm->u.str ? pm->u.str : "";
        }
        
        /* Function to set value of a scalar (string) parameter */
      --- 1188,1194 ----
        char *
        strgetfn(Param pm)
        {
      !     return pm->u.str ? pm->u.str : hcalloc(1);
        }
        
        /* Function to set value of a scalar (string) parameter */
      ***************
      *** 1314,1320 ****
            char *s = *((char **)pm->data);
        
            if (!s)
      ! 	return "";
            return s;
        }
        
      --- 1314,1320 ----
            char *s = *((char **)pm->data);
        
            if (!s)
      ! 	return hcalloc(1);
            return s;
        }
        

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: ascii

iQCVAwUBMy1FZXD/+HJTpU/hAQE5kQP/aYmYQVr7bUhFhdjissNyzeFn1Bb6DpYG
Hs7X+VpQut8RkqoKXhe9Dqy3DW2xr1DhW9anNhOHkYf5Aqo0KhlNuB1stPrpi/tT
4pLIjxZUuGhQv3XShafyaxJoxGwWSnfXgBNa47zNVvsJAfMGs7UD+FR0KBAc7PXl
uPehnmaqnHg=
=ooJu
-----END PGP SIGNATURE-----


             reply	other threads:[~1997-03-17 18:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-17 18:18 Zefram [this message]
  -- strict thread matches above, loose matches on Subject: below --
1997-03-07 19:46 Huy Le
1997-03-10 10:22 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5269.199703171818@stone.dcs.warwick.ac.uk \
    --to=zefram@dcs.warwick.ac.uk \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).