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
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_BCOPY) || defined(__cplusplus)
92 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
94 #if !defined(HAS_BZERO) || defined(__cplusplus)
95 # define bzero(s,l) memset(s,0,l)
98 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
100 #define strrchr rindex
109 # ifdef I_SYS_TIME_KERNEL
112 # include <sys/time.h>
113 # ifdef I_SYS_TIME_KERNEL
119 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
120 # include <sys/times.h>
126 # include "../os2ish.h"
128 # include "../dosish.h"
132 # define NO_PERL_TYPEDEFS
138 /* All of these are in stdlib.h or time.h for ANSI C */
140 struct tm *gmtime(), *localtime();
141 #if defined(OEMVS) || defined(__OPEN_VM)
142 char *(strchr)(), *(strrchr)();
143 char *(strcpy)(), *(strcat)();
145 char *strchr(), *strrchr();
146 char *strcpy(), *strcat();
148 #endif /* ! STANDARD_C */
153 # include "../handy.h"
157 #define Nullfp Null(FILE*)
207 #define OSEMICOLON 47
344 extern char *opname[];
353 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
354 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
357 #endif /* 80286 hack */
358 EXT union u_ops ops[OPSMAX];
360 typedef struct string STR;
361 typedef struct htbl HASH;
367 /* A string is TRUE if not "" or "0". */
368 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
369 EXT char *Yes INIT("1");
370 EXT char *No INIT("");
372 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
374 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
375 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
376 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
379 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
381 /* Prototypes for things in a2p.c */
382 int aryrefarg ( int arg );
383 int bl ( int arg, int maybe );
384 void dump ( int branch );
385 int fixfargs ( int name, int arg, int prevargs );
386 int fixrargs ( char *name, int arg, int prevargs );
387 void fixup ( STR *str );
388 int numary ( int arg );
389 int oper0 ( int type );
390 int oper1 ( int type, int arg1 );
391 int oper2 ( int type, int arg1, int arg2 );
392 int oper3 ( int type, int arg1, int arg2, int arg3 );
393 int oper4 ( int type, int arg1, int arg2, int arg3, int arg4 );
394 int oper5 ( int type, int arg1, int arg2, int arg3, int arg4, int arg5 );
395 void putlines ( STR *str );
396 void putone ( void );
397 int rememberargs ( int arg );
398 char * scannum ( char *s );
399 char * scanpat ( char *s );
400 int string ( char *ptr, int len );
401 void yyerror ( char *s );
404 EXT int line INIT(0);
408 EXT char *bufptr INIT(buf);
410 EXT STR *linestr INIT(Nullstr);
412 EXT char tokenbuf[2048];
413 EXT int expectterm INIT(TRUE);
416 EXT int debug INIT(0);
417 EXT int dlevel INIT(0);
426 EXT STR *freestrroot INIT(Nullstr);
431 EXT bool do_split INIT(FALSE);
432 EXT bool split_to_array INIT(FALSE);
433 EXT bool set_array_base INIT(FALSE);
434 EXT bool saw_RS INIT(FALSE);
435 EXT bool saw_OFS INIT(FALSE);
436 EXT bool saw_ORS INIT(FALSE);
437 EXT bool saw_line_op INIT(FALSE);
438 EXT bool in_begin INIT(TRUE);
439 EXT bool do_opens INIT(FALSE);
440 EXT bool do_fancy_opens INIT(FALSE);
441 EXT bool lval_field INIT(FALSE);
442 EXT bool do_chop INIT(FALSE);
443 EXT bool need_entire INIT(FALSE);
444 EXT bool absmaxfld INIT(FALSE);
445 EXT bool saw_altinput INIT(FALSE);
447 EXT bool nomemok INIT(FALSE);
449 EXT char const_FS INIT(0);
450 EXT char *namelist INIT(Nullch);
451 EXT char fswitch INIT(0);
452 EXT bool old_awk INIT(0);
454 EXT int saw_FS INIT(0);
455 EXT int maxfld INIT(0);
456 EXT int arymax INIT(0);
457 EXT char *nameary[100];
462 EXT HASH *curarghash;
477 #define P_FILETEST 65