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 char *strchr(), *strrchr();
142 char *strcpy(), *strcat();
143 #endif /* ! STANDARD_C */
148 # include "../handy.h"
152 #define Nullfp Null(FILE*)
202 #define OSEMICOLON 47
339 extern char *opname[];
348 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
349 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
352 #endif /* 80286 hack */
353 EXT union u_ops ops[OPSMAX];
355 typedef struct string STR;
356 typedef struct htbl HASH;
362 /* A string is TRUE if not "" or "0". */
363 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
364 EXT char *Yes INIT("1");
365 EXT char *No INIT("");
367 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
369 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
370 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
371 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
374 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
376 /* Prototypes for things in a2p.c */
377 int aryrefarg _(( int arg ));
378 int bl _(( int arg, int maybe ));
379 void dump _(( int branch ));
380 int fixfargs _(( int name, int arg, int prevargs ));
381 int fixrargs _(( char *name, int arg, int prevargs ));
382 void fixup _(( STR *str ));
383 int numary _(( int arg ));
384 int oper0 _(( int type ));
385 int oper1 _(( int type, int arg1 ));
386 int oper2 _(( int type, int arg1, int arg2 ));
387 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
388 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
389 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
390 void putlines _(( STR *str ));
391 void putone _(( void ));
392 int rememberargs _(( int arg ));
393 char * scannum _(( char *s ));
394 char * scanpat _(( char *s ));
395 int string _(( char *ptr, int len ));
396 void yyerror _(( char *s ));
397 int yylex _(( void ));
399 EXT int line INIT(0);
403 EXT char *bufptr INIT(buf);
405 EXT STR *linestr INIT(Nullstr);
407 EXT char tokenbuf[2048];
408 EXT int expectterm INIT(TRUE);
411 EXT int debug INIT(0);
412 EXT int dlevel INIT(0);
421 EXT STR *freestrroot INIT(Nullstr);
426 EXT bool do_split INIT(FALSE);
427 EXT bool split_to_array INIT(FALSE);
428 EXT bool set_array_base INIT(FALSE);
429 EXT bool saw_RS INIT(FALSE);
430 EXT bool saw_OFS INIT(FALSE);
431 EXT bool saw_ORS INIT(FALSE);
432 EXT bool saw_line_op INIT(FALSE);
433 EXT bool in_begin INIT(TRUE);
434 EXT bool do_opens INIT(FALSE);
435 EXT bool do_fancy_opens INIT(FALSE);
436 EXT bool lval_field INIT(FALSE);
437 EXT bool do_chop INIT(FALSE);
438 EXT bool need_entire INIT(FALSE);
439 EXT bool absmaxfld INIT(FALSE);
440 EXT bool saw_altinput INIT(FALSE);
442 EXT bool nomemok INIT(FALSE);
444 EXT char const_FS INIT(0);
445 EXT char *namelist INIT(Nullch);
446 EXT char fswitch INIT(0);
447 EXT bool old_awk INIT(0);
449 EXT int saw_FS INIT(0);
450 EXT int maxfld INIT(0);
451 EXT int arymax INIT(0);
452 EXT char *nameary[100];
457 EXT HASH *curarghash;
472 #define P_FILETEST 65