1 /* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $
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.
15 #define _INC_WIN32_PERL5 /* kludge around win32 stdio layer */
20 #elif defined(NETWARE)
21 # include "../NetWare/config.h"
23 # include "../config.h"
26 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
31 #undef USE_STDIO_PTR /* XXX fast gets won't work, must investigate */
35 # if defined(__BORLANDC__)
45 # elif defined(_MSC_VER)
46 # elif defined(__MINGW32__)
50 /* Use all the "standard" definitions? */
51 #if defined(STANDARD_C) && defined(I_STDLIB)
53 #endif /* STANDARD_C */
62 # include <sys/types.h>
67 #if NX_CURRENT_COMPILER_RELEASE >= 400
68 #include <objc/NXCType.h>
69 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
70 #include <appkit/NXCType.h>
71 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
73 #else /* !USE_NEXT_CTYPE */
75 #endif /* USE_NEXT_CTYPE */
77 #define MEM_SIZE Size_t
80 Malloc_t malloc (MEM_SIZE nbytes);
81 Malloc_t calloc (MEM_SIZE elements, MEM_SIZE size);
82 Malloc_t realloc (Malloc_t where, MEM_SIZE nbytes);
83 Free_t free (Malloc_t where);
86 #if defined(I_STRING) || defined(__cplusplus)
92 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
94 #define strrchr rindex
102 # ifdef I_SYS_TIME_KERNEL
105 # include <sys/time.h>
106 # ifdef I_SYS_TIME_KERNEL
112 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
113 # include <sys/times.h>
120 # include "../os2ish.h"
122 # include "../dosish.h"
126 # define NO_PERL_TYPEDEFS
132 /* All of these are in stdlib.h or time.h for ANSI C */
134 struct tm *gmtime(), *localtime();
135 #if defined(OEMVS) || defined(__OPEN_VM)
136 char *(strchr)(), *(strrchr)();
137 char *(strcpy)(), *(strcat)();
139 char *strchr(), *strrchr();
140 char *strcpy(), *strcat();
142 #endif /* ! STANDARD_C */
147 # include "../handy.h"
151 #define Nullfp Null(FILE*)
201 #define OSEMICOLON 47
338 extern char *opname[];
347 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
348 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
351 #endif /* 80286 hack */
352 EXT union u_ops ops[OPSMAX];
354 typedef struct string STR;
355 typedef struct htbl HASH;
361 /* A string is TRUE if not "" or "0". */
362 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
363 EXT char *Yes INIT("1");
364 EXT char *No INIT("");
366 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
368 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%"NVgf")",Str->str_nval),buf) : "" )))
369 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
370 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
373 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
375 /* Prototypes for things in a2p.c */
376 int aryrefarg ( int arg );
377 int bl ( int arg, int maybe );
378 void dump ( int branch );
379 int fixfargs ( int name, int arg, int prevargs );
380 int fixrargs ( char *name, int arg, int prevargs );
381 void fixup ( STR *str );
382 int numary ( int arg );
383 int oper0 ( int type );
384 int oper1 ( int type, int arg1 );
385 int oper2 ( int type, int arg1, int arg2 );
386 int oper3 ( int type, int arg1, int arg2, int arg3 );
387 int oper4 ( int type, int arg1, int arg2, int arg3, int arg4 );
388 int oper5 ( int type, int arg1, int arg2, int arg3, int arg4, int arg5 );
389 void putlines ( STR *str );
390 void putone ( void );
391 int rememberargs ( int arg );
392 char * scannum ( char *s );
393 char * scanpat ( char *s );
394 int string ( char *ptr, int len );
395 void yyerror ( char *s );
398 EXT int line INIT(0);
402 EXT char *bufptr INIT(buf);
404 EXT STR *linestr INIT(Nullstr);
406 EXT char tokenbuf[2048];
407 EXT int expectterm INIT(TRUE);
410 EXT int debug INIT(0);
411 EXT int dlevel INIT(0);
420 EXT STR *freestrroot INIT(Nullstr);
425 EXT bool do_split INIT(FALSE);
426 EXT bool split_to_array INIT(FALSE);
427 EXT bool set_array_base INIT(FALSE);
428 EXT bool saw_RS INIT(FALSE);
429 EXT bool saw_OFS INIT(FALSE);
430 EXT bool saw_ORS INIT(FALSE);
431 EXT bool saw_line_op INIT(FALSE);
432 EXT bool in_begin INIT(TRUE);
433 EXT bool do_opens INIT(FALSE);
434 EXT bool do_fancy_opens INIT(FALSE);
435 EXT bool lval_field INIT(FALSE);
436 EXT bool do_chop INIT(FALSE);
437 EXT bool need_entire INIT(FALSE);
438 EXT bool absmaxfld INIT(FALSE);
439 EXT bool saw_altinput INIT(FALSE);
441 EXT bool nomemok INIT(FALSE);
443 EXT char const_FS INIT(0);
444 EXT char *namelist INIT(Nullch);
445 EXT char fswitch INIT(0);
446 EXT bool old_awk INIT(0);
448 EXT int saw_FS INIT(0);
449 EXT int maxfld INIT(0);
450 EXT int arymax INIT(0);
451 EXT char *nameary[100];
456 EXT HASH *curarghash;
471 #define P_FILETEST 65