Date: 06 Jul 2000 02:03:48 +0200 From: Cyrille Lefevre <clefevre@no-spam.citeweb.net> To: Stefan Esser <se@FreeBSD.ORG> Cc: freebsd-arch@FreeBSD.ORG Subject: Re: [Patch] make test,expr,printf support 64bit integers Message-ID: <zonwi0pn.fsf@pc166.gits.fr> In-Reply-To: Stefan Esser's message of "Tue, 4 Jul 2000 12:23:45 %2B0200" References: <20000703184219.A7587@StefanEsser.FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Stefan Esser <se@FreeBSD.ORG> writes: > Index: /usr/src/usr.bin/printf/printf.c > =================================================================== > RCS file: /usr/cvs/src/usr.bin/printf/printf.c,v > retrieving revision 1.13 > diff -u -2 -r1.13 printf.c > --- /usr/src/usr.bin/printf/printf.c 2000/04/20 09:31:54 1.13 > +++ /usr/src/usr.bin/printf/printf.c 2000/07/03 16:21:25 > @@ -87,5 +87,5 @@ > static double getdouble __P((void)); > static int getint __P((int *)); > -static int getlong __P((long *)); > +static int getlong __P((quad_t *)); ^^^^^^^ getquad > static char *getstr __P((void)); > static char *mklong __P((char *, int)); > @@ -215,5 +215,5 @@ > } > case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': { > - long p; > + quad_t p; > char *f; > > @@ -250,6 +250,9 @@ > > len = strlen(str) + 2; > + if (len > sizeof copy) > + return NULL; > + > memmove(copy, str, len - 3); > - copy[len - 3] = 'l'; > + copy[len - 3] = 'q'; > copy[len - 2] = ch; > copy[len - 1] = '\0'; > @@ -339,13 +342,13 @@ > int *ip; > { > - long val; > + quad_t val; > > if (getlong(&val)) ^^^^^^^ getquad > return (1); > - if (val > INT_MAX) { > + if (val < INT_MIN || val > INT_MAX) { > warnx3("%s: %s", *gargv, strerror(ERANGE)); > return (1); > } > - *ip = val; > + *ip = (int)val; > return (0); > } > @@ -353,7 +356,7 @@ > static int > getlong(lp) > - long *lp; > + quad_t *lp; > { > - long val; > + quad_t val; > char *ep; > > @@ -364,5 +367,5 @@ > if (strchr(Number, **gargv)) { > errno = 0; > - val = strtol(*gargv, &ep, 0); > + val = strtoq(*gargv, &ep, 0); > if (*ep != '\0') { > warnx2("%s: illegal number", *gargv, NULL); > @@ -370,9 +373,9 @@ > } > if (errno == ERANGE) > - if (val == LONG_MAX) { > + if (val == QUAD_MAX) { > warnx3("%s: %s", *gargv, strerror(ERANGE)); > return (1); > } > - if (val == LONG_MIN) { > + if (val == QUAD_MIN) { > warnx3("%s: %s", *gargv, strerror(ERANGE)); > return (1); IMHO, be consistent w/ naming convention (getlong -> getquad). Regards, Cyrille. -- home:mailto:clefevre@no-spam.citeweb.net Supprimer "no-spam." pour me repondre. work:mailto:Cyrille.Lefevre@no-spam.edf.fr Remove "no-spam." to answer me back. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?zonwi0pn.fsf>