VirtualBox

source: kBuild/vendor/sed/4.1.5/basicdefs.h

Last change on this file was 599, checked in by bird, 18 years ago

GNU sed 4.1.5.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette