1 /* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 1996/07/05 23:49:58 $
3 * Copyright (c) 1991, 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.
9 * Revision 1.2 1996/07/05 23:49:58 gerti
10 * OPENSTEP 4.0 patches
16 #include "../config.h"
18 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
22 /* Use all the "standard" definitions? */
23 #if defined(STANDARD_C) && defined(I_STDLIB)
25 #endif /* STANDARD_C */
34 # include <sys/types.h>
40 #if NX_CURRENT_COMPILER_RELEASE >= 400
41 #include <objc/NXCType.h>
42 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
43 #include <appkit/NXCType.h>
44 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
46 #else /* !USE_NEXT_CTYPE */
48 #endif /* USE_NEXT_CTYPE */
50 #define MEM_SIZE Size_t
52 #if defined(I_STRING) || defined(__cplusplus)
59 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
62 # define bzero(s,l) memset(s,0,l)
65 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
67 #define strrchr rindex
76 # ifdef I_SYS_TIME_KERNEL
79 # include <sys/time.h>
80 # ifdef I_SYS_TIME_KERNEL
86 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
87 # include <sys/times.h>
93 # include "../os2ish.h"
95 # include "../dosish.h"
99 # include "../vmsish.h"
104 /* All of these are in stdlib.h or time.h for ANSI C */
106 struct tm *gmtime(), *localtime();
107 char *strchr(), *strrchr();
108 char *strcpy(), *strcat();
109 #endif /* ! STANDARD_C */
160 #define OSEMICOLON 47
297 extern char *opname[];
306 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
307 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
310 #endif /* 80286 hack */
311 EXT union u_ops ops[OPSMAX];
313 typedef struct string STR;
314 typedef struct htbl HASH;
320 /* A string is TRUE if not "" or "0". */
321 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
322 EXT char *Yes INIT("1");
323 EXT char *No INIT("");
325 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
327 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
328 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
329 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
332 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
334 /* Prototypes for things in a2p.c */
335 int aryrefarg _(( int arg ));
336 int bl _(( int arg, int maybe ));
337 void dump _(( int branch ));
338 int fixfargs _(( int name, int arg, int prevargs ));
339 int fixrargs _(( char *name, int arg, int prevargs ));
340 void fixup _(( STR *str ));
341 int numary _(( int arg ));
342 int oper0 _(( int type ));
343 int oper1 _(( int type, int arg1 ));
344 int oper2 _(( int type, int arg1, int arg2 ));
345 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
346 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
347 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
348 void putlines _(( STR *str ));
349 void putone _(( void ));
350 int rememberargs _(( int arg ));
351 char * scannum _(( char *s ));
352 char * scanpat _(( char *s ));
353 int string _(( char *ptr, int len ));
354 void yyerror _(( char *s ));
355 int yylex _(( void ));
357 EXT int line INIT(0);
361 EXT char *bufptr INIT(buf);
363 EXT STR *linestr INIT(Nullstr);
365 EXT char tokenbuf[2048];
366 EXT int expectterm INIT(TRUE);
369 EXT int debug INIT(0);
370 EXT int dlevel INIT(0);
375 EXT STR *freestrroot INIT(Nullstr);
380 EXT bool do_split INIT(FALSE);
381 EXT bool split_to_array INIT(FALSE);
382 EXT bool set_array_base INIT(FALSE);
383 EXT bool saw_RS INIT(FALSE);
384 EXT bool saw_OFS INIT(FALSE);
385 EXT bool saw_ORS INIT(FALSE);
386 EXT bool saw_line_op INIT(FALSE);
387 EXT bool in_begin INIT(TRUE);
388 EXT bool do_opens INIT(FALSE);
389 EXT bool do_fancy_opens INIT(FALSE);
390 EXT bool lval_field INIT(FALSE);
391 EXT bool do_chop INIT(FALSE);
392 EXT bool need_entire INIT(FALSE);
393 EXT bool absmaxfld INIT(FALSE);
394 EXT bool saw_altinput INIT(FALSE);
396 EXT bool nomemok INIT(FALSE);
398 EXT char const_FS INIT(0);
399 EXT char *namelist INIT(Nullch);
400 EXT char fswitch INIT(0);
402 EXT int saw_FS INIT(0);
403 EXT int maxfld INIT(0);
404 EXT int arymax INIT(0);
405 EXT char *nameary[100];
410 EXT HASH *curarghash;
425 #define P_FILETEST 65