3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 * 2000, 2001, 2002, by Larry Wall and others
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
13 #define _INC_WIN32_PERL5 /* kludge around win32 stdio layer */
18 #elif defined(NETWARE)
19 # include "../NetWare/config.h"
21 # include "../config.h"
24 #if defined(__STDC__) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
29 #undef USE_STDIO_PTR /* XXX fast gets won't work, must investigate */
33 # if defined(__BORLANDC__)
43 # elif defined(_MSC_VER)
44 # elif defined(__MINGW32__)
48 /* Use all the "standard" definitions? */
49 #if defined(STANDARD_C) && defined(I_STDLIB)
51 #endif /* STANDARD_C */
60 # include <sys/types.h>
65 #if NX_CURRENT_COMPILER_RELEASE >= 400
66 #include <objc/NXCType.h>
67 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
68 #include <appkit/NXCType.h>
69 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
71 #else /* !USE_NEXT_CTYPE */
73 #endif /* USE_NEXT_CTYPE */
75 #define MEM_SIZE Size_t
78 Malloc_t malloc (MEM_SIZE nbytes);
79 Malloc_t calloc (MEM_SIZE elements, MEM_SIZE size);
80 Malloc_t realloc (Malloc_t where, MEM_SIZE nbytes);
81 Free_t free (Malloc_t where);
84 #if defined(I_STRING) || defined(__cplusplus)
90 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
92 #define strrchr rindex
100 # ifdef I_SYS_TIME_KERNEL
103 # include <sys/time.h>
104 # ifdef I_SYS_TIME_KERNEL
110 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
111 # include <sys/times.h>
118 # include "../os2ish.h"
120 # include "../dosish.h"
124 # define NO_PERL_TYPEDEFS
130 /* All of these are in stdlib.h or time.h for ANSI C */
132 struct tm *gmtime(), *localtime();
133 #if defined(OEMVS) || defined(__OPEN_VM)
134 char *(strchr)(), *(strrchr)();
135 char *(strcpy)(), *(strcat)();
137 char *strchr(), *strrchr();
138 char *strcpy(), *strcat();
140 #endif /* ! STANDARD_C */
145 # include "../handy.h"
149 #define Nullfp Null(FILE*)
199 #define OSEMICOLON 47
336 extern char *opname[];
345 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
346 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
349 #endif /* 80286 hack */
350 EXT union u_ops ops[OPSMAX];
352 typedef struct string STR;
353 typedef struct htbl HASH;
359 /* A string is TRUE if not "" or "0". */
360 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
361 EXT char *Yes INIT("1");
362 EXT char *No INIT("");
364 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
367 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
369 /* Prototypes for things in a2p.c */
370 int aryrefarg ( int arg );
371 int bl ( int arg, int maybe );
372 void dump ( int branch );
373 int fixfargs ( int name, int arg, int prevargs );
374 int fixrargs ( char *name, int arg, int prevargs );
375 void fixup ( STR *str );
376 int numary ( int arg );
377 int oper0 ( int type );
378 int oper1 ( int type, int arg1 );
379 int oper2 ( int type, int arg1, int arg2 );
380 int oper3 ( int type, int arg1, int arg2, int arg3 );
381 int oper4 ( int type, int arg1, int arg2, int arg3, int arg4 );
382 int oper5 ( int type, int arg1, int arg2, int arg3, int arg4, int arg5 );
383 void putlines ( STR *str );
384 void putone ( void );
385 int rememberargs ( int arg );
386 char * scannum ( char *s );
387 char * scanpat ( char *s );
388 int string ( char *ptr, int len );
389 void yyerror ( char *s );
392 EXT int line INIT(0);
396 EXT char *bufptr INIT(buf);
398 EXT STR *linestr INIT(Nullstr);
400 EXT char tokenbuf[2048];
401 EXT int expectterm INIT(TRUE);
404 EXT int debug INIT(0);
405 EXT int dlevel INIT(0);
414 EXT STR *freestrroot INIT(Nullstr);
419 EXT bool do_split INIT(FALSE);
420 EXT bool split_to_array INIT(FALSE);
421 EXT bool set_array_base INIT(FALSE);
422 EXT bool saw_RS INIT(FALSE);
423 EXT bool saw_OFS INIT(FALSE);
424 EXT bool saw_ORS INIT(FALSE);
425 EXT bool saw_line_op INIT(FALSE);
426 EXT bool in_begin INIT(TRUE);
427 EXT bool do_opens INIT(FALSE);
428 EXT bool do_fancy_opens INIT(FALSE);
429 EXT bool lval_field INIT(FALSE);
430 EXT bool do_chop INIT(FALSE);
431 EXT bool need_entire INIT(FALSE);
432 EXT bool absmaxfld INIT(FALSE);
433 EXT bool saw_altinput INIT(FALSE);
435 EXT bool nomemok INIT(FALSE);
437 EXT char const_FS INIT(0);
438 EXT char *namelist INIT(Nullch);
439 EXT char fswitch INIT(0);
440 EXT bool old_awk INIT(0);
442 EXT int saw_FS INIT(0);
443 EXT int maxfld INIT(0);
444 EXT int arymax INIT(0);
445 EXT char *nameary[100];
450 EXT HASH *curarghash;
465 #define P_FILETEST 65