Commit | Line | Data |
---|---|---|
988174c1 | 1 | /* $RCSfile: perl.h,v $$Revision: 4.0.1.5 $$Date: 91/11/11 16:41:07 $ |
a687059c | 2 | * |
352d5a3a | 3 | * Copyright (c) 1991, Larry Wall |
a687059c | 4 | * |
352d5a3a LW |
5 | * You may distribute under the terms of either the GNU General Public |
6 | * License or the Artistic License, as specified in the README file. | |
8d063cd8 LW |
7 | * |
8 | * $Log: perl.h,v $ | |
988174c1 LW |
9 | * Revision 4.0.1.5 91/11/11 16:41:07 lwall |
10 | * patch19: uts wrongly defines S_ISDIR() et al | |
11 | * patch19: too many preprocessors can't expand a macro right in #if | |
12 | * patch19: added little-endian pack/unpack options | |
13 | * | |
45d8adaa LW |
14 | * Revision 4.0.1.4 91/11/05 18:06:10 lwall |
15 | * patch11: various portability fixes | |
16 | * patch11: added support for dbz | |
17 | * patch11: added some support for 64-bit integers | |
18 | * patch11: hex() didn't understand leading 0x | |
19 | * | |
1462b684 LW |
20 | * Revision 4.0.1.3 91/06/10 01:25:10 lwall |
21 | * patch10: certain pattern optimizations were botched | |
22 | * | |
352d5a3a LW |
23 | * Revision 4.0.1.2 91/06/07 11:28:33 lwall |
24 | * patch4: new copyright notice | |
25 | * patch4: made some allowances for "semi-standard" C | |
26 | * patch4: many, many itty-bitty portability fixes | |
27 | * | |
35c8bce7 LW |
28 | * Revision 4.0.1.1 91/04/11 17:49:51 lwall |
29 | * patch1: hopefully straightened out some of the Xenix mess | |
30 | * | |
fe14fcc3 LW |
31 | * Revision 4.0 91/03/20 01:37:56 lwall |
32 | * 4.0 baseline. | |
8d063cd8 LW |
33 | * |
34 | */ | |
35 | ||
35c8bce7 | 36 | #define VOIDWANT 1 |
ac58e20f LW |
37 | #include "config.h" |
38 | ||
45d8adaa LW |
39 | #ifdef MYMALLOC |
40 | # ifdef HIDEMYMALLOC | |
41 | # define malloc Mymalloc | |
42 | # define realloc Myremalloc | |
43 | # define free Myfree | |
44 | # endif | |
45 | # define safemalloc malloc | |
46 | # define saferealloc realloc | |
47 | # define safefree free | |
48 | #endif | |
49 | ||
50 | /* work around some libPW problems */ | |
51 | #define fatal Myfatal | |
52 | #ifdef DOINIT | |
53 | char Error[1]; | |
54 | #endif | |
55 | ||
0f85fab0 | 56 | #ifdef MSDOS |
fe14fcc3 | 57 | /* This stuff now in the MS-DOS config.h file. */ |
0f85fab0 LW |
58 | #else /* !MSDOS */ |
59 | ||
60 | /* | |
61 | * The following symbols are defined if your operating system supports | |
62 | * functions by that name. All Unixes I know of support them, thus they | |
63 | * are not checked by the configuration script, but are directly defined | |
64 | * here. | |
65 | */ | |
fe14fcc3 LW |
66 | #define HAS_ALARM |
67 | #define HAS_CHOWN | |
68 | #define HAS_CHROOT | |
69 | #define HAS_FORK | |
70 | #define HAS_GETLOGIN | |
71 | #define HAS_GETPPID | |
72 | #define HAS_KILL | |
73 | #define HAS_LINK | |
74 | #define HAS_PIPE | |
75 | #define HAS_WAIT | |
76 | #define HAS_UMASK | |
0f85fab0 LW |
77 | /* |
78 | * The following symbols are defined if your operating system supports | |
79 | * password and group functions in general. All Unix systems do. | |
80 | */ | |
fe14fcc3 LW |
81 | #define HAS_GROUP |
82 | #define HAS_PASSWD | |
0f85fab0 LW |
83 | |
84 | #endif /* !MSDOS */ | |
85 | ||
352d5a3a LW |
86 | #if defined(__STDC__) || defined(_AIX) || defined(__stdc__) |
87 | # define STANDARD_C 1 | |
88 | #endif | |
89 | ||
90 | #if defined(HASVOLATILE) || defined(STANDARD_C) | |
663a0e37 | 91 | #define VOLATILE volatile |
663a0e37 LW |
92 | #else |
93 | #define VOLATILE | |
663a0e37 LW |
94 | #endif |
95 | ||
a687059c LW |
96 | #ifdef IAMSUID |
97 | # ifndef TAINT | |
98 | # define TAINT | |
99 | # endif | |
100 | #endif | |
101 | ||
fe14fcc3 | 102 | #ifndef HAS_VFORK |
03a14243 LW |
103 | # define vfork fork |
104 | #endif | |
105 | ||
fe14fcc3 LW |
106 | #ifdef HAS_GETPGRP2 |
107 | # ifndef HAS_GETPGRP | |
108 | # define HAS_GETPGRP | |
663a0e37 LW |
109 | # endif |
110 | # define getpgrp getpgrp2 | |
111 | #endif | |
112 | ||
fe14fcc3 LW |
113 | #ifdef HAS_SETPGRP2 |
114 | # ifndef HAS_SETPGRP | |
115 | # define HAS_SETPGRP | |
663a0e37 LW |
116 | # endif |
117 | # define setpgrp setpgrp2 | |
118 | #endif | |
119 | ||
fe14fcc3 LW |
120 | #include <stdio.h> |
121 | #include <ctype.h> | |
122 | #include <setjmp.h> | |
123 | #ifndef MSDOS | |
352d5a3a LW |
124 | #ifdef PARAM_NEEDS_TYPES |
125 | #include <sys/types.h> | |
03a14243 | 126 | #endif |
352d5a3a LW |
127 | #include <sys/param.h> |
128 | #endif | |
129 | #ifdef STANDARD_C | |
fe14fcc3 LW |
130 | /* Use all the "standard" definitions */ |
131 | #include <stdlib.h> | |
132 | #include <string.h> | |
352d5a3a | 133 | #endif /* STANDARD_C */ |
03a14243 | 134 | |
fe14fcc3 LW |
135 | #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234 |
136 | #undef HAS_MEMCMP | |
663a0e37 | 137 | #endif |
fe14fcc3 LW |
138 | |
139 | #ifdef HAS_MEMCPY | |
140 | ||
352d5a3a | 141 | # ifndef STANDARD_C |
fe14fcc3 LW |
142 | # ifndef memcpy |
143 | extern char * memcpy(), *memset(); | |
450a55e4 | 144 | extern int memcmp(); |
fe14fcc3 | 145 | # endif /* ndef memcpy */ |
352d5a3a | 146 | # endif /* ndef STANDARD_C */ |
fe14fcc3 | 147 | |
352d5a3a LW |
148 | # ifndef bcopy |
149 | # define bcopy(s1,s2,l) memcpy(s2,s1,l) | |
150 | # endif | |
151 | # ifndef bzero | |
152 | # define bzero(s,l) memset(s,0,l) | |
153 | # endif | |
fe14fcc3 | 154 | #endif /* HAS_MEMCPY */ |
8d063cd8 | 155 | |
fe14fcc3 | 156 | #ifndef HAS_BCMP /* prefer bcmp slightly 'cuz it doesn't order */ |
352d5a3a LW |
157 | # ifndef bcmp |
158 | # define bcmp(s1,s2,l) memcmp(s1,s2,l) | |
159 | # endif | |
d9d8d8de | 160 | #endif |
378cc40b LW |
161 | |
162 | #ifndef _TYPES_ /* If types.h defines this it's easy. */ | |
163 | #ifndef major /* Does everyone's types.h define this? */ | |
8d063cd8 | 164 | #include <sys/types.h> |
378cc40b LW |
165 | #endif |
166 | #endif | |
167 | ||
ae986130 LW |
168 | #ifdef I_NETINET_IN |
169 | #include <netinet/in.h> | |
170 | #endif | |
171 | ||
8d063cd8 | 172 | #include <sys/stat.h> |
988174c1 LW |
173 | #ifdef uts |
174 | #undef S_ISDIR | |
175 | #undef S_ISCHR | |
176 | #undef S_ISBLK | |
177 | #undef S_ISREG | |
178 | #undef S_ISFIFO | |
179 | #undef S_ISLNK | |
180 | #define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR) | |
181 | #define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR) | |
182 | #define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK) | |
183 | #define S_ISREG(P) (((P)&S_IFMT)==S_IFREG) | |
184 | #define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO) | |
185 | #define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK) | |
186 | #endif | |
135863df | 187 | |
663a0e37 LW |
188 | #ifdef I_TIME |
189 | # include <time.h> | |
ffed7fef | 190 | #endif |
663a0e37 | 191 | |
fe14fcc3 | 192 | #ifdef I_SYS_TIME |
663a0e37 LW |
193 | # ifdef SYSTIMEKERNEL |
194 | # define KERNEL | |
195 | # endif | |
196 | # include <sys/time.h> | |
197 | # ifdef SYSTIMEKERNEL | |
198 | # undef KERNEL | |
199 | # endif | |
a687059c | 200 | #endif |
135863df | 201 | |
d9d8d8de | 202 | #ifndef MSDOS |
8d063cd8 | 203 | #include <sys/times.h> |
d9d8d8de | 204 | #endif |
8d063cd8 | 205 | |
fe14fcc3 LW |
206 | #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR)) |
207 | #undef HAS_STRERROR | |
663a0e37 LW |
208 | #endif |
209 | ||
210 | #include <errno.h> | |
d9d8d8de | 211 | #ifndef MSDOS |
663a0e37 LW |
212 | #ifndef errno |
213 | extern int errno; /* ANSI allows errno to be an lvalue expr */ | |
214 | #endif | |
d9d8d8de | 215 | #endif |
663a0e37 | 216 | |
35c8bce7 | 217 | #ifndef strerror |
fe14fcc3 | 218 | #ifdef HAS_STRERROR |
663a0e37 LW |
219 | char *strerror(); |
220 | #else | |
221 | extern int sys_nerr; | |
222 | extern char *sys_errlist[]; | |
223 | #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e]) | |
224 | #endif | |
35c8bce7 | 225 | #endif |
663a0e37 | 226 | |
a687059c LW |
227 | #ifdef I_SYSIOCTL |
228 | #ifndef _IOCTL_ | |
229 | #include <sys/ioctl.h> | |
230 | #endif | |
231 | #endif | |
232 | ||
233 | #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */ | |
fe14fcc3 LW |
234 | #ifdef HAS_SOCKETPAIR |
235 | #undef HAS_SOCKETPAIR | |
a687059c | 236 | #endif |
fe14fcc3 LW |
237 | #ifdef HAS_NDBM |
238 | #undef HAS_NDBM | |
a687059c LW |
239 | #endif |
240 | #endif | |
241 | ||
45d8adaa LW |
242 | #ifdef WANT_DBZ |
243 | #include <dbz.h> | |
244 | #define SOME_DBM | |
245 | #define dbm_fetch(db,dkey) fetch(dkey) | |
246 | #define dbm_delete(db,dkey) fatal("dbz doesn't implement delete") | |
247 | #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent) | |
248 | #define dbm_close(db) dbmclose() | |
249 | #define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch()) | |
250 | #define nextkey() (fatal("dbz doesn't implement traversal"),fetch()) | |
251 | #define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch()) | |
252 | #ifdef HAS_NDBM | |
253 | #undef HAS_NDBM | |
254 | #endif | |
255 | #ifndef HAS_ODBM | |
256 | #define HAS_ODBM | |
257 | #endif | |
258 | #else | |
fe14fcc3 LW |
259 | #ifdef HAS_GDBM |
260 | #ifdef I_GDBM | |
261 | #include <gdbm.h> | |
262 | #endif | |
263 | #define SOME_DBM | |
264 | #ifdef HAS_NDBM | |
265 | #undef HAS_NDBM | |
266 | #endif | |
267 | #ifdef HAS_ODBM | |
268 | #undef HAS_ODBM | |
269 | #endif | |
270 | #else | |
271 | #ifdef HAS_NDBM | |
a687059c LW |
272 | #include <ndbm.h> |
273 | #define SOME_DBM | |
fe14fcc3 LW |
274 | #ifdef HAS_ODBM |
275 | #undef HAS_ODBM | |
ae986130 | 276 | #endif |
a687059c | 277 | #else |
fe14fcc3 | 278 | #ifdef HAS_ODBM |
a687059c LW |
279 | #ifdef NULL |
280 | #undef NULL /* suppress redefinition message */ | |
281 | #endif | |
282 | #include <dbm.h> | |
283 | #ifdef NULL | |
284 | #undef NULL | |
285 | #endif | |
286 | #define NULL 0 /* silly thing is, we don't even use this */ | |
287 | #define SOME_DBM | |
288 | #define dbm_fetch(db,dkey) fetch(dkey) | |
289 | #define dbm_delete(db,dkey) delete(dkey) | |
290 | #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent) | |
291 | #define dbm_close(db) dbmclose() | |
292 | #define dbm_firstkey(db) firstkey() | |
fe14fcc3 LW |
293 | #endif /* HAS_ODBM */ |
294 | #endif /* HAS_NDBM */ | |
295 | #endif /* HAS_GDBM */ | |
45d8adaa | 296 | #endif /* WANT_DBZ */ |
a687059c LW |
297 | #ifdef SOME_DBM |
298 | EXT char *dbmkey; | |
299 | EXT int dbmlen; | |
300 | #endif | |
301 | ||
302 | #if INTSIZE == 2 | |
303 | #define htoni htons | |
304 | #define ntohi ntohs | |
305 | #else | |
306 | #define htoni htonl | |
307 | #define ntohi ntohl | |
308 | #endif | |
309 | ||
35c8bce7 | 310 | #if defined(I_DIRENT) |
663a0e37 LW |
311 | # include <dirent.h> |
312 | # define DIRENT dirent | |
ae986130 | 313 | #else |
fe14fcc3 | 314 | # ifdef I_SYS_NDIR |
79a0689e | 315 | # include <sys/ndir.h> |
663a0e37 LW |
316 | # define DIRENT direct |
317 | # else | |
fe14fcc3 | 318 | # ifdef I_SYS_DIR |
79a0689e LW |
319 | # ifdef hp9000s500 |
320 | # include <ndir.h> /* may be wrong in the future */ | |
321 | # else | |
322 | # include <sys/dir.h> | |
323 | # endif | |
663a0e37 LW |
324 | # define DIRENT direct |
325 | # endif | |
326 | # endif | |
a687059c LW |
327 | #endif |
328 | ||
352d5a3a LW |
329 | #ifdef FPUTS_BOTCH |
330 | /* work around botch in SunOS 4.0.1 and 4.0.2 */ | |
331 | # ifndef fputs | |
332 | # define fputs(str,fp) fprintf(fp,"%s",str) | |
333 | # endif | |
334 | #endif | |
335 | ||
c623bd54 LW |
336 | /* |
337 | * The following gobbledygook brought to you on behalf of __STDC__. | |
338 | * (I could just use #ifndef __STDC__, but this is more bulletproof | |
339 | * in the face of half-implementations.) | |
340 | */ | |
341 | ||
342 | #ifndef S_IFMT | |
343 | # ifdef _S_IFMT | |
344 | # define S_IFMT _S_IFMT | |
345 | # else | |
346 | # define S_IFMT 0170000 | |
347 | # endif | |
348 | #endif | |
349 | ||
350 | #ifndef S_ISDIR | |
351 | # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) | |
352 | #endif | |
353 | ||
354 | #ifndef S_ISCHR | |
355 | # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) | |
356 | #endif | |
357 | ||
358 | #ifndef S_ISBLK | |
fe14fcc3 LW |
359 | # ifdef S_IFBLK |
360 | # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) | |
361 | # else | |
362 | # define S_ISBLK(m) (0) | |
363 | # endif | |
c623bd54 LW |
364 | #endif |
365 | ||
366 | #ifndef S_ISREG | |
367 | # define S_ISREG(m) ((m & S_IFMT) == S_IFREG) | |
368 | #endif | |
369 | ||
370 | #ifndef S_ISFIFO | |
fe14fcc3 LW |
371 | # ifdef S_IFIFO |
372 | # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) | |
373 | # else | |
374 | # define S_ISFIFO(m) (0) | |
375 | # endif | |
c623bd54 LW |
376 | #endif |
377 | ||
378 | #ifndef S_ISLNK | |
379 | # ifdef _S_ISLNK | |
380 | # define S_ISLNK(m) _S_ISLNK(m) | |
381 | # else | |
382 | # ifdef _S_IFLNK | |
383 | # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK) | |
384 | # else | |
385 | # ifdef S_IFLNK | |
386 | # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK) | |
387 | # else | |
388 | # define S_ISLNK(m) (0) | |
389 | # endif | |
390 | # endif | |
391 | # endif | |
392 | #endif | |
393 | ||
394 | #ifndef S_ISSOCK | |
395 | # ifdef _S_ISSOCK | |
396 | # define S_ISSOCK(m) _S_ISSOCK(m) | |
397 | # else | |
398 | # ifdef _S_IFSOCK | |
399 | # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK) | |
400 | # else | |
401 | # ifdef S_IFSOCK | |
402 | # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK) | |
403 | # else | |
404 | # define S_ISSOCK(m) (0) | |
405 | # endif | |
406 | # endif | |
407 | # endif | |
408 | #endif | |
409 | ||
410 | #ifndef S_IRUSR | |
411 | # ifdef S_IREAD | |
412 | # define S_IRUSR S_IREAD | |
413 | # define S_IWUSR S_IWRITE | |
414 | # define S_IXUSR S_IEXEC | |
415 | # else | |
416 | # define S_IRUSR 0400 | |
417 | # define S_IWUSR 0200 | |
418 | # define S_IXUSR 0100 | |
419 | # endif | |
420 | # define S_IRGRP (S_IRUSR>>3) | |
421 | # define S_IWGRP (S_IWUSR>>3) | |
422 | # define S_IXGRP (S_IXUSR>>3) | |
423 | # define S_IROTH (S_IRUSR>>6) | |
424 | # define S_IWOTH (S_IWUSR>>6) | |
425 | # define S_IXOTH (S_IXUSR>>6) | |
426 | #endif | |
427 | ||
428 | #ifndef S_ISUID | |
429 | # define S_ISUID 04000 | |
430 | #endif | |
431 | ||
432 | #ifndef S_ISGID | |
433 | # define S_ISGID 02000 | |
434 | #endif | |
435 | ||
352d5a3a LW |
436 | #ifdef f_next |
437 | #undef f_next | |
438 | #endif | |
439 | ||
45d8adaa LW |
440 | #if defined(cray) || defined(gould) |
441 | # define SLOPPYDIVIDE | |
442 | #endif | |
443 | ||
988174c1 | 444 | #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff |
45d8adaa LW |
445 | # define QUAD |
446 | #endif | |
447 | ||
448 | #ifdef QUAD | |
449 | # ifdef cray | |
450 | # define quad int | |
451 | # else | |
988174c1 | 452 | # if defined(convex) || defined (uts) |
45d8adaa LW |
453 | # define quad long long |
454 | # else | |
455 | # define quad long | |
456 | # endif | |
457 | # endif | |
458 | #endif | |
459 | ||
450a55e4 LW |
460 | typedef unsigned int STRLEN; |
461 | ||
8d063cd8 LW |
462 | typedef struct arg ARG; |
463 | typedef struct cmd CMD; | |
464 | typedef struct formcmd FCMD; | |
465 | typedef struct scanpat SPAT; | |
8d063cd8 | 466 | typedef struct stio STIO; |
378cc40b | 467 | typedef struct sub SUBR; |
8d063cd8 LW |
468 | typedef struct string STR; |
469 | typedef struct atbl ARRAY; | |
470 | typedef struct htbl HASH; | |
378cc40b | 471 | typedef struct regexp REGEXP; |
a687059c LW |
472 | typedef struct stabptrs STBP; |
473 | typedef struct stab STAB; | |
d9d8d8de | 474 | typedef struct callsave CSV; |
8d063cd8 | 475 | |
378cc40b LW |
476 | #include "handy.h" |
477 | #include "regexp.h" | |
8d063cd8 | 478 | #include "str.h" |
378cc40b | 479 | #include "util.h" |
8d063cd8 LW |
480 | #include "form.h" |
481 | #include "stab.h" | |
482 | #include "spat.h" | |
483 | #include "arg.h" | |
484 | #include "cmd.h" | |
485 | #include "array.h" | |
486 | #include "hash.h" | |
487 | ||
450a55e4 | 488 | #if defined(iAPX286) || defined(M_I286) || defined(I80286) |
a687059c LW |
489 | # define I286 |
490 | #endif | |
491 | ||
352d5a3a | 492 | #ifndef STANDARD_C |
135863df AB |
493 | #ifdef CHARSPRINTF |
494 | char *sprintf(); | |
495 | #else | |
496 | int sprintf(); | |
497 | #endif | |
a687059c | 498 | #endif |
135863df | 499 | |
8d063cd8 LW |
500 | EXT char *Yes INIT("1"); |
501 | EXT char *No INIT(""); | |
502 | ||
a687059c LW |
503 | /* "gimme" values */ |
504 | ||
505 | /* Note: cmd.c assumes that it can use && to produce one of these values! */ | |
506 | #define G_SCALAR 0 | |
507 | #define G_ARRAY 1 | |
508 | ||
509 | #ifdef CRIPPLED_CC | |
510 | int str_true(); | |
511 | #else /* !CRIPPLED_CC */ | |
512 | #define str_true(str) (Str = (str), \ | |
513 | (Str->str_pok ? \ | |
514 | ((*Str->str_ptr > '0' || \ | |
515 | Str->str_cur > 1 || \ | |
516 | (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \ | |
517 | : \ | |
518 | (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) )) | |
519 | #endif /* CRIPPLED_CC */ | |
8d063cd8 | 520 | |
135863df | 521 | #ifdef DEBUGGING |
a687059c LW |
522 | #define str_peek(str) (Str = (str), \ |
523 | (Str->str_pok ? \ | |
524 | Str->str_ptr : \ | |
525 | (Str->str_nok ? \ | |
526 | (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \ | |
527 | (char*)tokenbuf) : \ | |
528 | "" ))) | |
135863df AB |
529 | #endif |
530 | ||
a687059c LW |
531 | #ifdef CRIPPLED_CC |
532 | char *str_get(); | |
533 | #else | |
534 | #ifdef TAINT | |
535 | #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \ | |
536 | (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) | |
537 | #else | |
8d063cd8 | 538 | #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) |
a687059c LW |
539 | #endif /* TAINT */ |
540 | #endif /* CRIPPLED_CC */ | |
541 | ||
542 | #ifdef CRIPPLED_CC | |
543 | double str_gnum(); | |
544 | #else /* !CRIPPLED_CC */ | |
545 | #ifdef TAINT | |
546 | #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \ | |
547 | (Str->str_nok ? Str->str_u.str_nval : str_2num(Str))) | |
548 | #else /* !TAINT */ | |
549 | #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str))) | |
550 | #endif /* TAINT*/ | |
551 | #endif /* CRIPPLED_CC */ | |
8d063cd8 LW |
552 | EXT STR *Str; |
553 | ||
554 | #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) | |
555 | ||
450a55e4 | 556 | #ifndef MSDOS |
a687059c | 557 | #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len) |
450a55e4 LW |
558 | #define Str_Grow str_grow |
559 | #else | |
560 | /* extra parentheses intentionally NOT placed around "len"! */ | |
561 | #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \ | |
562 | str_grow(str,(unsigned long)len) | |
563 | #define Str_Grow(str,len) str_grow(str,(unsigned long)(len)) | |
564 | #endif /* MSDOS */ | |
a687059c LW |
565 | |
566 | #ifndef BYTEORDER | |
ffed7fef | 567 | #define BYTEORDER 0x1234 |
a687059c LW |
568 | #endif |
569 | ||
fe14fcc3 LW |
570 | #if defined(htonl) && !defined(HAS_HTONL) |
571 | #define HAS_HTONL | |
ae986130 | 572 | #endif |
fe14fcc3 LW |
573 | #if defined(htons) && !defined(HAS_HTONS) |
574 | #define HAS_HTONS | |
ae986130 | 575 | #endif |
fe14fcc3 LW |
576 | #if defined(ntohl) && !defined(HAS_NTOHL) |
577 | #define HAS_NTOHL | |
ae986130 | 578 | #endif |
fe14fcc3 LW |
579 | #if defined(ntohs) && !defined(HAS_NTOHS) |
580 | #define HAS_NTOHS | |
ae986130 | 581 | #endif |
fe14fcc3 | 582 | #ifndef HAS_HTONL |
d9d8d8de | 583 | #if (BYTEORDER & 0xffff) != 0x4321 |
fe14fcc3 LW |
584 | #define HAS_HTONS |
585 | #define HAS_HTONL | |
586 | #define HAS_NTOHS | |
587 | #define HAS_NTOHL | |
a687059c LW |
588 | #define MYSWAP |
589 | #define htons my_swap | |
590 | #define htonl my_htonl | |
591 | #define ntohs my_swap | |
592 | #define ntohl my_ntohl | |
593 | #endif | |
594 | #else | |
d9d8d8de | 595 | #if (BYTEORDER & 0xffff) == 0x4321 |
fe14fcc3 LW |
596 | #undef HAS_HTONS |
597 | #undef HAS_HTONL | |
598 | #undef HAS_NTOHS | |
599 | #undef HAS_NTOHL | |
a687059c LW |
600 | #endif |
601 | #endif | |
602 | ||
988174c1 LW |
603 | /* |
604 | * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'. | |
605 | * -DWS | |
606 | */ | |
607 | #if BYTEORDER != 0x1234 | |
608 | # define HAS_VTOHL | |
609 | # define HAS_VTOHS | |
610 | # define HAS_HTOVL | |
611 | # define HAS_HTOVS | |
612 | # if BYTEORDER == 0x4321 | |
613 | # define vtohl(x) ((((x)&0xFF)<<24) \ | |
614 | +(((x)>>24)&0xFF) \ | |
615 | +(((x)&0x0000FF00)<<8) \ | |
616 | +(((x)&0x00FF0000)>>8) ) | |
617 | # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF)) | |
618 | # define htovl(x) vtohl(x) | |
619 | # define htovs(x) vtohs(x) | |
620 | # endif | |
621 | /* otherwise default to functions in util.c */ | |
622 | #endif | |
623 | ||
0f85fab0 LW |
624 | #ifdef CASTNEGFLOAT |
625 | #define U_S(what) ((unsigned short)(what)) | |
626 | #define U_I(what) ((unsigned int)(what)) | |
627 | #define U_L(what) ((unsigned long)(what)) | |
628 | #else | |
629 | unsigned long castulong(); | |
630 | #define U_S(what) ((unsigned int)castulong(what)) | |
631 | #define U_I(what) ((unsigned int)castulong(what)) | |
632 | #define U_L(what) (castulong(what)) | |
633 | #endif | |
634 | ||
8d063cd8 LW |
635 | CMD *add_label(); |
636 | CMD *block_head(); | |
637 | CMD *append_line(); | |
638 | CMD *make_acmd(); | |
639 | CMD *make_ccmd(); | |
a687059c | 640 | CMD *make_icmd(); |
8d063cd8 LW |
641 | CMD *invert(); |
642 | CMD *addcond(); | |
643 | CMD *addloop(); | |
644 | CMD *wopt(); | |
378cc40b | 645 | CMD *over(); |
8d063cd8 | 646 | |
8d063cd8 | 647 | STAB *stabent(); |
378cc40b | 648 | STAB *genstab(); |
8d063cd8 | 649 | |
378cc40b | 650 | ARG *stab2arg(); |
8d063cd8 LW |
651 | ARG *op_new(); |
652 | ARG *make_op(); | |
8d063cd8 LW |
653 | ARG *make_match(); |
654 | ARG *make_split(); | |
a687059c | 655 | ARG *rcatmaybe(); |
378cc40b | 656 | ARG *listish(); |
a687059c | 657 | ARG *maybelistish(); |
378cc40b | 658 | ARG *localize(); |
a687059c LW |
659 | ARG *fixeval(); |
660 | ARG *jmaybe(); | |
378cc40b | 661 | ARG *l(); |
a687059c | 662 | ARG *fixl(); |
378cc40b LW |
663 | ARG *mod_match(); |
664 | ARG *make_list(); | |
665 | ARG *cmd_to_arg(); | |
666 | ARG *addflags(); | |
667 | ARG *hide_ary(); | |
668 | ARG *cval_to_arg(); | |
8d063cd8 | 669 | |
8d063cd8 LW |
670 | STR *str_new(); |
671 | STR *stab_str(); | |
a687059c LW |
672 | |
673 | int do_each(); | |
674 | int do_subr(); | |
675 | int do_match(); | |
676 | int do_unpack(); | |
677 | int eval(); /* this evaluates expressions */ | |
678 | int do_eval(); /* this evaluates eval operator */ | |
679 | int do_assign(); | |
378cc40b LW |
680 | |
681 | SUBR *make_sub(); | |
8d063cd8 LW |
682 | |
683 | FCMD *load_format(); | |
684 | ||
685 | char *scanpat(); | |
686 | char *scansubst(); | |
687 | char *scantrans(); | |
688 | char *scanstr(); | |
fe14fcc3 | 689 | char *scanident(); |
8d063cd8 LW |
690 | char *str_append_till(); |
691 | char *str_gets(); | |
a687059c | 692 | char *str_grow(); |
8d063cd8 | 693 | |
8d063cd8 LW |
694 | bool do_open(); |
695 | bool do_close(); | |
696 | bool do_print(); | |
378cc40b LW |
697 | bool do_aprint(); |
698 | bool do_exec(); | |
699 | bool do_aexec(); | |
8d063cd8 LW |
700 | |
701 | int do_subst(); | |
378cc40b LW |
702 | int cando(); |
703 | int ingroup(); | |
8d063cd8 | 704 | |
378cc40b LW |
705 | void str_replace(); |
706 | void str_inc(); | |
707 | void str_dec(); | |
8d063cd8 | 708 | void str_free(); |
a687059c | 709 | void stab_clear(); |
378cc40b | 710 | void do_join(); |
378cc40b | 711 | void do_sprintf(); |
a687059c | 712 | void do_accept(); |
ac58e20f | 713 | void do_pipe(); |
a687059c | 714 | void do_vecset(); |
fe14fcc3 LW |
715 | void do_unshift(); |
716 | void do_execfree(); | |
717 | void magicalize(); | |
718 | void magicname(); | |
a687059c LW |
719 | void savelist(); |
720 | void saveitem(); | |
721 | void saveint(); | |
722 | void savelong(); | |
723 | void savesptr(); | |
724 | void savehptr(); | |
725 | void restorelist(); | |
ac58e20f | 726 | void repeatcpy(); |
a687059c LW |
727 | HASH *savehash(); |
728 | ARRAY *saveary(); | |
378cc40b | 729 | |
ac58e20f LW |
730 | EXT char **origargv; |
731 | EXT int origargc; | |
fe14fcc3 | 732 | EXT char **origenviron; |
35c8bce7 LW |
733 | extern char **environ; |
734 | ||
45d8adaa | 735 | EXT long subline INIT(0); |
a687059c | 736 | EXT STR *subname INIT(Nullstr); |
8d063cd8 LW |
737 | EXT int arybase INIT(0); |
738 | ||
739 | struct outrec { | |
d9d8d8de LW |
740 | long o_lines; |
741 | char *o_str; | |
742 | int o_len; | |
8d063cd8 LW |
743 | }; |
744 | ||
745 | EXT struct outrec outrec; | |
746 | EXT struct outrec toprec; | |
747 | ||
a687059c | 748 | EXT STAB *stdinstab INIT(Nullstab); |
8d063cd8 LW |
749 | EXT STAB *last_in_stab INIT(Nullstab); |
750 | EXT STAB *defstab INIT(Nullstab); | |
751 | EXT STAB *argvstab INIT(Nullstab); | |
752 | EXT STAB *envstab INIT(Nullstab); | |
753 | EXT STAB *sigstab INIT(Nullstab); | |
754 | EXT STAB *defoutstab INIT(Nullstab); | |
755 | EXT STAB *curoutstab INIT(Nullstab); | |
756 | EXT STAB *argvoutstab INIT(Nullstab); | |
378cc40b | 757 | EXT STAB *incstab INIT(Nullstab); |
a687059c LW |
758 | EXT STAB *leftstab INIT(Nullstab); |
759 | EXT STAB *amperstab INIT(Nullstab); | |
760 | EXT STAB *rightstab INIT(Nullstab); | |
761 | EXT STAB *DBstab INIT(Nullstab); | |
d9d8d8de | 762 | EXT STAB *DBline INIT(Nullstab); |
a687059c LW |
763 | EXT STAB *DBsub INIT(Nullstab); |
764 | ||
765 | EXT HASH *defstash; /* main symbol table */ | |
766 | EXT HASH *curstash; /* symbol table for current package */ | |
767 | EXT HASH *debstash; /* symbol table for perldb package */ | |
768 | ||
769 | EXT STR *curstname; /* name of current package */ | |
8d063cd8 LW |
770 | |
771 | EXT STR *freestrroot INIT(Nullstr); | |
378cc40b | 772 | EXT STR *lastretstr INIT(Nullstr); |
a687059c | 773 | EXT STR *DBsingle INIT(Nullstr); |
d9d8d8de LW |
774 | EXT STR *DBtrace INIT(Nullstr); |
775 | EXT STR *DBsignal INIT(Nullstr); | |
a687059c LW |
776 | |
777 | EXT int lastspbase; | |
778 | EXT int lastsize; | |
8d063cd8 | 779 | |
45d8adaa | 780 | EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx"); |
378cc40b | 781 | EXT char *origfilename; |
ac58e20f | 782 | EXT FILE * VOLATILE rsfp; |
8d063cd8 | 783 | EXT char buf[1024]; |
a687059c LW |
784 | EXT char *bufptr; |
785 | EXT char *oldbufptr; | |
786 | EXT char *oldoldbufptr; | |
787 | EXT char *bufend; | |
8d063cd8 LW |
788 | |
789 | EXT STR *linestr INIT(Nullstr); | |
790 | ||
fe14fcc3 LW |
791 | EXT char *rs INIT("\n"); |
792 | EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */ | |
a687059c | 793 | EXT int rslen INIT(1); |
8d063cd8 | 794 | EXT char *ofs INIT(Nullch); |
a687059c | 795 | EXT int ofslen INIT(0); |
8d063cd8 | 796 | EXT char *ors INIT(Nullch); |
a687059c | 797 | EXT int orslen INIT(0); |
8d063cd8 LW |
798 | EXT char *ofmt INIT(Nullch); |
799 | EXT char *inplace INIT(Nullch); | |
a687059c | 800 | EXT char *nointrp INIT(""); |
8d063cd8 | 801 | |
378cc40b LW |
802 | EXT bool preprocess INIT(FALSE); |
803 | EXT bool minus_n INIT(FALSE); | |
804 | EXT bool minus_p INIT(FALSE); | |
fe14fcc3 | 805 | EXT bool minus_l INIT(FALSE); |
378cc40b LW |
806 | EXT bool minus_a INIT(FALSE); |
807 | EXT bool doswitches INIT(FALSE); | |
808 | EXT bool dowarn INIT(FALSE); | |
450a55e4 | 809 | EXT bool doextract INIT(FALSE); |
378cc40b LW |
810 | EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/ |
811 | EXT bool sawampersand INIT(FALSE); /* must save all match strings */ | |
812 | EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */ | |
a687059c LW |
813 | EXT bool sawi INIT(FALSE); /* study must assume case insensitive */ |
814 | EXT bool sawvec INIT(FALSE); | |
ac58e20f | 815 | EXT bool localizing INIT(FALSE); /* are we processing a local() list? */ |
a687059c | 816 | |
352d5a3a LW |
817 | #ifndef MAXSYSFD |
818 | # define MAXSYSFD 2 | |
819 | #endif | |
820 | EXT int maxsysfd INIT(MAXSYSFD); /* top fd to pass to subprocesses */ | |
821 | ||
ae986130 LW |
822 | #ifdef CSH |
823 | char *cshname INIT(CSH); | |
824 | int cshlen INIT(0); | |
825 | #endif /* CSH */ | |
a687059c LW |
826 | |
827 | #ifdef TAINT | |
828 | EXT bool tainted INIT(FALSE); /* using variables controlled by $< */ | |
829 | #endif | |
378cc40b | 830 | |
450a55e4 | 831 | #ifndef MSDOS |
378cc40b | 832 | #define TMPPATH "/tmp/perl-eXXXXXX" |
450a55e4 | 833 | #else |
57ebbfd0 | 834 | #define TMPPATH "plXXXXXX" |
450a55e4 | 835 | #endif /* MSDOS */ |
378cc40b LW |
836 | EXT char *e_tmpname; |
837 | EXT FILE *e_fp INIT(Nullfp); | |
838 | ||
8d063cd8 | 839 | EXT char tokenbuf[256]; |
a687059c | 840 | EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */ |
ac58e20f | 841 | EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */ |
a687059c LW |
842 | EXT int multiline INIT(0); /* $*--do strings hold >1 line? */ |
843 | EXT int forkprocess; /* so do_open |- can return proc# */ | |
844 | EXT int do_undump INIT(0); /* -u or dump seen? */ | |
845 | EXT int error_count INIT(0); /* how many errors so far, max 10 */ | |
846 | EXT int multi_start INIT(0); /* 1st line of multi-line string */ | |
847 | EXT int multi_end INIT(0); /* last line of multi-line string */ | |
848 | EXT int multi_open INIT(0); /* delimiter of said string */ | |
849 | EXT int multi_close INIT(0); /* delimiter of said string */ | |
8d063cd8 LW |
850 | |
851 | FILE *popen(); | |
852 | /* char *str_get(); */ | |
853 | STR *interp(); | |
854 | void free_arg(); | |
855 | STIO *stio_new(); | |
1462b684 | 856 | void hoistmust(); |
45d8adaa | 857 | void scanconst(); |
8d063cd8 LW |
858 | |
859 | EXT struct stat statbuf; | |
a687059c LW |
860 | EXT struct stat statcache; |
861 | STAB *statstab INIT(Nullstab); | |
862 | STR *statname; | |
d9d8d8de | 863 | #ifndef MSDOS |
8d063cd8 | 864 | EXT struct tms timesbuf; |
d9d8d8de | 865 | #endif |
378cc40b LW |
866 | EXT int uid; |
867 | EXT int euid; | |
a687059c LW |
868 | EXT int gid; |
869 | EXT int egid; | |
378cc40b LW |
870 | UIDTYPE getuid(); |
871 | UIDTYPE geteuid(); | |
872 | GIDTYPE getgid(); | |
873 | GIDTYPE getegid(); | |
874 | EXT int unsafe; | |
8d063cd8 LW |
875 | |
876 | #ifdef DEBUGGING | |
ac58e20f | 877 | EXT VOLATILE int debug INIT(0); |
8d063cd8 | 878 | EXT int dlevel INIT(0); |
a687059c LW |
879 | EXT int dlmax INIT(128); |
880 | EXT char *debname; | |
881 | EXT char *debdelim; | |
d96024cf | 882 | #define YYDEBUG 1 |
8d063cd8 | 883 | #endif |
a687059c | 884 | EXT int perldb INIT(0); |
fe14fcc3 | 885 | #define YYMAXDEPTH 300 |
8d063cd8 | 886 | |
378cc40b LW |
887 | EXT line_t cmdline INIT(NOLINE); |
888 | ||
a687059c | 889 | EXT STR str_undef; |
8d063cd8 LW |
890 | EXT STR str_no; |
891 | EXT STR str_yes; | |
892 | ||
893 | /* runtime control stuff */ | |
894 | ||
895 | EXT struct loop { | |
a687059c LW |
896 | char *loop_label; /* what the loop was called, if anything */ |
897 | int loop_sp; /* stack pointer to copy stuff down to */ | |
8d063cd8 | 898 | jmp_buf loop_env; |
a687059c | 899 | } *loop_stack; |
8d063cd8 LW |
900 | |
901 | EXT int loop_ptr INIT(-1); | |
a687059c | 902 | EXT int loop_max INIT(128); |
8d063cd8 LW |
903 | |
904 | EXT jmp_buf top_env; | |
905 | ||
ac58e20f | 906 | EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */ |
8d063cd8 | 907 | |
450a55e4 LW |
908 | struct ufuncs { |
909 | int (*uf_val)(); | |
910 | int (*uf_set)(); | |
911 | int uf_index; | |
912 | }; | |
913 | ||
a687059c LW |
914 | EXT ARRAY *stack; /* THE STACK */ |
915 | ||
ac58e20f | 916 | EXT ARRAY * VOLATILE savestack; /* to save non-local values on */ |
378cc40b LW |
917 | |
918 | EXT ARRAY *tosave; /* strings to save on recursive subroutine */ | |
919 | ||
a687059c | 920 | EXT ARRAY *lineary; /* lines of script for debugger */ |
d9d8d8de | 921 | EXT ARRAY *dbargs; /* args to call listed by caller function */ |
a687059c | 922 | |
d9d8d8de LW |
923 | EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */ |
924 | EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */ | |
a687059c | 925 | |
ac58e20f LW |
926 | EXT int *di; /* for tmp use in debuggers */ |
927 | EXT char *dc; | |
928 | EXT short *ds; | |
929 | ||
fe14fcc3 LW |
930 | /* Fix these up for __STDC__ */ |
931 | EXT long basetime INIT(0); | |
932 | char *mktemp(); | |
352d5a3a | 933 | #ifndef STANDARD_C |
fe14fcc3 | 934 | /* All of these are in stdlib.h or time.h for ANSI C */ |
8d063cd8 | 935 | double atof(); |
a687059c | 936 | long time(); |
8d063cd8 | 937 | struct tm *gmtime(), *localtime(); |
378cc40b LW |
938 | char *index(), *rindex(); |
939 | char *strcpy(), *strcat(); | |
352d5a3a | 940 | #endif /* ! STANDARD_C */ |
8d063cd8 | 941 | |
8d063cd8 | 942 | #ifdef EUNICE |
378cc40b LW |
943 | #define UNLINK unlnk |
944 | int unlnk(); | |
8d063cd8 LW |
945 | #else |
946 | #define UNLINK unlink | |
947 | #endif | |
a687059c | 948 | |
fe14fcc3 LW |
949 | #ifndef HAS_SETREUID |
950 | #ifdef HAS_SETRESUID | |
a687059c | 951 | #define setreuid(r,e) setresuid(r,e,-1) |
fe14fcc3 | 952 | #define HAS_SETREUID |
a687059c LW |
953 | #endif |
954 | #endif | |
fe14fcc3 LW |
955 | #ifndef HAS_SETREGID |
956 | #ifdef HAS_SETRESGID | |
a687059c | 957 | #define setregid(r,e) setresgid(r,e,-1) |
fe14fcc3 | 958 | #define HAS_SETREGID |
a687059c LW |
959 | #endif |
960 | #endif |