annotate kdiff3/src/gnudiff_system.h @ 53:32d5cbf9db71

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