1 /* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $
3 * Copyright (c) 1991-1997, 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 */
20 # include "../config.h"
23 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
28 #undef USE_STDIO_PTR /* XXX fast gets won't work, must investigate */
32 # if defined(__BORLANDC__)
42 # elif defined(_MSC_VER)
43 # elif defined(__MINGW32__)
47 /* Use all the "standard" definitions? */
48 #if defined(STANDARD_C) && defined(I_STDLIB)
50 #endif /* STANDARD_C */
59 # include <sys/types.h>
64 #if NX_CURRENT_COMPILER_RELEASE >= 400
65 #include <objc/NXCType.h>
66 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
67 #include <appkit/NXCType.h>
68 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
70 #else /* !USE_NEXT_CTYPE */
72 #endif /* USE_NEXT_CTYPE */
74 #define MEM_SIZE Size_t
77 Malloc_t malloc (MEM_SIZE nbytes);
78 Malloc_t calloc (MEM_SIZE elements, MEM_SIZE size);
79 Malloc_t realloc (Malloc_t where, MEM_SIZE nbytes);
80 Free_t free (Malloc_t where);
83 #if defined(I_STRING) || defined(__cplusplus)
89 #if !defined(HAS_BCOPY) || defined(__cplusplus)
90 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
92 #if !defined(HAS_BZERO) || defined(__cplusplus)
93 # define bzero(s,l) memset(s,0,l)
96 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
98 #define strrchr rindex
107 # ifdef I_SYS_TIME_KERNEL
110 # include <sys/time.h>
111 # ifdef I_SYS_TIME_KERNEL
117 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
118 # include <sys/times.h>
124 # include "../os2ish.h"
126 # include "../dosish.h"
130 # define NO_PERL_TYPEDEFS
136 /* All of these are in stdlib.h or time.h for ANSI C */
138 struct tm *gmtime(), *localtime();
139 #if defined(OEMVS) || defined(__OPEN_VM)
140 char *(strchr)(), *(strrchr)();
141 char *(strcpy)(), *(strcat)();
143 char *strchr(), *strrchr();
144 char *strcpy(), *strcat();
146 #endif /* ! STANDARD_C */
151 # include "../handy.h"
155 #define Nullfp Null(FILE*)
205 #define OSEMICOLON 47
342 extern char *opname[];
351 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
352 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
355 #endif /* 80286 hack */
356 EXT union u_ops ops[OPSMAX];
358 typedef struct string STR;
359 typedef struct htbl HASH;
365 /* A string is TRUE if not "" or "0". */
366 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
367 EXT char *Yes INIT("1");
368 EXT char *No INIT("");
370 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
372 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
373 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
374 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
377 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
379 /* Prototypes for things in a2p.c */
380 int aryrefarg ( int arg );
381 int bl ( int arg, int maybe );
382 void dump ( int branch );
383 int fixfargs ( int name, int arg, int prevargs );
384 int fixrargs ( char *name, int arg, int prevargs );
385 void fixup ( STR *str );
386 int numary ( int arg );
387 int oper0 ( int type );
388 int oper1 ( int type, int arg1 );
389 int oper2 ( int type, int arg1, int arg2 );
390 int oper3 ( int type, int arg1, int arg2, int arg3 );
391 int oper4 ( int type, int arg1, int arg2, int arg3, int arg4 );
392 int oper5 ( int type, int arg1, int arg2, int arg3, int arg4, int arg5 );
393 void putlines ( STR *str );
394 void putone ( void );
395 int rememberargs ( int arg );
396 char * scannum ( char *s );
397 char * scanpat ( char *s );
398 int string ( char *ptr, int len );
399 void yyerror ( char *s );
402 EXT int line INIT(0);
406 EXT char *bufptr INIT(buf);
408 EXT STR *linestr INIT(Nullstr);
410 EXT char tokenbuf[2048];
411 EXT int expectterm INIT(TRUE);
414 EXT int debug INIT(0);
415 EXT int dlevel INIT(0);
424 EXT STR *freestrroot INIT(Nullstr);
429 EXT bool do_split INIT(FALSE);
430 EXT bool split_to_array INIT(FALSE);
431 EXT bool set_array_base INIT(FALSE);
432 EXT bool saw_RS INIT(FALSE);
433 EXT bool saw_OFS INIT(FALSE);
434 EXT bool saw_ORS INIT(FALSE);
435 EXT bool saw_line_op INIT(FALSE);
436 EXT bool in_begin INIT(TRUE);
437 EXT bool do_opens INIT(FALSE);
438 EXT bool do_fancy_opens INIT(FALSE);
439 EXT bool lval_field INIT(FALSE);
440 EXT bool do_chop INIT(FALSE);
441 EXT bool need_entire INIT(FALSE);
442 EXT bool absmaxfld INIT(FALSE);
443 EXT bool saw_altinput INIT(FALSE);
445 EXT bool nomemok INIT(FALSE);
447 EXT char const_FS INIT(0);
448 EXT char *namelist INIT(Nullch);
449 EXT char fswitch INIT(0);
450 EXT bool old_awk INIT(0);
452 EXT int saw_FS INIT(0);
453 EXT int maxfld INIT(0);
454 EXT int arymax INIT(0);
455 EXT char *nameary[100];
460 EXT HASH *curarghash;
475 #define P_FILETEST 65