1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
/* GNU SED, a batch stream editor.
Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef BASICDEFS_H
#define BASICDEFS_H
#if defined(_AIX)
#pragma alloca
#else
# if !defined(alloca) /* predefined by HP cc +Olibcalls */
# ifdef __GNUC__
# define alloca(size) __builtin_alloca(size)
# else
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
# if defined(__hpux)
void *alloca ();
# else
# if !defined(__OS2__) && !defined(WIN32)
char *alloca ();
# else
# include <malloc.h> /* OS/2 defines alloca in here */
# endif
# endif
# endif
# endif
# endif
#endif
#ifdef HAVE_WCHAR_H
# include <wchar.h>
#endif
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
#ifdef HAVE_WCTYPE_H
# include <wctype.h>
#endif
#ifdef BOOTSTRAP
# define false 0
# define true 1
# define bool unsigned
# define __bool_true_false_are_defined 1
#else
# include <stdbool.h>
#endif
#if ENABLE_NLS
# include <libintl.h>
#else
# define gettext(msgid) (msgid)
# define ngettext(sing, plur, n) ((n) == 1 ? (sing) : (plur))
#endif
#define _(String) gettext(String)
#ifdef gettext_noop
# define N_(String) gettext_noop(String)
#else
# define N_(String) (String)
#endif
/* type countT is used to keep track of line numbers, etc. */
typedef unsigned long countT;
/* Oftentimes casts are used as an ugly hack to silence warnings
* from the compiler. However, sometimes those warnings really
* do point to something worth avoiding. I define this
* dummy marker to make searching for them with a text editor
* much easier, in case I want to verify that they are all
* legitimate. It is defined in the way it is so that it is
* easy to disable all casts so that the compiler (or lint)
* can tell me potentially interesting things about what would
* happen to the code without the explicit casts.
*/
#ifdef LOUD_LINT
# define CAST(x)
#else
# define CAST(x) (x)
#endif
/* Can the compiler grok function prototypes? */
#if (defined __STDC__ && __STDC__-0) || defined __GNUC__ || defined __SUNPRO_C || __PROTOTYPES
# define P_(s) s
#else
# define P_(s) ()
#endif
/* (VOID *) is the generic pointer type; some ancient compilers
don't know about (void *), and typically use (char *) instead.
VCAST() is used to cast to and from (VOID *)s --- but if the
compiler *does* support (void *) make this a no-op, so that
the compiler can detect if we omitted an essential function
declaration somewhere.
*/
#ifndef VOID
# define VOID void
# define VCAST(t)
#else
# define VCAST(t) (t)
#endif
/* some basic definitions to avoid undue promulgating of VCAST ugliness */
#define MALLOC(n,t) (VCAST(t *)ck_malloc((n)*sizeof(t)))
#define REALLOC(x,n,t) (VCAST(t *)ck_realloc(VCAST(VOID *)(x),(n)*sizeof(t)))
#define MEMDUP(x,n,t) (VCAST(t *)ck_memdup(VCAST(VOID *)(x),(n)*sizeof(t)))
#define FREE(x) (ck_free(VCAST(VOID *)x))
#define MEMCPY(d,s,l) (memcpy(VCAST(VOID *)(d),VCAST(const VOID *)(s),l))
#define MEMMOVE(d,s,l) (memmove(VCAST(VOID *)(d),VCAST(const VOID *)(s),l))
#define OB_MALLOC(o,n,t) (VCAST(t *)obstack_alloc(o,(n)*sizeof(t)))
#define obstack_chunk_alloc ck_malloc
#define obstack_chunk_free ck_free
#ifdef HAVE_MEMORY_H
# include <memory.h>
#endif
#ifndef HAVE_MEMMOVE
# ifndef memmove
/* ../lib/libsed.a provides a memmove() if the system doesn't.
Here is where we declare its return type; we don't prototype
it because that sometimes causes problems when we're running in
bootstrap mode on a system which really does support memmove(). */
extern VOID *memmove();
# endif
#endif
#ifndef HAVE_MEMCPY
# ifndef memcpy
# define memcpy(d, s, n) memmove(d, s, n)
# endif
#endif
#ifndef HAVE_STRERROR
extern char *strerror P_((int e));
#endif
/* handle misdesigned <ctype.h> macros (snarfed from lib/regex.c) */
/* Jim Meyering writes:
"... Some ctype macros are valid only for character codes that
isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
using /bin/cc or gcc but without giving an ansi option). So, all
ctype uses should be through macros like ISPRINT... If
STDC_HEADERS is defined, then autoconf has verified that the ctype
macros don't need to be guarded with references to isascii. ...
Defining isascii to 1 should let any compiler worth its salt
eliminate the && through constant folding."
Solaris defines some of these symbols so we must undefine them first. */
#undef ISASCII
#if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
# define ISASCII(c) 1
#else
# define ISASCII(c) isascii(c)
#endif
#if defined isblank || defined HAVE_ISBLANK
# define ISBLANK(c) (ISASCII (c) && isblank (c))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#undef ISPRINT
#define ISPRINT(c) (ISASCII (c) && isprint (c))
#define ISDIGIT(c) (ISASCII (c) && isdigit (c))
#define ISALNUM(c) (ISASCII (c) && isalnum (c))
#define ISALPHA(c) (ISASCII (c) && isalpha (c))
#define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
#define ISLOWER(c) (ISASCII (c) && islower (c))
#define ISPUNCT(c) (ISASCII (c) && ispunct (c))
#define ISSPACE(c) (ISASCII (c) && isspace (c))
#define ISUPPER(c) (ISASCII (c) && isupper (c))
#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
#ifndef initialize_main
# ifdef __EMX__
# define initialize_main(argcp, argvp) \
{ _response(argcp, argvp); _wildcard(argcp, argvp); }
# else /* NOT __EMX__ */
# define initialize_main(argcp, argvp)
# endif
#endif
#endif /*!BASICDEFS_H*/
|