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 91737 2002-03-06 11:20:13Z maxim $";
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 <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 *);
173static long long 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 */
477static long long
478getq(const char *s)
479{
480 char *p;
481 long long r;
482
483 errno = 0;
484 r = strtoll(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{
505 long long 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 ---