~ubuntu-branches/ubuntu/karmic/fweb/karmic

« back to all changes in this revision

Viewing changes to Web/custom.web

  • Committer: Bazaar Package Importer
  • Author(s): Yann Dirson
  • Date: 2002-01-04 23:20:22 UTC
  • Revision ID: james.westby@ubuntu.com-20020104232022-330ad4iyzpvb5bm4
Tags: upstream-1.62
ImportĀ upstreamĀ versionĀ 1.62

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@z --- custom.web ---
 
2
 
 
3
FWEB version 1.62 (September 25, 1998)
 
4
 
 
5
Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]
 
6
 
 
7
@x-----------------------------------------------------------------------------
 
8
 
 
9
\Title{CUSTOM.WEB} % Customization header file.
 
10
 
 
11
@c
 
12
@* CUSTOMIZATION. 
 
13
Customization refers to tayloring an already compilable \FWEB, as well as
 
14
dealing with the annoyances of different compilers and operating systems. 
 
15
Once you've gotten a workable processor, you could supply a change file for
 
16
\.{custom.web} to maintain your changes from release to release. 
 
17
 
 
18
The source code includes the file \.{custom.h}. There are two fundamental
 
19
ways of producing that file.
 
20
 
 
21
In the modern way (new with v1.30), a template file \.{custom.h.in} is
 
22
produced.  This file is read by the configuration script \.{./configure},
 
23
which figures out automatically the settings of various parameters
 
24
appropriate for your system, then writes out \.{custom.h}.
 
25
 
 
26
In the old way, \.{custom.h} is created directly from \.{custom.web}, using
 
27
conditional flags to handle the differences between machines.  
 
28
 
 
29
Conditional branches \It{in this file only} are determined by upper-case \WEB\
 
30
macros, one of which should be defined from the command line (by saying,
 
31
e.g., ``\.{-mIBMPC}'') or put into your \.{.fweb} file.  Currently, these
 
32
macros are |CONFIG| (the special ``machine'' for automatic configuration), 
 
33
|ANSI|, |BSD|, |DSU|, |IBMPC|, |MAC|, |MISC|, |SGI|,
 
34
|SUN|, and |VAX|.  If you're working on the Sun and will be using \.{gcc}
 
35
(highly recommended), you should also define |GCC|.  Use the |MISC| macro
 
36
for working with your own customization.
 
37
 
 
38
\comment
 
39
The current list of customization flags is as follows:
 
