1 /* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $
3 * Copyright (c) 1991-2003, Larry Wall
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.
14 #define _INC_WIN32_PERL5 /* kludge around win32 stdio layer */
19 #elif defined(NETWARE)
20 # include "../NetWare/config.h"
22 # include "../config.h"
25 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
30 #undef USE_STDIO_PTR /* XXX fast gets won't work, must investigate */
34 # if defined(__BORLANDC__)
44 # elif defined(_MSC_VER)
45 # elif defined(__MINGW32__)
49 /* Use all the "standard" definitions? */
50 #if defined(STANDARD_C) && defined(I_STDLIB)
52 #endif /* STANDARD_C */
61 # include <sys/types.h>
66 #if NX_CURRENT_COMPILER_RELEASE >= 400
67 #include <objc/NXCType.h>
68 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
69 #include <appkit/NXCType.h>
70 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
72 #else /* !USE_NEXT_CTYPE */
74 #endif /* USE_NEXT_CTYPE */
76 #define MEM_SIZE Size_t
79 Malloc_t malloc (MEM_SIZE nbytes);
80 Malloc_t calloc (MEM_SIZE elements, MEM_SIZE size);
81 Malloc_t realloc (Malloc_t where, MEM_SIZE nbytes);
82 Free_t free (Malloc_t where);
85 #if defined(I_STRING) || defined(__cplusplus)
91 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
93 #define strrchr rindex
101 # ifdef I_SYS_TIME_KERNEL
104 # include <sys/time.h>
105 # ifdef I_SYS_TIME_KERNEL
111 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
112 # include <sys/times.h>
119 # include "../os2ish.h"
121 # include "../dosish.h"
125 # define NO_PERL_TYPEDEFS
131 /* All of these are in stdlib.h or time.h for ANSI C */
133 struct tm *gmtime(), *localtime();
134 #if defined(OEMVS) || defined(__OPEN_VM)
135 char *(strchr)(), *(strrchr)();
136 char *(strcpy)(), *(strcat)();
138 char *strchr(), *strrchr();
139 char *strcpy(), *strcat();
141 #endif /* ! STANDARD_C */
146 # include "../handy.h"
150 #define Nullfp Null(FILE*)
200 #define OSEMICOLON 47
337 extern char *opname[];
346 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
347 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
350 #endif /* 80286 hack */
351 EXT union u_ops ops[OPSMAX];
353 typedef struct string STR;
354 typedef struct htbl HASH;
360 /* A string is TRUE if not "" or "0". */
361 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
362 EXT char *Yes INIT("1");
363 EXT char *No INIT("");
365 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
367 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%"NVgf")",Str->str_nval),buf) : "" )))
368 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
369 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
372 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
374 /* Prototypes for things in a2p.c */
375 int aryrefarg ( int arg );
376 int bl ( int arg, int maybe );
377 void dump ( int branch );
378 int fixfargs ( int name, int arg, int prevargs );
379 int fixrargs ( char *name, int arg, int prevargs );
380 void fixup ( STR *str );
381 int numary ( int arg );
382 int oper0 ( int type );
383 int oper1 ( int type, int arg1 );
384 int oper2 ( int type, int arg1, int arg2 );
385 int oper3 ( int type, int arg1, int arg2, int arg3 );
386 int oper4 ( int type, int arg1, int arg2, int arg3, int arg4 );
387 int oper5 ( int type, int arg1, int arg2, int arg3, int arg4, int arg5 );
388 void putlines ( STR *str );
389 void putone ( void );
390 int rememberargs ( int arg );
391 char * scannum ( char *s );
392 char * scanpat ( char *s );
393 int string ( char *ptr, int len );
394 void yyerror ( char *s );
397 EXT int line INIT(0);
401 EXT char *bufptr INIT(buf);
403 EXT STR *linestr INIT(Nullstr);
405 EXT char tokenbuf[2048];
406 EXT int expectterm INIT(TRUE);
409 EXT int debug INIT(0);
410 EXT int dlevel INIT(0);
419 EXT STR *freestrroot INIT(Nullstr);
424 EXT bool do_split INIT(FALSE);
425 EXT bool split_to_array INIT(FALSE);
426 EXT bool set_array_base INIT(FALSE);
427 EXT bool saw_RS INIT(FALSE);
428 EXT bool saw_OFS INIT(FALSE);
429 EXT bool saw_ORS INIT(FALSE);
430 EXT bool saw_line_op INIT(FALSE);
431 EXT bool in_begin INIT(TRUE);
432 EXT bool do_opens INIT(FALSE);
433 EXT bool do_fancy_opens INIT(FALSE);
434 EXT bool lval_field INIT(FALSE);
435 EXT bool do_chop INIT(FALSE);
436 EXT bool need_entire INIT(FALSE);
437 EXT bool absmaxfld INIT(FALSE);
438 EXT bool saw_altinput INIT(FALSE);
440 EXT bool nomemok INIT(FALSE);
442 EXT char const_FS INIT(0);
443 EXT char *namelist INIT(Nullch);
444 EXT char fswitch INIT(0);
445 EXT bool old_awk INIT(0);
447 EXT int saw_FS INIT(0);
448 EXT int maxfld INIT(0);
449 EXT int arymax INIT(0);
450 EXT char *nameary[100];
455 EXT HASH *curarghash;
470 #define P_FILETEST 65