zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Peter Stephenson <pws@ibmth.df.unipi.it>,
	zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Re: PATCH: 3.1.4: getopts
Date: Tue, 6 Oct 1998 20:43:49 -0700	[thread overview]
Message-ID: <981006204350.ZM9969@candle.brasslantern.com> (raw)
In-Reply-To: <9810061245.AA28058@ibmth.df.unipi.it>

On Oct 6,  2:45pm, Peter Stephenson wrote:
} Subject: Re: PATCH: 3.1.4: getopts: forget it.
}
} I spoke too soon.  Bernd's patch that I referred to does fix the
} problem, only more simply, so use that.  It needs merging by hand.

Is the following the correct merge?

Index: Src/builtin.c
===================================================================
*** builtin.c	1998/09/16 15:35:52	1.2
--- builtin.c	1998/10/07 03:37:08
***************
*** 2546,2552 ****
      char *optstr = unmetafy(*argv++, &lenoptstr), *var = *argv++;
      char **args = (*argv) ? argv : pparams;
      static int optcind = 0;
!     char *str, optbuf[2], *p, opch;
  
      /* zoptind keeps count of the current argument number.  The *
       * user can set it to zero to start a new option parse.     */
--- 2546,2552 ----
      char *optstr = unmetafy(*argv++, &lenoptstr), *var = *argv++;
      char **args = (*argv) ? argv : pparams;
      static int optcind = 0;
!     char *str, optbuf[2] = " ", *p, opch;
  
      /* zoptind keeps count of the current argument number.  The *
       * user can set it to zero to start a new option parse.     */
***************
*** 2567,2576 ****
      /* find place in relevant argument */
      str = unmetafy(dupstring(args[zoptind - 1]), &lenstr);
      if(optcind >= lenstr) {
  	if(!args[zoptind++])
  	    return 1;
  	str = unmetafy(dupstring(args[zoptind - 1]), &lenstr);
- 	optcind = 0;
      }
      if(!optcind) {
  	if(lenstr < 2 || (*str != '-' && *str != '+'))
--- 2567,2576 ----
      /* find place in relevant argument */
      str = unmetafy(dupstring(args[zoptind - 1]), &lenstr);
      if(optcind >= lenstr) {
+ 	optcind = 0;
  	if(!args[zoptind++])
  	    return 1;
  	str = unmetafy(dupstring(args[zoptind - 1]), &lenstr);
      }
      if(!optcind) {
  	if(lenstr < 2 || (*str != '-' && *str != '+'))
***************
*** 2593,2605 ****
      if(opch == ':' || !(p = memchr(optstr, opch, lenoptstr))) {
  	p = "?";
  err:
  	if(quiet) {
  	    setsparam(var, ztrdup(p));
- 	    zsfree(zoptarg);
  	    zoptarg = metafy(optbuf, lenoptbuf, META_DUP);
  	} else {
  	    zerr(*p == '?' ? "bad option: -%c" :
  		"argument expected after -%c option", NULL, opch);
  	    errflag = 0;
  	}
  	return 0;
--- 2593,2606 ----
      if(opch == ':' || !(p = memchr(optstr, opch, lenoptstr))) {
  	p = "?";
  err:
+       zsfree(zoptarg);
  	if(quiet) {
  	    setsparam(var, ztrdup(p));
  	    zoptarg = metafy(optbuf, lenoptbuf, META_DUP);
  	} else {
  	    zerr(*p == '?' ? "bad option: -%c" :
  		"argument expected after -%c option", NULL, opch);
+           zoptarg=ztrdup("");
  	    errflag = 0;
  	}
  	return 0;

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1998-10-07  3:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-06 12:18 PATCH: 3.1.4: getopts not reset properly for new function Peter Stephenson
1998-10-06 12:45 ` PATCH: 3.1.4: getopts: forget it Peter Stephenson
1998-10-07  3:43   ` Bart Schaefer [this message]
1998-10-07  7:39     ` PATCH: 3.1.4: getopts Peter Stephenson
1998-10-07  7:53     ` Bernd Eggink
1998-10-06 14:44 ` mla referencing (Was: PATCH: 3.1.4: getopts not reset properly for new function) Geoff Wing

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=981006204350.ZM9969@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=pws@ibmth.df.unipi.it \
    --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).