comparison kdiff3/src/gnudiff_system.h @ 52:ba22ec30aa4e

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