seq.c (204107) | seq.c (215034) |
---|---|
1/* $NetBSD: seq.c,v 1.5 2008/07/21 14:19:26 lukem Exp $ */ 2/* 3 * Copyright (c) 2005 The NetBSD Foundation, Inc. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Brian Ginsbach. 8 * --- 15 unchanged lines hidden (view full) --- 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> | 1/* $NetBSD: seq.c,v 1.5 2008/07/21 14:19:26 lukem Exp $ */ 2/* 3 * Copyright (c) 2005 The NetBSD Foundation, Inc. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Brian Ginsbach. 8 * --- 15 unchanged lines hidden (view full) --- 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/usr.bin/seq/seq.c 204107 2010-02-20 01:23:15Z delphij $"); | 32__FBSDID("$FreeBSD: head/usr.bin/seq/seq.c 215034 2010-11-09 10:59:09Z brucec $"); |
33 34#include <ctype.h> 35#include <err.h> 36#include <errno.h> 37#include <math.h> 38#include <locale.h> 39#include <stdio.h> 40#include <stdlib.h> --- 205 unchanged lines hidden (view full) --- 246 break; 247 } 248 /* valid conversions */ 249 if (strchr("eEfgG", *fmt) && 250 conversions++ < 1) { 251 fmt++; 252 break; 253 } | 33 34#include <ctype.h> 35#include <err.h> 36#include <errno.h> 37#include <math.h> 38#include <locale.h> 39#include <stdio.h> 40#include <stdlib.h> --- 205 unchanged lines hidden (view full) --- 246 break; 247 } 248 /* valid conversions */ 249 if (strchr("eEfgG", *fmt) && 250 conversions++ < 1) { 251 fmt++; 252 break; 253 } |
254 /* flags, width and precsision */ | 254 /* flags, width and precision */ |
255 if (isdigit((unsigned char)*fmt) || 256 strchr("+- 0#.", *fmt)) 257 continue; 258 259 /* oops! bad conversion format! */ 260 return (0); 261 } while (*fmt != '\0'); 262 } --- 61 unchanged lines hidden (view full) --- 324 ISODIGIT((unsigned char)*cp) && i < 3; 325 i++, cp++) { 326 c <<= 3; 327 c |= (*cp - '0'); 328 } 329 *orig = c; 330 --cp; 331 continue; | 255 if (isdigit((unsigned char)*fmt) || 256 strchr("+- 0#.", *fmt)) 257 continue; 258 259 /* oops! bad conversion format! */ 260 return (0); 261 } while (*fmt != '\0'); 262 } --- 61 unchanged lines hidden (view full) --- 324 ISODIGIT((unsigned char)*cp) && i < 3; 325 i++, cp++) { 326 c <<= 3; 327 c |= (*cp - '0'); 328 } 329 *orig = c; 330 --cp; 331 continue; |
332 case 'x': /* hexidecimal number */ | 332 case 'x': /* hexadecimal number */ |
333 cp++; /* skip 'x' */ 334 for (i = 0, c = 0; 335 isxdigit((unsigned char)*cp) && i < 2; 336 i++, cp++) { 337 c <<= 4; 338 if (isdigit((unsigned char)*cp)) 339 c |= (*cp - '0'); 340 else --- 56 unchanged lines hidden (view full) --- 397 places++; 398 } 399 return (places); 400} 401 402/* 403 * generate_format - create a format string 404 * | 333 cp++; /* skip 'x' */ 334 for (i = 0, c = 0; 335 isxdigit((unsigned char)*cp) && i < 2; 336 i++, cp++) { 337 c <<= 4; 338 if (isdigit((unsigned char)*cp)) 339 c |= (*cp - '0'); 340 else --- 56 unchanged lines hidden (view full) --- 397 places++; 398 } 399 return (places); 400} 401 402/* 403 * generate_format - create a format string 404 * |
405 * XXX to be bug for bug compatable with Plan9 and GNU return "%g" | 405 * XXX to be bug for bug compatible with Plan9 and GNU return "%g" |
406 * when "%g" prints as "%e" (this way no width adjustments are made) 407 */ 408char * 409generate_format(double first, double incr, double last, int equalize, char pad) 410{ 411 static char buf[256]; 412 char cc = '\0'; 413 int precision, width1, width2, places; --- 40 unchanged lines hidden --- | 406 * when "%g" prints as "%e" (this way no width adjustments are made) 407 */ 408char * 409generate_format(double first, double incr, double last, int equalize, char pad) 410{ 411 static char buf[256]; 412 char cc = '\0'; 413 int precision, width1, width2, places; --- 40 unchanged lines hidden --- |