40
$$\vbox{\halign{\.{#}\hfil&\ ---\ \vtop{\hsize=0.75\hsize\noindent
 
41
        \strut#\strut}\hfil\cr
 
42
machine&\It{Lower-case} name of the machine, such as ``\.{-mmachine=ansi}''
 
43
or ``\.{-mmachine=sun}''.\cr 
 
44
MY\_BANNER&A possible local addition to the start-up banner, such as
 
45
``\.{-mMY\_BANNER=(Princeton)}''.\cr 
 
46
SYS\_NAME&System name, usually used to customize the ANSI version, as in
 
47
``\.{-mSYS\_NAME=CRAY}''.\cr 
 
48
TIMING\_WIDTH&Number of decimal places in the seconds field for timing
 
49
statistics. For example, on the CRAY you might say
 
50
``\.{-mTIMING\_WIDTH=2}''.\cr 
 
51
}}$$
 
52
For the flags such as |SYS_NAME| that require string arguments, quotes are
 
53
optional if the argument contains no embedded blanks.
 
54
\endcomment
 
55
 
 
56
@ We can automatically generate the relevant lower-case machine flags from the
 
57
value in \.{.fweb}.
 
58
 
 
59
@#ifdef ANSI
 
60
        @m ANSI 1
 
61
@#else
 
62
        @m ANSI 0
 
63
@#endif
 
64
 
 
65
@#ifdef APOLLO
 
66
        @m APOLLO 1
 
67
@#else
 
68
        @m APOLLO 0
 
69
@#endif
 
70
 
 
71
@#ifdef BSD
 
72
        @m BSD 1
 
73
@#else
 
74
        @m BSD 0
 
75
@#endif
 
76
 
 
77
@#ifdef CONFIG
 
78
        @m CONFIG 1
 
79
@#else
 
80
        @m CONFIG 0
 
81
@#endif
 
82
 
 
83
@#ifdef DSU
 
84
        @m DSU 1
 
85
@#else
 
86
        @m DSU 0
 
87
@#endif
 
88
 
 
89
@#ifdef IBMPC
 
90
        @m IBMPC 1
 
91
@#else
 
92
        @m IBMPC 0
 
93
@#endif
 
94
 
 
95
@#ifdef MAC
 
96
        @m MAC 1
 
97
@#else
 
98
        @m MAC 0
 
99
@#endif
 
100
 
 
101
@#ifdef MISC
 
102
        @m MISC 1
 
103
@#else
 
104
        @m MISC 0
 
105
@#endif
 
106
 
 
107
@#ifdef MVS
 
108
        @m MVS 1
 
109
@#else
 
110
        @m MVS 0
 
111
@#endif
 
112
 
 
113
@#ifdef SGI
 
114
        @m SGI 1
 
115
@#else
 
116
        @m SGI 0
 
117
@#endif
 
118
 
 
119
@#ifdef SUN
 
120
        @m SUN 1
 
121
 
 
122
        @#ifdef GCC
 
123
                @m SUN_GCC 1
 
124
                @m SUN_CC 0
 
125
        @#else
 
126
                @m SUN_GCC 0
 
127
                @m SUN_CC 1
 
128
        @#endif
 
129
@#else
 
130
        @m SUN 0
 
131
        @m SUN_GCC 0
 
132
        @m SUN_CC 0
 
133
@#endif
 
134
 
 
135
@#ifdef VAX
 
136
        @m VAX 1
 
137
@#else
 
138
        @m VAX 0
 
139
@#endif
 
140
 
 
141
 
 
142
@* TEMPLATE DEFINITIONS.  First, we have a macro definition that generates
 
143
the definition, conditionally commented out.  A similar definition handles
 
144
file includes. The |SYS_PATH| macro is used for such things as
 
145
\.{sys/types.h} that have slashes in them.
 
146
 
 
147
@m DEFN(when,text) $P define text $EVAL(when)
 
148
@m DEFN0(when,txt) DEFN1(when,txt)
 
149
@m DEFN1(when,txt) $IF(when,txt,$COMMENT(#txt))
 
150
 
 
151
@m AUTOCONFIG(name) 
 
152
   AU0("(The flag |",#name,"| is set automatically in config.h by ./configure.)")
 
153
@m AU0(s1,s2,s3) AU1(s1 s2 s3)
 
154
@m AU1(s) $COMMENT(s)
 
155
 
 
156
@m INCLUDE(when,file) DEFN0(when,_P include <file.h>)
 
157
@m INCLUDE_LOCAL(when,file) DEFN0(when,_P include #file)
 
158
 
 
159
@#if IBMPC
 
160
        @m SYS_PATH(name) $TRANSLIT(#name,"/","\\")
 
161
@#else
 
162
        @m SYS_PATH(name) #!name
 
163
@#endif /* |IBMPC| */
 
164
 
 
165
 
 
166
@* EXECUTABLE STATEMENTS. Finally, here are the statements that are
 
167
actually written into \.{custom.h} or \.{custom.h.in}.
 
168
 
 
169
@A
 
170
/* --- BOOTSTRAPPING --- */
 
171
 
 
172
/* To bootstrap yourself onto a new system, you should modify this file
 
173
appropriately.  In most cases, you set a flag by saying ``#define
 
174
FLAG''---i.e., you make a null definition.  Don't set these flags to~0
 
175
or~1.  However, in a few cases the macros are not flags and must be given
 
176
the appropriate definition. */
 
177
 
 
178
/* --- MACHINE COMPILER FLAG --- */
 
179
 
 
180
/* This must be in lower case.  Presently these are drawn from the list
 
181
{ansi, bsd, dsu, ibmpc, mac, misc, mvs, sgi, sun, vax}.  These
 
182
flags may be used in #define statements within the source code to tailor
 
183
things to a particular compiler or operating system.  If you use
 
184
./configure to generate custom.h, there will be no definition following
 
185
this comment. */ 
 
186
@#if !CONFIG 
 
187
@#if ANSI
 
188
        #ifndef ansi
 
189
        #define ansi
 
190
        #endif
 
191
@#endif@%
 
192
@#if APOLLO
 
193
        #ifndef apollo
 
194
        #define apollo
 
195
        #endif // |apollo|
 
196
@#endif@%
 
197
@#if BSD
 
198
        #ifndef bsd
 
199
        #define bsd
 
200
        #endif // |bsd|
 
201
@#endif@%
 
202
@#if DSU
 
203
        #ifndef dsu
 
204
        #define dsu
 
205
        #endif // |dsu|
 
206
@#endif@%
 
207
@#if IBMPC
 
208
        #ifndef ibmpc
 
209
        #define ibmpc
 
210
        #endif // |ibmpc|
 
211
@#endif@%
 
212
@#if MAC
 
213
        #ifndef mac
 
214
        #define mac
 
215
        #endif // |mac|
 
216
@#endif@%
 
217
@#if MISC
 
218
        #ifndef misc
 
219
        #define misc
 
220
        #endif // |misc|
 
221
@#endif@%
 
222
@#if MVS
 
223
        #ifndef mvs
 
224
        #define mvs
 
225
        #endif // |mvs|
 
226
@#endif@%
 
227
@#if SGI
 
228
        #ifndef sgi
 
229
        #define sgi
 
230
        #endif // |sgi|
 
231
@#endif@%
 
232
@#if SUN
 
233
        #ifndef sun
 
234
        #define sun
 
235
        #endif // |sun|
 
236
@#endif@%
 
237
@#if VAX
 
238
        #ifndef vax
 
239
        #define vax
 
240
        #endif // |vax|
 
241
@#endif@%
 
242
@#endif@%
 
243
 
 
244
@ The \FWEB\ variable |SYS_NAME| is usually used to customize the ANSI
 
245
version. If it's not defined while tangling \.{custom.web}, it's given a
 
246
default value. Things are set up so you can override by defining
 
247
|sys_name| from the compiler's line while compiling \.{common.c}.
 
248
 
 
249
@m S(type) `$P`##define THE_SYSTEM@= @>$STRING(type) /* (Without the verbatim
 
250
        command, the space disappears under expansion, which Microsoft doesn't
 
251
        like.) */ 
 
252
 
 
253
@A
 
254
/* --- FWEB SYSTEM NAME --- */
 
255
 
 
256
/* This is a string such as ``IBM-PC/DOS'' or ``VAX/VMS''. It is printed
 
257
when FWEB starts up. */
 
258
 
 
259
@#ifdef SYS_NAME
 
260
        S(SYS_NAME)
 
261
@#else@%
 
262
@#if CONFIG
 
263
        S("UNIX")
 
264
@#elif ANSI
 
265
        S("ANSI/UNIX") 
 
266
@#elif BSD
 
267
        S("BSD")
 
268
@#elif DSU
 
269
        S("DECstation/ULTRIX")
 
270
@#elif IBMPC
 
271
        S("IBM-PC/MSDOS")
 
272
@#elif MAC
 
273
        S("Mac/SHELL")
 
274
@#elif MISC
 
275
        S("Vanilla")
 
276
@#elif MVS
 
277
        S("IBM/MVS")
 
278
@#elif SGI
 
279
        S("Iris")
 
280
@#elif SUN
 
281
        S("SunOS/UNIX")
 
282
@#elif VAX
 
283
        S("VAX/VMS")
 
284
@#else
 
285
        S("Unknown")
 
286
@#endif@%
 
287
@#endif@% /* NO |SYS_NAME|. */
 
288
 
 
289
/* --- An optional local banner, printed after the system name above. --- */
 
290
 
 
291
#define LOCAL_BANNER ""
 
292
 
 
293
@* Errors.  We attempt to use the \.{\#error} command to warn the user
 
294
about inconsistencies.
 
295
@A
 
296
/* Does your compiler understand the ANSI preprocessor command \#error?
 
297
If it does, define |HAVE_ERROR|.  (I haven't figured out a general
 
298
autoconf test yet; it seems to be impossible in principle.) */
 
299
 
 
300
DEFN(CONFIG || ANSI || IBMPC || MVS || SUN_GCC ||VAX,HAVE_ERROR)@;
 
301
 
 
302
@* Running the preprocessor.
 
303
@A
 
304
/* The C preprocessor is run by the \.{-H} option. */
 
305
 
 
306
@#if CONFIG
 
307
        AUTOCONFIG(RUN_CPP)
 
308
@#else
 
309
        #define RUN_CPP "gcc -E"
 
310
@#endif
 
311
 
 
312
@* Renaming files.
 
313
@A
 
314
/* Occasionally a system command is issued to rename a file.  Here's how to
 
315
do that. */
 
316
@#if(IBMPC)
 
317
        #define MV "rename"
 
318
@#else
 
319
        #define MV "mv"
 
320
@#endif
 
321
 
 
322
@* ASCII translation.  For efficiency, translations to and from the
 
323
character set of the external world to \FWEB's internal |ASCII| aren't
 
324
carried out on |ASCII| machines.
 
325
@A
 
326
/* Do we bother with translations to the internal |ASCII| representation?
 
327
If so, define |TRANSLATE_ASCII|.  Don't bother on |ASCII| machines. */
 
328
 
 
329
DEFN(MVS,TRANSLATE_ASCII)@;
 
330
 
 
331
/* For \It{debugging} of target machines whose character set differs from
 
332
the one on which you're working, define |DEBUG_XCHR|.  \It{Usually, this
 
333
flag should not be defined.}  When it is defined, the |TRANSLATE_ASCII|
 
334
flag is automatically turned on, and the value of the style-file field
 
335
`xchr' is relevant. \It{Don't use this flag unless you're a system
 
336
developer!!!} */
 
337
 
 
338
DEFN(0,DEBUG_XCHR)@;
 
339
 
 
340
@* Path format.  @A /* Does the operating system have a Unix-like path?
 
341
That is, does it have the form ``/u/krommes'' rather than the VMS form
 
342
``ux3:[krommes]''?  If so, define |UNIX_PATH|. */
 
343
 
 
344
DEFN(!VAX,UNIX_PATH)@;
 
345
 
 
346
@* Environment variables.
 
347
@A
 
348
/* If the |getenv| call to obtain an environment variable is supported
 
349
(it usually is) define |HAVE_GETENV|. */
 
350
@#if CONFIG
 
351
        AUTOCONFIG(HAVE_GETENV)
 
352
@#else@%
 
353
        DEFN(!(MAC || MVS), HAVE_GETENV)@;
 
354
@#endif@%
 
355
 
 
356
@* File names and extensions.
 
357
 
 
358
@m NFN(type) `$P`##define NULL_FILE_NAME@= @>$STRING(type) 
 
359
        /* (Without the verbatim
 
360
        command, the space disappears under expansion, which Microsoft doesn't
 
361
        like.) */ 
 
362
 
 
363
@A
 
364
/* --- FILE NAMES and EXTENSIONS --- */
 
365
 
 
366
/* Name of the null file.  This macro merely defines the default value of
 
367
the style-file parameter `null_file', so it's not essential to add any more
 
368
machines here. */
 
369
 
 
370
@#ifdef NULL_NAME
 
371
        NFN(NULL_NAME)
 
372
@#else@%
 
373
@#if VAX
 
374
        NFN("nl:")
 
375
@#elif IBMPC
 
376
        NFN("nul")
 
377
@#elif MVS
 
378
        NFN("'NULLFILE'")
 
379
@#else
 
380
        NFN("/dev/null") // For Unix systems.
 
381
@#endif@%
 
382
@#endif@%
 
383
 
 
384
/* Name of \FWEB's initialization file.  Please see below, after the
 
385
definition of |SMALL_MEMORY|. */
 
386
 
 
387
/* Name of \FWEB's default style file.  \It{Please don't change this unless
 
388
you absolutely have to!  Use the `-z' option instead.} */
 
389
 
 
390
#define STYLE_FILE_NAME "fweb.sty"
 
391
 
 
392
/* Here are the default file extensions for each language.  These merely
 
393
set default style-file parameters, so it's not essential that you change
 
394
anything here.  See the parameters `suffix.C', `suffix.N', etc. */
 
395
 
 
396
#define C_EXT "c"
 
397
#define V_EXT "mk"
 
398
#define X_EXT "sty"
 
399
 
 
400
@#if CONFIG || ANSI || APOLLO || DSU || MISC || SGI || SUN
 
401
/* Unix. */
 
402
        #define Cpp_EXT "C" // Per \.{gcc}.
 
403
        #define R_EXT "r"
 
404
        #define R90_EXT "r90"
 
405
        #define N_EXT "f"
 
406
        #define N90_EXT "f90"
 
407
@#else 
 
408
/* Non-unix. */
 
409
        #define Cpp_EXT "C"
 
410
        #define R_EXT "rat"
 
411
        #define R90_EXT "rat90"
 
412
        #define N_EXT "for"
 
413
        #define N90_EXT "for90"
 
414
@#endif@%
 
415
 
 
416
@#if CONFIG
 
417
        AUTOCONFIG(HAVE_TMPNAM)
 
418
        AUTOCONFIG(HAVE_TEMPNAM)
 
419
@#else
 
420
        DEFN(1, HAVE_TMPNAM)@;
 
421
        DEFN(0, HAVE_TEMPNAM)@;
 
422
@#endif
 
423
 
 
424
@* Fancy continuations.  
 
425
@A
 
426
/* The |FANCY_SPLIT| flag is used for buffering the output lines of C~code.
 
427
Define this if the C~compiler CAN'T continue an incomplete line with a
 
428
backslash.  (ANSI compilers should be able to.)
 
429
{\bf (This code may not be fully debugged yet!)} */
 
430
 
 
431
@#if CONFIG
 
432
        AUTOCONFIG(FANCY_SPLIT)
 
433
@#else
 
434
        DEFN(SUN_CC || DSU || VAX,FANCY_SPLIT)@;
 
435
@#endif
 
436
 
 
437
@* Including files.
 
438
@A
 
439
/* --- INCLUDING FILES --- */
 
440
 
 
441
/* The code is written in C, and various header files of the form
 
442
``<*.h>'' are included near the beginning of each source file.  The
 
443
names of these files are standardized by ANSI.  Unfortunately, not everyone
 
444
has gotten around to ANSI yet.  Therefore, here we include important files
 
445
whose names may be nonstandard or whose functions may fluctuate. */
 
446
 
 
447
/* Does the ANSI <stdlib.h> exist?  If so, say so here.  This is supposed
 
448
to contain prototypes for the following functions used by \FWEB: |abort|,
 
449
|abs|, |atof|, |atoi|, |atol|, |calloc|, |exit|, |free|, |getenv|,
 
450
|realloc|, |strtod|, |strtol|.  If it doesn't, either find the prototypes
 
451
in another file and include it here, or actually give the prototypes here. */
 
452
 
 
453
@#if CONFIG
 
454
        AUTOCONFIG(HAVE_STDLIB_H)
 
455
@#else
 
456
DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN || VAX,HAVE_STDLIB_H)@;
 
457
@#endif
 
458
 
 
459
@#if CONFIG
 
460
        AUTOCONFIG(HAVE_STDARG_H)
 
461
@#else
 
462
DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN || VAX,HAVE_STDARG_H)@;
 
463
@#endif
 
464
 
 
465
 
 
466
/* Does the ANSI <stddef.h> exist?  If so, include it here.  This is
 
467
supposed to define the |NULL| pointer, and the type |size_t|.  Sometimes
 
468
these are defined in other places as well. */
 
469
 
 
470
@#if CONFIG
 
471
        AUTOCONFIG(HAVE_STDDEF_H)
 
472
@#else
 
473
        DEFN(ANSI || IBMPC || MISC || MVS || VAX,HAVE_STDDEF_H)@;
 
474
@#endif
 
475
 
 
476
/* Other stuff handled by autoconf. */
 
477
@#if CONFIG
 
478
        AUTOCONFIG(HAVE_STRING_H)
 
479
@#else
 
480
DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN || VAX,HAVE_STRING_H)@;
 
481
@#endif
 
482
 
 
483
@#if CONFIG
 
484
        AUTOCONFIG(HAVE_MEMORY_H)
 
485
@#else
 
486
        DEFN(0,HAVE_MEMORY_H)@;
 
487
@#endif
 
488
 
 
489
@#if CONFIG
 
490
        AUTOCONFIG(HAVE_FLOAT_H)
 
491
@#else
 
492
DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN || VAX,HAVE_FLOAT_H)@;
 
493
@#endif
 
494
 
 
495
/* Does (non-ANSI) <sys/types.h> exist?  You may find some useful stuff in
 
496
here. But don't use it unless you have to. */
 
497
 
 
498
INCLUDE(!CONFIG && (APOLLO || DSU || SGI || SUN), SYS_PATH(sys/types))@;
 
499
 
 
500
/* Must we include an extra file for memory management?  E.g., for
 
501
Microsoft, <malloc.h>; for Borland; <alloc.h>.  Not necessary for ANSI;
 
502
it's in <stdlib.h>. */
 
503
 
 
504
INCLUDE(IBMPC,malloc)@;
 
505
 
 
506
/* Numerical limits.  We use the following ANSI macros: |INT_MAX|,
 
507
|INT_MIN|, |LONG_MAX|, |LONG_MIN|, and |ULONG_MAX|, which are found in
 
508
<limits.h>. If you can't find those macros, define the flag
 
509
|HAVE_VALUES_H|, and possibly include another file with different names for
 
510
the limits, such as <values.h> on the Sun.  The flag |HAVE_VALUES_H|
 
511
assumes that the macros |MAXINT| and |MAXLONG| are defined.  If they are
 
512
not, you must define them here. */
 
513
 
 
514
@#if CONFIG
 
515
        AUTOCONFIG(HAVE_LIMITS_H)
 
516
        AUTOCONFIG(HAVE_VALUES_H)
 
517
@#else
 
518
DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN_GCC|| VAX,HAVE_LIMITS_H)@;
 
519
DEFN(APOLLO || SUN_CC,HAVE_VALUES_H)@;
 
520
@#endif
 
521
 
 
522
/* Please note that additional files are included automatically
 
523
(essentially immediately after this file is read; see <includes.hweb>).
 
524
These were considered to be standard, but that might be a mistake.  Those
 
525
files are: <string.h>, <stdio.h>, <ctype.h>, <setjmp.h>, <time.h>.
 
526
Remember that by convention these files should limit themselves to being
 
527
included only once.  Therefore, if for some reason you need to include one
 
528
of these somewhere in this file, you should be able to do it without
 
529
difficulty; the later automatic include just won't be done if those files
 
530
are following standard protocol. */
 
531
 
 
532
@#if CONFIG
 
533
        AUTOCONFIG(ANSI_CTYPE_H)
 
534
@#else
 
535
        DEFN(ANSI || IBMPC || SUN_GCC,ANSI_CTYPE_H)@;
 
536
@#endif
 
537
 
 
538
@* Variable-length argument lists.
 
539
@A
 
540
/* --- VARIABLE-LENGTH ARGUMENT LISTS --- */
 
541
 
 
542
/* For convenience, FWEB attempts to use functions with variable numbers of
 
543
arguments.  We attempt to support two conventions: ANSI, and Sun's.  If
 
544
this feature is supported, define the flag |VARIABLE_ARGUMENTS|, say
 
545
whether |va_start| has one or two arguments, and include the associated
 
546
header file (<stdarg.h> for ANSI). */
 
547
 
 
548
/* Does the compiler allow ANSI-style variable arguments? */
 
549
 
 
550
DEFN(CONFIG || ANSI || IBMPC || MISC || MVS || SUN || VAX, VARIABLE_ARGUMENTS)@;
 
551
 
 
552
/* Is |va_start| defined with one argument (Sun's convention) or two
 
553
(ANSI)? */  
 
554
@#if SUN_CC
 
555
        #define NUM_VA_ARGS 1
 
556
@#else
 
557
        #define NUM_VA_ARGS 2
 
558
@#endif
 
559
@#if CONFIG
 
560
        AUTOCONFIG(HAVE_STDARG_H)
 
561
@#else
 
562
DEFN(CONFIG || ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN_GCC|| VAX,HAVE_STDARG_H)@;
 
563
@#endif
 
564
 
 
565
@* Additional prototypes.
 
566
@A
 
567
/* --- ADDITIONAL PROTOTYPES --- */
 
568
 
 
569
/* You may wish to collect any additional prototypes that are required and
 
570
put them into your own header file that you include here. */
 
571
 
 
572
/* If the flag |HAVE_STD_PROTOTYPES| is false, it causes the file
 
573
"stdlib0.h" to be loaded.  This contains ANSI prototypes that for some
 
574
reason aren't provided with the gcc environment on the Sun. */
 
575
@#if CONFIG
 
576
        AUTOCONFIG(HAVE_STD_PROTOTYPES)
 
577
@#else
 
578
        DEFN(!SUN_GCC,HAVE_STD_PROTOTYPES)@; 
 
579
@#endif
 
580
 
 
581
@* Function prototyping, etc.  
 
582
@A 
 
583
/* Define the flag |OLD_PROTOTYPES| for compilers that don't support the
 
584
new (ANSI) style of function declaration and prototyping.  The new style is
 
585
|fcn(int i,char *s){}|; the old style is |fcn(i,s) int i; char *s; {}|. */
 
586
 
 
587
@#if CONFIG
 
588
        AUTOCONFIG(OLD_PROTOTYPES)
 
589
@#else
 
590
        DEFN(SUN_CC || DSU || MAC || SGI || MISC || VAX, OLD_PROTOTYPES)@;
 
591
@#endif
 
592
 
 
593
/* ANSI also introduces the type |void|.  If your compiler doesn't
 
594
understand the constructions |void *| and |void fcn()|, define |NO_VOID|. */
 
595
 
 
596
@#if CONFIG
 
597
        AUTOCONFIG(NO_VOID)
 
598
@#else
 
599
        DEFN(DSU || MAC || SGI || SUN_CC, NO_VOID)@;
 
600
@#endif
 
601
 
 
602
@* Special types.
 
603
@A
 
604
/* --- SPECIAL TYPES --- */
 
605
 
 
606
/* |const| seems to be an annoyance; not all compilers treat it the same
 
607
way.  We really only want it for debugging, anyway, so we mostly just
 
608
remove it.  It's kept when compiling on the Sun with gcc, because it
 
609
gives the developer more checks on the code.  If you want to keep it,
 
610
define |KEEP_CONST|. */
 
611
 
 
612
DEFN(CONFIG || SUN_GCC,KEEP_CONST)@;
 
613
 
 
614
/* For personal computers, the kind of pointer is an issue.  They must be
 
615
|huge|.  If your compiler understands |huge|, define |HUGE_POINTERS|. */
 
616
 
 
617
DEFN(IBMPC,HUGE_POINTERS)@;
 
618
 
 
619
@* Special functions.
 
620
@A
 
621
/* --- SPECIAL FUNCTIONS --- */
 
622
 
 
623
/* The ANSI |sprintf| function returns the number of characters written.
 
624
If this is the case on your system, define |ANSI_SPRINTF|.  (It's always
 
625
safe to not define it.) */
 
626
 
 
627
@#if CONFIG
 
628
        AUTOCONFIG(ANSI_SPRINTF)
 
629
@#else
 
630
        DEFN((ANSI || IBMPC || MVS || VAX),ANSI_SPRINTF)@;
 
631
@#endif
 
632
 
 
633
/* The ANSI |sscanf| does some cute things with scansets, but it doesn't
 
634
always work. */
 
635
@#if CONFIG
 
636
        AUTOCONFIG(ANSI_SSCANF)
 
637
@#else
 
638
        DEFN(ANSI || IBMPC || SUN_GCC, ANSI_SSCANF)@;
 
639
@#endif
 
640
 
 
641
/* The ANSI |system| function is supposed to take |NULL| as an argument,
 
642
which means check if a command processor exists.  If this works properly,
 
643
defined |ANSI_SYSTEM|.  (It doesn't work on the Sun.) */
 
644
 
 
645
DEFN(ANSI || IBMPC, ANSI_SYSTEM)@;
 
646
 
 
647
@* Annoying warnings.  
 
648
@A
 
649
/* --- ANNOYING WARNINGS --- */
 
650
 
 
651
/* Sometimes the compiler can't understand that the
 
652
control flow can never get to the bottom of a function. To avoid warning
 
653
complaints, we have the following: */
 
654
 
 
655
@#if SUN_CC || DSU || SGI
 
656
        #define DUMMY_RETURN(value) 
 
657
@#else
 
658
        #define DUMMY_RETURN(value) return value
 
659
@#endif
 
660
 
 
661
@* Functions with unusual names.
 
662
The Aztec environment handled newlines in a non-standard way, and had
 
663
some other peculiarities.
 
664
 
 
665
@f lmalloc malloc
 
666
 
 
667
@A
 
668
/* --- UNUSUAL NAMES --- */
 
669
 
 
670
/* Put here any definitions that override standard names.  For example, for
 
671
some ancient on the MAC one had to say ``#define getc agetc''. */
 
672
 
 
673
@#if MAC /* \.{Machine-dependent}: Non-Unix treatment of newlines, and some
 
674
                other garbage. */
 
675
        #define index indexx
 
676
        #define getc agetc 
 
677
        #define putc aputc
 
678
        #define abs(i) (i > 0 ? i : (-i)) // Maybe in some other header file?
 
679
@#else
 
680
        /* Nothing to be done. */
 
681
@#endif@%
 
682
 
 
683
@* Directory specifications.
 
684
@A
 
685
/* --- DIRECTORY SPECIFICATIONS --- */
 
686
 
 
687
/* Directory specifications are delimited in different ways under the various
 
688
operating systems. Unix: '/'; IBM-PC: '\\'; VAX/VMS: ']'. */
 
689
 
 
690
@#ifdef PREFIX_END_CHR
 
691
        #define PREFIX_END_CHAR PREFIX_END_CHR
 
692
@#else@%
 
693
@#if VAX
 
694
        #define PREFIX_END_CHAR ']' // The VAX has a peculiar format.
 
695
@#elif IBMPC
 
696
        #define PREFIX_END_CHAR '\\' // IBM is perverse.
 
697
@#else@%
 
698
        #define PREFIX_END_CHAR '/' // The Unix convention.
 
699
@#endif@%
 
700
@#endif@%
 
701
 
 
702
@* Timing.
 
703
@A
 
704
/* --- TIMING --- */
 
705
 
 
706
/* First of all, we have a flag to say whether timing information is
 
707
printed at the end of the run.  (If you can't figure out the timing
 
708
routines for your machine or don't want a timing information line at the
 
709
end of your terminal output, don't define this.)  Beginning with fweb-1.53,
 
710
timing is turned off by default. */
 
711
 
 
712
DEFN(0 && !(MVS),TIMING)@;
 
713
 
 
714
/* --- Number of decimal places  for timing information in seconds.  (Use
 
715
at least 2 for supercomputers.) --- */
 
716
 
 
717
#define TIMING_WIDTH 1
 
718
 
 
719
/* There's supposed to be a function |clock()| that returns the cpu time,
 
720
in units of |CLOCKS_PER_SEC|.  The type of |clock| is |clock_t|.  If that
 
721
is defined, define the flag |CLOCK_T_DEFINED|; otherwise, say |typedef ...
 
722
clock_t| here. */
 
723
 
 
724
@#if CONFIG
 
725
        AUTOCONFIG(CLOCK_T_DEFINED)
 
726
@#else
 
727
        DEFN(!(APOLLO || SGI), CLOCK_T_DEFINED)@;
 
728
@#endif
 
729
 
 
730
/* Some systems don't define |CLOCKS_PER_SEC|.  If not, we try |CLK_TCK|.
 
731
If that's not defined, it defaults to 1000000.  If that's not appropriate,
 
732
define |CLOCKS_PER_SEC| here. */
 
733
 
 
734
/*
 
735
#define CLOCKS_PER_SEC 1000000
 
736
*/
 
737
 
 
738
/* Are there system routines that return wall-clock time in sub-second units? 
 
739
First, look for |gettimeofday| ($\mu$sec timing). */
 
740
@#if CONFIG
 
741
        AUTOCONFIG(HAVE_GETTIMEOFDAY)
 
742
@#else
 
743
        DEFN(SUN,HAVE_GETTIMEOFDAY)@;
 
744
@#endif
 
745
 
 
746
/* Otherwise, does the file sys/timeb.h exist that along with |ftime| gives
 
747
millisecond timing for wall-clock time?  We check for the header file, not
 
748
|ftime| itself, since |ftime| may be in a Berkeley compatibility library,
 
749
not in libc. */
 
750
 
 
751
@#if CONFIG
 
752
        AUTOCONFIG(HAVE_SYS_TIMEB_H)
 
753
@#else
 
754
        DEFN((APOLLO || DSU || IBMPC),HAVE_SYS_TIMEB_H)@;
 
755
@#endif
 
756
 
 
757
/* Do we use our own version of |difftime()|, which computes the difference
 
758
of two wall clock times?  If so, define |NEW_DIFFTIME|.  This flag should
 
759
always be defined if |HAVE_SYS_TIMEB_H| is defined above.  */
 
760
 
 
761
@#if CONFIG
 
762
        /* |NEW_DIFFTIME| is computed from flags set by ./configure. */
 
763
@#else
 
764
        DEFN(APOLLO || DSU || IBMPC || MAC || MISC || SGI || SUN, NEW_DIFFTIME)@;
 
765
@#endif
 
766
 
 
767
@* Squeezing it down.
 
768
@A
 
769
/* --- MAKING IT FIT --- */
 
770
 
 
771
/* Sometimes the compiler can't handle functions or switches that are too
 
772
large.  In that case, define |FCN_CALLS|.  That converts certain in-line
 
773
code (such as in the syntax production analyzer) into function calls (at
 
774
the price of slowing things down a bit). */
 
775
 
 
776
@#ifdef F_CALLS
 
777
        #define FCN_CALLS F_CALLS
 
778
@#else
 
779
        DEFN(IBMPC || MAC, FCN_CALLS)@;
 
780
@#endif
 
781
 
 
782
/* The personal computers are starved for memory.  For those machines, we
 
783
specify smaller default values for the lengths of dynamic arrays; define
 
784
|SMALL_MEMORY|.  (You can always use the `-y' option to override these
 
785
defaults.) */ 
 
786
 
 
787
@#ifdef SMALL_MEM
 
788
        #define SMALL_MEMORY SMALL_MEM
 
789
@#else
 
790
        DEFN(IBMPC || MAC, SMALL_MEMORY)@;
 
791
@#endif
 
792
 
 
793
/* Name of \FWEB's default initialization file.  Please don't change these
 
794
conventions unless you absolutely have to!!!  Also, note that these
 
795
definitions are overridden by the environment variable |FWEB_INI|, if it is
 
796
defined. */
 
797
 
 
798
#ifndef SMALL_MEMORY
 
799
        #define SMALL_MEMORY 0
 
800
#endif
 
801
 
 
802
#if SMALL_MEMORY
 
803
        #define FWEB_INI "fweb.ini"
 
804
#else
 
805
        #define FWEB_INI ".fweb"
 
806
#endif
 
807
 
 
808
@* Allocating and printing memory.
 
809
 
 
810
@A
 
811
/* --- MEMORY ALLOCATIONS --- */
 
812
 
 
813
/* The ANSI |calloc| routine takes two arguments:  |void
 
814
*calloc(size_t,size_t)|. If the system doesn't have a standard |calloc|
 
815
routine, or if the name isn't standard, you must define an UPPERCASE macro
 
816
that does the same thing.  (The name isn't standard on personal computers
 
817
because one is dealing with |huge| allocations.)  If you define
 
818
|NON_ANSI_CALLOC|, you must define |CALLOC|, |REALLOC|, and |FREE|.  E.g., the
 
819
relevant definitions for Borland are
 
820
\begintt
 
821
#define CALLOC farcalloc
 
822
#define REALLOC(oldblock,nbytes) \
 
823
 farrealloc((void far *)(oldblock),(unsigned long)(nbytes))
 
824
#define FREE(block) farfree((void far *)(block))
 
825
\endtt
 
826
*/ 
 
827
 
 
828
DEFN(IBMPC || MAC,NON_ANSI_CALLOC)@;
 
829
 
 
830
/* |IBMPC| */
 
831
@#if IBMPC
 
832
        #define CALLOC halloc
 
833
        #define REALLOC hrealloc
 
834
        #define FREE hfree
 
835
@#elif MAC
 
836
        #define CALLOC(nunits,nsize) lmalloc(nunits*nsize)
 
837
        #define REALLOC(oldptr, new_size, old_size) realloc(old_ptr, new_size)
 
838
        #define FREE free
 
839
@#endif
 
840
 
 
841
/* Do we supply below a routine that obtains the available memory, such 
 
842
as Borland's farcoreleft()? */
 
843
 
 
844
DEFN(IBMPC,PRINT_AVAILABLE_MEMORY)
 
845
 
 
846
/* The function call that obtains the memory is called |CORE_LEFT|.  This
 
847
function is assumed to return an |unsigned long int|.  For Microsoft, we had
 
848
to write our own routine |_hmemavl|; see below.  For Borland, the routine
 
849
should be called |farcoreleft|.  For the other machines, we don't have
 
850
anything as yet. */ 
 
851
 
 
852
@#if IBMPC
 
853
        #define CORE_LEFT _hmemavl()
 
854
@#endif
 
855
 
 
856
 
 
857
@* ADDITIONAL FUNCTIONS.  
 
858
 
 
859
@A
 
860
/* The following flag is defined only by \common.web}. */
 
861
#ifdef COMMON_FCNS_
 
862
#if(part==0 || part==1)
 
863
 
 
864
/* Give here the C code for any additional functions that are
 
865
compiler-specific or missing from your implementation, such as maybe
 
866
|strtod|.  Note that these are bracketed with the flag COMMON_FCNS_ so they
 
867
are compiled into just one module, namely common.c. You must
 
868
always supply some version of the debugging routine |trap|, which must
 
869
return~0 as a minimum. */
 
870
@#if IBMPC /* \.{Machine-dependent}: Custom memory routines required. */
 
871
        @<Finding out about memory@>@;
 
872
@#endif
 
873
@<Additional compiler-specific functions@>@;
 
874
#endif /* |part == 1| */
 
875
 
 
876
#endif // |COMMON_FCNS_|
 
877
 
 
878
@
 
879
@<Finding out about memory@>=
 
880
 
 
881
/* For Microsoft, we must write our own routine to find out about memory,
 
882
since no heap management is done for the huge model. */
 
883
 
 
884
#ifdef mcc /* This flag is defined by the Microsoft compiler. */
 
885
 
 
886
#include <dos.h>
 
887
#define DOS_GET_MEM 0x48
 
888
 
 
889
unsigned long _hmemavl(void)
 
890
{
 
891
union REGS inregs,outregs;
 
892
 
 
893
inregs.h.ah = DOS_GET_MEM;
 
894
inregs.x.bx = 0xFFFF; /* Force the request to fail by giving a number
 
895
                                that's too big. */
 
896
 
 
897
intdos(&inregs,&outregs);  /* Make DOS system call. */
 
898
 
 
899
/* When the allocation fails, \.{BX} will return the size of the largest
 
900
block of memory available in paragraphs. */
 
901
return 16*(unsigned long)outregs.x.bx;
 
902
}
 
903
#endif /* mcc */
 
904
 
 
905
@ Here we insert any extra functions that are compiler-specific.  
 
906
 
 
907
@<Additional compiler-specific...@>=
 
908
 
 
909
@#if MAC /* \.{Machine-dependent}: If you want to use the \FWEB\
 
910
                breakpoint/debugging system. */
 
911
/* Required routines for the MAC. */
 
912
SRTN trap(m,name)
 
913
        int m;
 
914
        char name[];
 
915
{
 
916
#if(0)
 
917
printf("Mod %d: \"%s\"\n",m,name); /* For debugging. */
 
918
#endif
 
919
}
 
920
 
 
921
double pow()
 
922
{
 
923
puts("! Error: make the linker find pow().");
 
924
return 0.0;
 
925
}
 
926
 
 
927
double strtod()
 
928
{
 
929
puts("! Error: Need replacement routine for strtod");
 
930
return 0.0;
 
931
}
 
932
 
 
933
long strtol()
 
934
{
 
935
puts("! Error: Need replacement function for strtol");
 
936
return 0;
 
937
}
 
938
@#else
 
939
/* The default |trap| function for debugging. */
 
940
int trap(void)
 
941
{return 0;}
 
942
@#endif
 
943