Deleted Added
full compact
test.c (91737) test.c (93345)
1/* $NetBSD: test.c,v 1.21 1999/04/05 09:48:38 kleink Exp $ */
2
3/*
4 * test(1); version 7-like -- author Erik Baalbergen
5 * modified by Eric Gisin to be used as built-in.
6 * modified by Arnold Robbins to add SVR3 compatibility
7 * (-x -c -b -p -u -g -k) plus Korn's -L -nt -ot -ef and new -S (socket).
8 * modified by J.T. Conklin for NetBSD.
9 *
10 * This program is in the Public Domain.
11 */
12
13#ifndef lint
14static const char rcsid[] =
1/* $NetBSD: test.c,v 1.21 1999/04/05 09:48:38 kleink Exp $ */
2
3/*
4 * test(1); version 7-like -- author Erik Baalbergen
5 * modified by Eric Gisin to be used as built-in.
6 * modified by Arnold Robbins to add SVR3 compatibility
7 * (-x -c -b -p -u -g -k) plus Korn's -L -nt -ot -ef and new -S (socket).
8 * modified by J.T. Conklin for NetBSD.
9 *
10 * This program is in the Public Domain.
11 */
12
13#ifndef lint
14static const char rcsid[] =
15 "$FreeBSD: head/bin/test/test.c 91737 2002-03-06 11:20:13Z maxim $";
15 "$FreeBSD: head/bin/test/test.c 93345 2002-03-28 16:30:42Z ache $";
16#endif /* not lint */
17
18#include <sys/types.h>
19#include <sys/stat.h>
20
21#include <ctype.h>
22#include <err.h>
23#include <errno.h>
16#endif /* not lint */
17
18#include <sys/types.h>
19#include <sys/stat.h>
20
21#include <ctype.h>
22#include <err.h>
23#include <errno.h>
24#include <inttypes.h>
24#include <limits.h>
25#include <stdarg.h>
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29#include <unistd.h>
30
31#ifdef SHELL

--- 133 unchanged lines hidden (view full) ---

165struct t_op const *t_wp_op;
166char **t_wp;
167
168static int aexpr(enum token);
169static int binop(void);
170static int equalf(const char *, const char *);
171static int filstat(char *, enum token);
172static int getn(const char *);
25#include <limits.h>
26#include <stdarg.h>
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <unistd.h>
31
32#ifdef SHELL

--- 133 unchanged lines hidden (view full) ---

166struct t_op const *t_wp_op;
167char **t_wp;
168
169static int aexpr(enum token);
170static int binop(void);
171static int equalf(const char *, const char *);
172static int filstat(char *, enum token);
173static int getn(const char *);
173static long long getq(const char *);
174static intmax_t getq(const char *);
174static int intcmp(const char *, const char *);
175static int isoperand(void);
176static int newerf(const char *, const char *);
177static int nexpr(enum token);
178static int oexpr(enum token);
179static int olderf(const char *, const char *);
180static int primary(enum token);
181static void syntax(const char *, const char *);

--- 287 unchanged lines hidden (view full) ---

469
470 if (*p)
471 error("%s: bad number", s);
472
473 return (int) r;
474}
475
476/* atoi with error detection and 64 bit range */
175static int intcmp(const char *, const char *);
176static int isoperand(void);
177static int newerf(const char *, const char *);
178static int nexpr(enum token);
179static int oexpr(enum token);
180static int olderf(const char *, const char *);
181static int primary(enum token);
182static void syntax(const char *, const char *);

--- 287 unchanged lines hidden (view full) ---

470
471 if (*p)
472 error("%s: bad number", s);
473
474 return (int) r;
475}
476
477/* atoi with error detection and 64 bit range */
477static long long
478static intmax_t
478getq(const char *s)
479{
480 char *p;
479getq(const char *s)
480{
481 char *p;
481 long long r;
482 intmax_t r;
482
483 errno = 0;
483
484 errno = 0;
484 r = strtoll(s, &p, 10);
485 r = strtoimax(s, &p, 10);
485
486 if (s == p)
487 error("%s: bad number", s);
488
489 if (errno != 0)
490 error((errno == EINVAL) ? "%s: bad number" :
491 "%s: out of range", s);
492

--- 4 unchanged lines hidden (view full) ---

497 error("%s: bad number", s);
498
499 return r;
500}
501
502static int
503intcmp (const char *s1, const char *s2)
504{
486
487 if (s == p)
488 error("%s: bad number", s);
489
490 if (errno != 0)
491 error((errno == EINVAL) ? "%s: bad number" :
492 "%s: out of range", s);
493

--- 4 unchanged lines hidden (view full) ---

498 error("%s: bad number", s);
499
500 return r;
501}
502
503static int
504intcmp (const char *s1, const char *s2)
505{
505 long long q1, q2;
506 intmax_t q1, q2;
506
507
508 q1 = getq(s1);
509 q2 = getq(s2);
510
511 if (q1 > q2)
512 return 1;
513

--- 36 unchanged lines hidden ---
507
508
509 q1 = getq(s1);
510 q2 = getq(s2);
511
512 if (q1 > q2)
513 return 1;
514

--- 36 unchanged lines hidden ---