File: includes.hweb

package info (click to toggle)
fweb 1.62-14.1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 7,400 kB
  • sloc: ansic: 41,945; makefile: 411; sh: 152
file content (240 lines) | stat: -rw-r--r-- 4,568 bytes parent folder | download | duplicates (9)
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
@z --- includes.hweb ---

FWEB version 1.62 (September 25, 1998)

Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]

@x-----------------------------------------------------------------------------

@ This file is included immediately after \.{custom.h}.  It contains logic
based on the flags set in \.{custom.h}, includes some extra files that are
pretty well standard, and includes the timing macros.

First, we try to ensure the preprocessor doesn't get annoyed.

@<Operating sys...@>=

/* SYSTEM LOGIC based on \.{custom.h}, and additional include files. */

#ifndef ANSI_CTYPE_H
	#define ANSI_CTYPE_H 0
#endif

#ifndef ANSI_SPRINTF
	#define ANSI_SPRINTF 0
#endif

#ifndef ANSI_SSCANF
	#define ANSI_SSCANF 0
#endif

#ifndef ANSI_SYSTEM
	#define ANSI_SYSTEM 0
#endif

#ifndef DEBUG_XCHR
	#define DEBUG_XCHR 0
#endif

#ifndef FCN_CALLS
	#define FCN_CALLS 0
#endif

#ifndef FANCY_SPLIT
	#define FANCY_SPLIT 0
#endif

#ifndef HAVE_ERROR
	#define HAVE_ERROR 0
#endif

#ifndef HAVE_GETENV
	#define HAVE_GETENV 0
#endif

#ifndef HAVE_GETTIMEOFDAY
	#define HAVE_GETTIMEOFDAY 0
#endif

#ifndef HAVE_LIMITS_H
	#define HAVE_LIMITS_H 0
#endif

#ifndef HAVE_SYS_TIMEB_H
	#define HAVE_SYS_TIMEB_H 0
#endif

#ifndef HAVE_STDARG_H
	#define HAVE_STDARG_H 0
#endif

#ifndef HAVE_STDDEF_H
	#define HAVE_STDDEF_H 0
#endif

#ifndef HAVE_STDLIB_H
	#define HAVE_STDLIB_H 0
#endif

#ifndef HAVE_STD_PROTOTYPES
	#define HAVE_STD_PROTOTYPES 0
#endif

#ifndef HAVE_STRERROR
	#define HAVE_STRERROR 0
#endif

#ifndef HAVE_VALUES_H
	#define HAVE_VALUES_H 0
#endif

#ifndef HUGE_POINTERS
	#define HUGE_POINTERS 0
#endif

#ifndef KEEP_CONST
	#define KEEP_CONST 0
#endif

#ifndef NEW_DIFFTIME
	#define NEW_DIFFTIME 0
#endif

#ifndef NO_VOID
	#define NO_VOID 0
#endif

#ifndef NON_ANSI_CALLOC
	#define NON_ANSI_CALLOC 0
#endif

#ifndef OLD_PROTOTYPES
	#define OLD_PROTOTYPES 0
#endif

#ifndef PRINT_AVAILABLE_MEMORY
	#define PRINT_AVAILABLE_MEMORY 0
#endif

#ifndef SIZE_T_DEFINED
	#define SIZE_T_DEFINED 0
#endif

#ifndef TIMING 
	#define TIMING 0
#endif

#ifndef TRANSLATE_ASCII 
	#define TRANSLATE_ASCII 0
#endif

#ifndef UNIX_PATH
	#define UNIX_PATH 0
#endif

@ Next, we start conditional processing.
@<Operating sys...@>=

#if HAVE_STDARG_H
	#include <stdarg.h>
#else
	#include <varargs.h>
#endif

#if HAVE_STDLIB_H
	#include <stdlib.h>
#endif

#if !HAVE_STD_PROTOTYPES
	#include "stdlib0.h"
#endif

#if HAVE_STDDEF_H
	#include <stddef.h>
#endif

#if HAVE_LIMITS_H
	#include <limits.h> // ANSI: Numerical limits.
#else
	#if HAVE_VALUES_H
		#define INT_MAX MAXINT
		#define LONG_MAX MAXLONG
	#else
		#define INT_MAX 0x7FFF
		#define LONG_MAX INT_MAX
	#endif

	#define INT_MIN (~(INT_MAX))
	#define LONG_MIN (~(LONG_MAX))
	#define ULONG_MAX (MAXLONG | (~(MAXLONG)))
		/* E.g., |0x7FFF @t\OR@> 0x8000|. */
#endif

#if HAVE_FLOAT_H
	#include <float.h>
#else
	#ifndef DBL_DIG
		#define DBL_DIG 10
	#endif
#endif

#if !NON_ANSI_CALLOC
	#define CALLOC calloc
	#define REALLOC(old_ptr, new_size, old_size) realloc(old_ptr, new_size)
	#define FREE free
#endif // |ANSI_CALLOC|


/* Some compilers can't handle |unsigned long| constants of the form
|123UL|.  Thus, these constants are declared via the following macro. */

#define UL(num) ((unsigned long)(num))

#include <stdio.h> // ANSI: STDIO routines.
#include <errno.h>

/* We use only ANSI write routines. */
#define FWRITE(buf,len,fp) fwrite((CONST void *)(buf),(size_t)(len),\
				(size_t)(1),fp)

#define WRITE1(buf,len) \
	{\
	int _k;\
	outer_char *_p;\
	for(_p=buf,_k=(int)(len); _k>0; _k--)\
	  {\
	  PUTC(*_p);\
	  _p++;\
	  }\
	}

/* The following is courtesy of the autoconf Info file. */
#if STDC_HEADERS || HAVE_STRING_H
	#include <string.h> // ANSI: String manipulation routines.

	#if !STDC_HEADERS && HAVE_MEMORY_H
		#include <memory.h>
	#endif
#else
	#include <strings.h>
#endif

#include <ctype.h> // ANSI: Character classification macros.

/* The following works only for |ASCII| machines.  Furthermore, it's slower
than the usual procedure involving ANDing a |_ctype| array with various bit
flags.  However, that procedure isn't portable across machines.  Caution:
This solution evaluates |c| more than once, so watch out for side effects! */
#if !ANSI_CTYPE_H
	#undef isalpha
	#undef isupper
	#undef islower

	#define isupper(c) ('A' <= (unsigned)(c) && (unsigned)(c) <= 'Z')
	#define islower(c) ('a' <= (unsigned)(c) && (unsigned)(c) <= 'z')
	#define isalpha(c) (isupper(c) || islower(c))
#endif

#include <setjmp.h> // ANSI: |longjmp| and |setjmp|.

@I time.hweb // Timing's quite an annoyance.