bug? in getopt(3) + [PATCH] + testcase

2020-03-25 Thread 0xef967c36
To wrap this up and get if off my plate, here is the updated patch, and a testcase program together with what should be (imvho) the correct output. Please do NOT assume that I'm insisting or that I have any personal interest to have this included, considered, etc. The testcase is a stripped down

Re: bug? in getopt(3) / possible [PATCH]

2020-03-17 Thread 0xef967c36
On Tue, Mar 17, 2020 at 02:14:58PM +0100, Martijn van Duren wrote: > Included millert, since he imported this code. > He might shed some more light on what's intended. > > On 3/15/20 11:27 PM, 0xef967...@gmail.com wrote: > > On Sun, Mar 15, 2020 at 07:32:52PM +0100, Martijn van Duren wrote: > >>

Re: bug? in getopt(3) / possible [PATCH]

2020-03-15 Thread 0xef967c36
On Sun, Mar 15, 2020 at 07:32:52PM +0100, Martijn van Duren wrote: > tl;dr new diff below Check with: OPTS=r- ./getopt-test-MvD2 -r- getopt-test-MvD2: unknown option -- - #U- | With the unpatched code, my patch, and the original 44BSD, it's: OPTS=r- ./getopt-test-O -r- {./getopt-test-O} <->

Re: bug? in getopt(3) / possible [PATCH]

2020-03-15 Thread 0xef967c36
On Sun, Mar 15, 2020 at 12:21:02PM +0200, 0xef967...@gmail.com wrote: > On Sun, Mar 15, 2020 at 09:30:22AM +0100, Martijn van Duren wrote: > > > --- lib/libc/stdlib/getopt_long.c~ > > > +++ lib/libc/stdlib/getopt_long.c > > > @@ -418,15 +418,8 @@ > > > } > > > > > > if ((optchar =

Re: bug? in getopt(3) / possible [PATCH]

2020-03-15 Thread 0xef967c36
On Sun, Mar 15, 2020 at 12:21:02PM +0200, 0xef967...@gmail.com wrote: > Notice that OpenBSD's getopt(3) explicitly allows to use "-" as an > option character, and there may be a /separate/ bug related to that, > but my patch doesn't change or affect it in any way. In case it's not clear what I'm

Re: bug? in getopt(3) / possible [PATCH]

2020-03-15 Thread 0xef967c36
On Sun, Mar 15, 2020 at 09:30:22AM +0100, Martijn van Duren wrote: > > --- lib/libc/stdlib/getopt_long.c~ > > +++ lib/libc/stdlib/getopt_long.c > > @@ -418,15 +418,8 @@ > > } > > > > if ((optchar = (int)*place++) == (int)':' || > > - (optchar == (int)'-' && *place != '\0') || > > -

bug? in getopt(3) / possible [PATCH]

2020-03-11 Thread 0xef967c36
$ cat > opts.c <<'EOT' && cc -Wall -W opts.c -o opts #include #include int main(int ac, char **av){ int c, i; while((c = getopt(ac, av, "q")) != -1) if(c != '?' && c != ':') printf("OPT %c\n", c); for(i = optind; i < ac; i++) printf("%s\n", av[i]); } EOT