joachim99@52
|
1 /* System dependent declarations.
|
joachim99@52
|
2
|
joachim99@52
|
3 Modified for KDiff3 by Joachim Eibl 2003.
|
joachim99@52
|
4
|
joachim99@52
|
5 Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002
|
joachim99@52
|
6 Free Software Foundation, Inc.
|
joachim99@52
|
7
|
joachim99@52
|
8 This file is part of GNU DIFF.
|
joachim99@52
|
9
|
joachim99@52
|
10 GNU DIFF is free software; you can redistribute it and/or modify
|
joachim99@52
|
11 it under the terms of the GNU General Public License as published by
|
joachim99@52
|
12 the Free Software Foundation; either version 2, or (at your option)
|
joachim99@52
|
13 any later version.
|
joachim99@52
|
14
|
joachim99@52
|
15 GNU DIFF is distributed in the hope that it will be useful,
|
joachim99@52
|
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
joachim99@52
|
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
joachim99@52
|
18 GNU General Public License for more details.
|
joachim99@52
|
19
|
joachim99@52
|
20 You should have received a copy of the GNU General Public License
|
joachim99@52
|
21 along with this program; see the file COPYING.
|
joachim99@52
|
22 If not, write to the Free Software Foundation,
|
joachim99@52
|
23 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
joachim99@52
|
24
|
joachim99@52
|
25 //#include <config.h>
|
joachim99@52
|
26
|
joachim99@52
|
27 /* Don't bother to support K&R C compilers any more; it's not worth
|
joachim99@52
|
28 the trouble. These macros prevent some library modules from being
|
joachim99@52
|
29 compiled in K&R C mode. */
|
joachim99@52
|
30 #define PARAMS(Args) Args
|
joachim99@52
|
31 #define PROTOTYPES 1
|
joachim99@52
|
32
|
joachim99@52
|
33 /* Define `__attribute__' and `volatile' first
|
joachim99@52
|
34 so that they're used consistently in all system includes. */
|
joachim99@52
|
35 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__
|
joachim99@52
|
36 # define __attribute__(x)
|
joachim99@52
|
37 #endif
|
joachim99@52
|
38 #if defined const && !defined volatile
|
joachim99@52
|
39 # define volatile
|
joachim99@52
|
40 #endif
|
joachim99@52
|
41
|
joachim99@52
|
42 /* Verify a requirement at compile-time (unlike assert, which is runtime). */
|
joachim99@52
|
43 #define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
|
joachim99@52
|
44
|
joachim99@52
|
45
|
joachim99@52
|
46 /* Determine whether an integer type is signed, and its bounds.
|
joachim99@52
|
47 This code assumes two's (or one's!) complement with no holes. */
|
joachim99@52
|
48
|
joachim99@52
|
49 /* The extra casts work around common compiler bugs,
|
joachim99@52
|
50 e.g. Cray C 5.0.3.0 when t == time_t. */
|
joachim99@52
|
51 #ifndef TYPE_SIGNED
|
joachim99@52
|
52 # define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
joachim99@52
|
53 #endif
|
joachim99@52
|
54 #ifndef TYPE_MINIMUM
|
joachim99@52
|
55 # define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
joachim99@52
|
56 ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
|
joachim99@52
|
57 : (t) 0))
|
joachim99@52
|
58 #endif
|
joachim99@52
|
59 #ifndef TYPE_MAXIMUM
|
joachim99@52
|
60 # define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
joachim99@52
|
61 #endif
|
joachim99@52
|
62
|
joachim99@52
|
63 #include <sys/types.h>
|
joachim99@52
|
64 #include <sys/stat.h>
|
joachim99@52
|
65
|
joachim99@52
|
66
|
joachim99@52
|
67 # include <stdlib.h>
|
joachim99@52
|
68 #ifndef EXIT_SUCCESS
|
joachim99@52
|
69 # define EXIT_SUCCESS 0
|
joachim99@52
|
70 #endif
|
joachim99@52
|
71 #if !EXIT_FAILURE
|
joachim99@52
|
72 # undef EXIT_FAILURE /* Sony NEWS-OS 4.0C defines EXIT_FAILURE to 0. */
|
joachim99@52
|
73 # define EXIT_FAILURE 1
|
joachim99@52
|
74 #endif
|
joachim99@52
|
75 #define EXIT_TROUBLE 2
|
joachim99@52
|
76
|
joachim99@52
|
77 #include <limits.h>
|
joachim99@52
|
78 #ifndef SSIZE_MAX
|
joachim99@52
|
79 # define SSIZE_MAX TYPE_MAXIMUM (ssize_t)
|
joachim99@52
|
80 #endif
|
joachim99@52
|
81
|
joachim99@52
|
82 #ifndef PTRDIFF_MAX
|
joachim99@52
|
83 # define PTRDIFF_MAX TYPE_MAXIMUM (ptrdiff_t)
|
joachim99@52
|
84 #endif
|
joachim99@52
|
85 #ifndef SIZE_MAX
|
joachim99@52
|
86 # define SIZE_MAX TYPE_MAXIMUM (size_t)
|
joachim99@52
|
87 #endif
|
joachim99@52
|
88 #ifndef UINTMAX_MAX
|
joachim99@52
|
89 # define UINTMAX_MAX TYPE_MAXIMUM (uintmax_t)
|
joachim99@52
|
90 #endif
|
joachim99@52
|
91
|
joachim99@52
|
92 #include <stddef.h>
|
joachim99@52
|
93 #include <string.h>
|
joachim99@52
|
94 #include <ctype.h>
|
joachim99@52
|
95
|
joachim99@52
|
96 /* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
|
joachim99@52
|
97 as an argument to <ctype.h> macros like `isspace'. */
|
joachim99@52
|
98 # define CTYPE_DOMAIN(c) 1
|
joachim99@52
|
99 #define ISPRINT(c) (CTYPE_DOMAIN (c) && isprint (c))
|
joachim99@52
|
100 #define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
|
joachim99@52
|
101
|
joachim99@52
|
102 # define TOLOWER(c) tolower (c)
|
joachim99@52
|
103
|
joachim99@52
|
104 /* ISDIGIT differs from isdigit, as follows:
|
joachim99@52
|
105 - Its arg may be any int or unsigned int; it need not be an unsigned char.
|
joachim99@52
|
106 - It's guaranteed to evaluate its argument exactly once.
|
joachim99@52
|
107 - It's typically faster.
|
joachim99@52
|
108 POSIX 1003.1-2001 says that only '0' through '9' are digits.
|
joachim99@52
|
109 Prefer ISDIGIT to isdigit unless it's important to use the locale's
|
joachim99@52
|
110 definition of `digit' even when the host does not conform to POSIX. */
|
joachim99@52
|
111 #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
|
joachim99@52
|
112
|
joachim99@52
|
113 #undef MIN
|
joachim99@52
|
114 #undef MAX
|
joachim99@52
|
115 #define MIN(a, b) ((a) <= (b) ? (a) : (b))
|
joachim99@52
|
116 #define MAX(a, b) ((a) >= (b) ? (a) : (b))
|
joachim99@52
|
117
|
joachim99@52
|
118
|
joachim99@52
|
119
|
joachim99@52
|
120 /* Type used for fast comparison of several bytes at a time. */
|
joachim99@52
|
121
|
joachim99@52
|
122 #ifndef word
|
joachim99@52
|
123 # define word unsigned int
|
joachim99@52
|
124 #endif
|
joachim99@52
|
125
|
joachim99@52
|
126 /* The integer type of a line number. Since files are read into main
|
joachim99@52
|
127 memory, ptrdiff_t should be wide enough. */
|
joachim99@52
|
128
|
joachim99@52
|
129 typedef ptrdiff_t lin;
|
joachim99@52
|
130 #define LIN_MAX PTRDIFF_MAX
|
joachim99@52
|
131 verify (lin_is_signed, TYPE_SIGNED (lin));
|
joachim99@52
|
132 verify (lin_is_wide_enough, sizeof (ptrdiff_t) <= sizeof (lin));
|
joachim99@52
|
133 verify (lin_is_printable_as_long, sizeof (lin) <= sizeof (long));
|