zsh-workers
 help / color / mirror / code / Atom feed
From: Bernd Eggink <eggink@uni-hamburg.de>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@math.gatech.edu>
Subject: Re: PATCH: 3.1.4: getopts
Date: Wed, 07 Oct 1998 09:53:28 +0200	[thread overview]
Message-ID: <361B1DF8.4F4833A5@rrz.uni-hamburg.de> (raw)
In-Reply-To: <981006204350.ZM9969@candle.brasslantern.com>

Bart Schaefer wrote:
> 
> 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;
> 


Yes, looks OK.

Bernd

--
Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg
eggink@rrz.uni-hamburg.de
http://www.rrz.uni-hamburg.de/eggink/BEggink.html


  parent reply	other threads:[~1998-10-07  8:00 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   ` PATCH: 3.1.4: getopts Bart Schaefer
1998-10-07  7:39     ` Peter Stephenson
1998-10-07  7:53     ` Bernd Eggink [this message]
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=361B1DF8.4F4833A5@rrz.uni-hamburg.de \
    --to=eggink@uni-hamburg.de \
    --cc=schaefer@brasslantern.com \
    --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).