On Mon, Dec 22, 2014 at 06:05:48PM +0400, Vadim Zhukov wrote:
> 22 дек. 2014 г. 17:03 пользователь "Vadim Zhukov" <persg...@gmail.com>
> написал:
> >
> > 22 дек. 2014 г. 16:26 пользователь "Alexandr Shadchin" <
> alexandr.shadc...@gmail.com> написал:
> >
> > >
> > > On Mon, Dec 22, 2014 at 04:37:22PM +0400, Vadim Zhukov wrote:
> > > > 22 дек. 2014 г. 15:02 пользователь "Alexandr Shadchin" <
> > > > alexandr.shadc...@gmail.com> написал:
> > > > >
> > > > > On Mon, Dec 22, 2014 at 03:52:39PM +0400, Vadim Zhukov wrote:
> > > > > > 22 дек. 2014 г. 14:40 пользователь "Alexandr Shadchin" <
> > > > > > alexandr.shadc...@gmail.com> написал:
> > > > > > >
> > > > > > > Convert atoi -> strtonum. Plus more detailed error messages.
> > > > > > >
> > > > > > > OK ?
> > > > > > >
> > > > > > > --
> > > > > > > Alexandr Shadchin
> > > > > > >
> > > > > > > Index: wsmoused.c
> > > > > > >
> ===================================================================
> > > > > > > RCS file: /cvs/src/usr.sbin/wsmoused/wsmoused.c,v
> > > > > > > retrieving revision 1.34
> > > > > > > diff -u -p -r1.34 wsmoused.c
> > > > > > > --- wsmoused.c  22 Dec 2014 11:21:49 -0000      1.34
> > > > > > > +++ wsmoused.c  22 Dec 2014 11:29:36 -0000
> > > > > > > @@ -175,14 +175,6 @@ static int p2l[MOUSE_MAXBUTTON] = {
> > > > > > >         MOUSE_BUTTON5,  MOUSE_BUTTON6,  MOUSE_BUTTON7,
> MOUSE_BUTTON8,
> > > > > > >  };
> > > > > > >
> > > > > > > -static char *
> > > > > > > -skipspace(char *s)
> > > > > > > -{
> > > > > > > -       while (isspace((unsigned char)*s))
> > > > > > > -               ++s;
> > > > > > > -       return s;
> > > > > > > -}
> > > > > > > -
> > > > > > >  /* mouse_installmap : install a map between physical and
> logical
> > > > buttons
> > > > > > */
> > > > > > >  static int
> > > > > > >  mouse_installmap(char *arg)
> > > > > > > @@ -190,29 +182,38 @@ mouse_installmap(char *arg)
> > > > > > >         int pbutton;
> > > > > > >         int lbutton;
> > > > > > >         char *s;
> > > > > > > +       const char *errstr;
> > > > > > >
> > > > > > >         while (*arg) {
> > > > > > > -               arg = skipspace(arg);
> > > > > > >                 s = arg;
> > > > > > >                 while (isdigit((unsigned char)*arg))
> > > > > > >                         ++arg;
> > > > > >
> > > > > > So now, if there is some whitespace before digits, arg won't get
> > > > > > incremented, and FALSE may be returned. This is behaviour change,
> is it
> > > > > > intended?
> > > > >
> > > > > No, getopt() eat extra spaces and skipspace() does nothing.
> > > >
> > > > No, getopt(3) doesn't eat spaces, neither when argument its separated
> or
> > > > written next to option letter.
> > > >
> > >
> > > Tests showed that optarg has no leading and trailing whitespace.
> >
> > $ cat g.c
> > #include <sys/types.h>
> > #include <stdio.h>
> > #include <unistd.h>
> > int main(int argc, char **argv){
> > int opt;
> > while ((opt = (vector(argc, argv, "o:"))) != -1)
> 
> getopt instead of vector here, of course, - sorry, I have to retype things
> via phone.
> 
> > printf("o=%sEOF\n", optarg);
> > return 0;
> > }
> > $ make g && ./g -o " 1 "
> > cc -O2 -pipe    -o g g.c
> > o= 1 EOF
> > $
> 

Yes, example is correct, but using quotes we consciously say to preserve spaces.

I do not think that the command - wsmoused -M "  3=1   " -M "   1=3  "
will be useful to someone.

> --
> Vadim Zhukov

-- 
Alexandr Shadchin

Reply via email to