From owner-freebsd-arch Wed Jul 5 17: 3:59 2000 Delivered-To: freebsd-arch@freebsd.org Received: from camus.cybercable.fr (camus.cybercable.fr [212.198.0.200]) by hub.freebsd.org (Postfix) with SMTP id EFCEE37B901 for ; Wed, 5 Jul 2000 17:03:51 -0700 (PDT) (envelope-from root@gits.dyndns.org) Received: (qmail 8984221 invoked from network); 6 Jul 2000 00:03:49 -0000 Received: from r224m65.cybercable.tm.fr (HELO gits.dyndns.org) ([195.132.224.65]) (envelope-sender ) by camus.cybercable.fr (qmail-ldap-1.03) with SMTP for ; 6 Jul 2000 00:03:49 -0000 Received: (from root@localhost) by gits.dyndns.org (8.9.3/8.9.3) id CAA13316; Thu, 6 Jul 2000 02:03:48 +0200 (CEST) (envelope-from root) Posted-Date: Thu, 6 Jul 2000 02:03:48 +0200 (CEST) To: Stefan Esser Cc: freebsd-arch@FreeBSD.ORG Subject: Re: [Patch] make test,expr,printf support 64bit integers References: <20000703184219.A7587@StefanEsser.FreeBSD.org> Reply-To: clefevre@citeweb.net X-Face: V|+c;4!|B?E%BE^{E6);aI.[<97Zd*>^#%Y5Cxv;%Y[PT-LW3;A:fRrJ8+^k"e7@+30g0YD0*^^3jgyShN7o?a]C la*Zv'5NA,=963bM%J^o]C From: Cyrille Lefevre Date: 06 Jul 2000 02:03:48 +0200 In-Reply-To: Stefan Esser's message of "Tue, 4 Jul 2000 12:23:45 +0200" Message-ID: Lines: 91 X-Mailer: Gnus v5.6.45/XEmacs 21.1 - "Canyonlands" Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Stefan Esser 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