dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jilles Tjoelker <jilles@stack.nl>
To: Kylie McClain <somasissounds@gmail.com>
Cc: dash@vger.kernel.org, Kylie McClain <somasis@exherbo.org>
Subject: Re: [PATCH 2/2] histedit: Remove non-glibc fallback code
Date: Mon, 8 Aug 2016 17:50:11 +0200	[thread overview]
Message-ID: <20160808155011.GA29197@stack.nl> (raw)
In-Reply-To: <20160804155908.GA94936@stack.nl>

On Thu, Aug 04, 2016 at 05:59:08PM +0200, Jilles Tjoelker wrote:
> >From 23da600dcff616662a93f307420d9142598e2cae Mon Sep 17 00:00:00 2001
> From: Jilles Tjoelker <jilles@stack.nl>
> Date: Thu, 4 Aug 2016 17:51:12 +0200
> Subject: [PATCH 1/2] [HISTEDIT] Stop depending on getopt reset feature.

> Instead, use our own nextopt() function.
> ---
>  src/histedit.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/src/histedit.c b/src/histedit.c
> index 94465d7..ec45065 100644
> --- a/src/histedit.c
> +++ b/src/histedit.c
> @@ -214,13 +214,8 @@ histcmd(int argc, char **argv)
>  	if (argc == 1)
>  		sh_error("missing history argument");
>  
> -#ifdef __GLIBC__
> -	optind = 0;
> -#else
> -	optreset = 1; optind = 1; /* initialize getopt */
> -#endif
>  	while (not_fcnumber(argv[optind]) &&
> -	      (ch = getopt(argc, argv, ":e:lnrs")) != -1)
> +	      (ch = nextopt(":e:lnrs")) != '\0')
>  		switch ((char)ch) {
>  		case 'e':
>  			editor = optionarg;

This is clearly wrong; not_fcnumber() should be passed *argptr instead
of something bogus depending on optind.

The fixed version is what FreeBSD sh has as of SVN r240541 but I have
not tested it in dash.

In any case, a side effect of this change is a small code size
reduction.

-- 
Jilles Tjoelker

  reply	other threads:[~2016-08-08 15:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  5:54 [PATCH 1/2] mkbuiltins: Use a `while` loop rather than `nl` Kylie McClain
2016-08-04  5:54 ` [PATCH 2/2] histedit: Remove non-glibc fallback code Kylie McClain
2016-08-04 15:59   ` Jilles Tjoelker
2016-08-08 15:50     ` Jilles Tjoelker [this message]
2016-08-04 17:17 ` [PATCH 1/2] mkbuiltins: Use a `while` loop rather than `nl` Harald van Dijk
2016-08-06  9:02   ` Seb
2016-08-07 10:17     ` Seb
2016-08-06 16:51   ` Harald van Dijk
2016-08-08 15:33   ` Herbert Xu

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=20160808155011.GA29197@stack.nl \
    --to=jilles@stack.nl \
    --cc=dash@vger.kernel.org \
    --cc=somasis@exherbo.org \
    --cc=somasissounds@gmail.com \
    --subject='Re: [PATCH 2/2] histedit: Remove non-glibc fallback code' \
    /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

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).