Deleted Added
sdiff udiff text old ( 91737 ) new ( 93345 )
full compact
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 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>
24#include <inttypes.h>
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 *);
174static intmax_t getq(const char *);
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 */
478static intmax_t
479getq(const char *s)
480{
481 char *p;
482 intmax_t r;
483
484 errno = 0;
485 r = strtoimax(s, &p, 10);
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{
506 intmax_t q1, q2;
507
508
509 q1 = getq(s1);
510 q2 = getq(s2);
511
512 if (q1 > q2)
513 return 1;
514

--- 36 unchanged lines hidden ---