1N/A/* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $
1N/A *
1N/A * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
1N/A * 2000, 2001, 2002, by Larry Wall and others
1N/A *
1N/A * You may distribute under the terms of either the GNU General Public
1N/A * License or the Artistic License, as specified in the README file.
1N/A *
1N/A * $Log: a2p.h,v $
1N/A */
1N/A
1N/A#define VOIDUSED 1
1N/A
1N/A#ifdef WIN32
1N/A#define _INC_WIN32_PERL5 /* kludge around win32 stdio layer */
1N/A#endif
1N/A
1N/A#ifdef VMS
1N/A# include "config.h"
1N/A#elif defined(NETWARE)
1N/A# include "../NetWare/config.h"
1N/A#else
1N/A# include "../config.h"
1N/A#endif
1N/A
1N/A#if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
1N/A# define STANDARD_C 1
1N/A#endif
1N/A
1N/A#ifdef WIN32
1N/A#undef USE_STDIO_PTR /* XXX fast gets won't work, must investigate */
1N/A# ifndef STANDARD_C
1N/A# define STANDARD_C
1N/A# endif
1N/A# if defined(__BORLANDC__)
1N/A# pragma warn -ccc
1N/A# pragma warn -rch
1N/A# pragma warn -sig
1N/A# pragma warn -pia
1N/A# pragma warn -par
1N/A# pragma warn -aus
1N/A# pragma warn -use
1N/A# pragma warn -csu
1N/A# pragma warn -pro
1N/A# elif defined(_MSC_VER)
1N/A# elif defined(__MINGW32__)
1N/A# endif
1N/A#endif
1N/A
1N/A/* Use all the "standard" definitions? */
1N/A#if defined(STANDARD_C) && defined(I_STDLIB)
1N/A# include <stdlib.h>
1N/A#endif /* STANDARD_C */
1N/A
1N/A#include <stdio.h>
1N/A
1N/A#ifdef I_MATH
1N/A#include <math.h>
1N/A#endif
1N/A
1N/A#ifdef I_SYS_TYPES
1N/A# include <sys/types.h>
1N/A#endif
1N/A
1N/A#ifdef USE_NEXT_CTYPE
1N/A
1N/A#if NX_CURRENT_COMPILER_RELEASE >= 400
1N/A#include <objc/NXCType.h>
1N/A#else /* NX_CURRENT_COMPILER_RELEASE < 400 */
1N/A#include <appkit/NXCType.h>
1N/A#endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
1N/A
1N/A#else /* !USE_NEXT_CTYPE */
1N/A#include <ctype.h>
1N/A#endif /* USE_NEXT_CTYPE */
1N/A
1N/A#define MEM_SIZE Size_t
1N/A
1N/A#ifndef STANDARD_C
1N/A Malloc_t malloc (MEM_SIZE nbytes);
1N/A Malloc_t calloc (MEM_SIZE elements, MEM_SIZE size);
1N/A Malloc_t realloc (Malloc_t where, MEM_SIZE nbytes);
1N/A Free_t free (Malloc_t where);
1N/A#endif
1N/A
1N/A#if defined(I_STRING) || defined(__cplusplus)
1N/A# include <string.h>
1N/A#else
1N/A# include <strings.h>
1N/A#endif
1N/A
1N/A#if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
1N/A#define strchr index
1N/A#define strrchr rindex
1N/A#endif
1N/A
1N/A#ifdef I_TIME
1N/A# include <time.h>
1N/A#endif
1N/A
1N/A#ifdef I_SYS_TIME
1N/A# ifdef I_SYS_TIME_KERNEL
1N/A# define KERNEL
1N/A# endif
1N/A# include <sys/time.h>
1N/A# ifdef I_SYS_TIME_KERNEL
1N/A# undef KERNEL
1N/A# endif
1N/A#endif
1N/A
1N/A#ifndef MSDOS
1N/A# if defined(HAS_TIMES) && defined(I_SYS_TIMES)
1N/A# include <sys/times.h>
1N/A# endif
1N/A#endif
1N/A
1N/A#ifdef DOSISH
1N/A# if defined(OS2)
1N/A# define PTHX_UNUSED
1N/A# include "../os2ish.h"
1N/A# else
1N/A# include "../dosish.h"
1N/A# endif
1N/A#else
1N/A# if defined(VMS)
1N/A# define NO_PERL_TYPEDEFS
1N/A# include "vmsish.h"
1N/A# endif
1N/A#endif
1N/A
1N/A#ifndef STANDARD_C
1N/A/* All of these are in stdlib.h or time.h for ANSI C */
1N/ATime_t time();
1N/Astruct tm *gmtime(), *localtime();
1N/A#if defined(OEMVS) || defined(__OPEN_VM)
1N/Achar *(strchr)(), *(strrchr)();
1N/Achar *(strcpy)(), *(strcat)();
1N/A#else
1N/Achar *strchr(), *strrchr();
1N/Achar *strcpy(), *strcat();
1N/A#endif
1N/A#endif /* ! STANDARD_C */
1N/A
1N/A#ifdef VMS
1N/A# include "handy.h"
1N/A#else
1N/A# include "../handy.h"
1N/A#endif
1N/A
1N/A#undef Nullfp
1N/A#define Nullfp Null(FILE*)
1N/A
1N/A#define Nullop 0
1N/A
1N/A#define OPROG 1
1N/A#define OJUNK 2
1N/A#define OHUNKS 3
1N/A#define ORANGE 4
1N/A#define OPAT 5
1N/A#define OHUNK 6
1N/A#define OPPAREN 7
1N/A#define OPANDAND 8
1N/A#define OPOROR 9
1N/A#define OPNOT 10
1N/A#define OCPAREN 11
1N/A#define OCANDAND 12
1N/A#define OCOROR 13
1N/A#define OCNOT 14
1N/A#define ORELOP 15
1N/A#define ORPAREN 16
1N/A#define OMATCHOP 17
1N/A#define OMPAREN 18
1N/A#define OCONCAT 19
1N/A#define OASSIGN 20
1N/A#define OADD 21
1N/A#define OSUBTRACT 22
1N/A#define OMULT 23
1N/A#define ODIV 24
1N/A#define OMOD 25
1N/A#define OPOSTINCR 26
1N/A#define OPOSTDECR 27
1N/A#define OPREINCR 28
1N/A#define OPREDECR 29
1N/A#define OUMINUS 30
1N/A#define OUPLUS 31
1N/A#define OPAREN 32
1N/A#define OGETLINE 33
1N/A#define OSPRINTF 34
1N/A#define OSUBSTR 35
1N/A#define OSTRING 36
1N/A#define OSPLIT 37
1N/A#define OSNEWLINE 38
1N/A#define OINDEX 39
1N/A#define ONUM 40
1N/A#define OSTR 41
1N/A#define OVAR 42
1N/A#define OFLD 43
1N/A#define ONEWLINE 44
1N/A#define OCOMMENT 45
1N/A#define OCOMMA 46
1N/A#define OSEMICOLON 47
1N/A#define OSCOMMENT 48
1N/A#define OSTATES 49
1N/A#define OSTATE 50
1N/A#define OPRINT 51
1N/A#define OPRINTF 52
1N/A#define OBREAK 53
1N/A#define ONEXT 54
1N/A#define OEXIT 55
1N/A#define OCONTINUE 56
1N/A#define OREDIR 57
1N/A#define OIF 58
1N/A#define OWHILE 59
1N/A#define OFOR 60
1N/A#define OFORIN 61
1N/A#define OVFLD 62
1N/A#define OBLOCK 63
1N/A#define OREGEX 64
1N/A#define OLENGTH 65
1N/A#define OLOG 66
1N/A#define OEXP 67
1N/A#define OSQRT 68
1N/A#define OINT 69
1N/A#define ODO 70
1N/A#define OPOW 71
1N/A#define OSUB 72
1N/A#define OGSUB 73
1N/A#define OMATCH 74
1N/A#define OUSERFUN 75
1N/A#define OUSERDEF 76
1N/A#define OCLOSE 77
1N/A#define OATAN2 78
1N/A#define OSIN 79
1N/A#define OCOS 80
1N/A#define ORAND 81
1N/A#define OSRAND 82
1N/A#define ODELETE 83
1N/A#define OSYSTEM 84
1N/A#define OCOND 85
1N/A#define ORETURN 86
1N/A#define ODEFINED 87
1N/A#define OSTAR 88
1N/A
1N/A#ifdef DOINIT
1N/Achar *opname[] = {
1N/A "0",
1N/A "PROG",
1N/A "JUNK",
1N/A "HUNKS",
1N/A "RANGE",
1N/A "PAT",
1N/A "HUNK",
1N/A "PPAREN",
1N/A "PANDAND",
1N/A "POROR",
1N/A "PNOT",
1N/A "CPAREN",
1N/A "CANDAND",
1N/A "COROR",
1N/A "CNOT",
1N/A "RELOP",
1N/A "RPAREN",
1N/A "MATCHOP",
1N/A "MPAREN",
1N/A "CONCAT",
1N/A "ASSIGN",
1N/A "ADD",
1N/A "SUBTRACT",
1N/A "MULT",
1N/A "DIV",
1N/A "MOD",
1N/A "POSTINCR",
1N/A "POSTDECR",
1N/A "PREINCR",
1N/A "PREDECR",
1N/A "UMINUS",
1N/A "UPLUS",
1N/A "PAREN",
1N/A "GETLINE",
1N/A "SPRINTF",
1N/A "SUBSTR",
1N/A "STRING",
1N/A "SPLIT",
1N/A "SNEWLINE",
1N/A "INDEX",
1N/A "NUM",
1N/A "STR",
1N/A "VAR",
1N/A "FLD",
1N/A "NEWLINE",
1N/A "COMMENT",
1N/A "COMMA",
1N/A "SEMICOLON",
1N/A "SCOMMENT",
1N/A "STATES",
1N/A "STATE",
1N/A "PRINT",
1N/A "PRINTF",
1N/A "BREAK",
1N/A "NEXT",
1N/A "EXIT",
1N/A "CONTINUE",
1N/A "REDIR",
1N/A "IF",
1N/A "WHILE",
1N/A "FOR",
1N/A "FORIN",
1N/A "VFLD",
1N/A "BLOCK",
1N/A "REGEX",
1N/A "LENGTH",
1N/A "LOG",
1N/A "EXP",
1N/A "SQRT",
1N/A "INT",
1N/A "DO",
1N/A "POW",
1N/A "SUB",
1N/A "GSUB",
1N/A "MATCH",
1N/A "USERFUN",
1N/A "USERDEF",
1N/A "CLOSE",
1N/A "ATAN2",
1N/A "SIN",
1N/A "COS",
1N/A "RAND",
1N/A "SRAND",
1N/A "DELETE",
1N/A "SYSTEM",
1N/A "COND",
1N/A "RETURN",
1N/A "DEFINED",
1N/A "STAR",
1N/A "89"
1N/A};
1N/A#else
1N/Aextern char *opname[];
1N/A#endif
1N/A
1N/AEXT int mop INIT(1);
1N/A
1N/Aunion u_ops {
1N/A int ival;
1N/A char *cval;
1N/A};
1N/A#if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
1N/A#define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
1N/A#else
1N/A#define OPSMAX 50000
1N/A#endif /* 80286 hack */
1N/AEXT union u_ops ops[OPSMAX];
1N/A
1N/Atypedef struct string STR;
1N/Atypedef struct htbl HASH;
1N/A
1N/A#include "str.h"
1N/A#include "hash.h"
1N/A
1N/A
1N/A/* A string is TRUE if not "" or "0". */
1N/A#define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
1N/AEXT char *Yes INIT("1");
1N/AEXT char *No INIT("");
1N/A
1N/A#define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
1N/A
1N/A#define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%"NVgf")",Str->str_nval),buf) : "" )))
1N/A#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
1N/A#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
1N/AEXT STR *Str;
1N/A
1N/A#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
1N/A
1N/A/* Prototypes for things in a2p.c */
1N/Aint aryrefarg ( int arg );
1N/Aint bl ( int arg, int maybe );
1N/Avoid dump ( int branch );
1N/Aint fixfargs ( int name, int arg, int prevargs );
1N/Aint fixrargs ( char *name, int arg, int prevargs );
1N/Avoid fixup ( STR *str );
1N/Aint numary ( int arg );
1N/Aint oper0 ( int type );
1N/Aint oper1 ( int type, int arg1 );
1N/Aint oper2 ( int type, int arg1, int arg2 );
1N/Aint oper3 ( int type, int arg1, int arg2, int arg3 );
1N/Aint oper4 ( int type, int arg1, int arg2, int arg3, int arg4 );
1N/Aint oper5 ( int type, int arg1, int arg2, int arg3, int arg4, int arg5 );
1N/Avoid putlines ( STR *str );
1N/Avoid putone ( void );
1N/Aint rememberargs ( int arg );
1N/Achar * scannum ( char *s );
1N/Achar * scanpat ( char *s );
1N/Aint string ( char *ptr, int len );
1N/Avoid yyerror ( char *s );
1N/Aint yylex ( void );
1N/A
1N/AEXT int line INIT(0);
1N/A
1N/AEXT FILE *rsfp;
1N/AEXT char buf[2048];
1N/AEXT char *bufptr INIT(buf);
1N/A
1N/AEXT STR *linestr INIT(Nullstr);
1N/A
1N/AEXT char tokenbuf[2048];
1N/AEXT int expectterm INIT(TRUE);
1N/A
1N/A#ifdef DEBUGGING
1N/AEXT int debug INIT(0);
1N/AEXT int dlevel INIT(0);
1N/A#define YYDEBUG 1
1N/Aextern int yydebug;
1N/A#else
1N/A# ifndef YYDEBUG
1N/A# define YYDEBUG 0
1N/A# endif
1N/A#endif
1N/A
1N/AEXT STR *freestrroot INIT(Nullstr);
1N/A
1N/AEXT STR str_no;
1N/AEXT STR str_yes;
1N/A
1N/AEXT bool do_split INIT(FALSE);
1N/AEXT bool split_to_array INIT(FALSE);
1N/AEXT bool set_array_base INIT(FALSE);
1N/AEXT bool saw_RS INIT(FALSE);
1N/AEXT bool saw_OFS INIT(FALSE);
1N/AEXT bool saw_ORS INIT(FALSE);
1N/AEXT bool saw_line_op INIT(FALSE);
1N/AEXT bool in_begin INIT(TRUE);
1N/AEXT bool do_opens INIT(FALSE);
1N/AEXT bool do_fancy_opens INIT(FALSE);
1N/AEXT bool lval_field INIT(FALSE);
1N/AEXT bool do_chop INIT(FALSE);
1N/AEXT bool need_entire INIT(FALSE);
1N/AEXT bool absmaxfld INIT(FALSE);
1N/AEXT bool saw_altinput INIT(FALSE);
1N/A
1N/AEXT bool nomemok INIT(FALSE);
1N/A
1N/AEXT char const_FS INIT(0);
1N/AEXT char *namelist INIT(Nullch);
1N/AEXT char fswitch INIT(0);
1N/AEXT bool old_awk INIT(0);
1N/A
1N/AEXT int saw_FS INIT(0);
1N/AEXT int maxfld INIT(0);
1N/AEXT int arymax INIT(0);
1N/AEXT char *nameary[100];
1N/A
1N/AEXT STR *opens;
1N/A
1N/AEXT HASH *symtab;
1N/AEXT HASH *curarghash;
1N/A
1N/A#define P_MIN 0
1N/A#define P_LISTOP 5
1N/A#define P_COMMA 10
1N/A#define P_ASSIGN 15
1N/A#define P_COND 20
1N/A#define P_DOTDOT 25
1N/A#define P_OROR 30
1N/A#define P_ANDAND 35
1N/A#define P_OR 40
1N/A#define P_AND 45
1N/A#define P_EQ 50
1N/A#define P_REL 55
1N/A#define P_UNI 60
1N/A#define P_FILETEST 65
1N/A#define P_SHIFT 70
1N/A#define P_ADD 75
1N/A#define P_MUL 80
1N/A#define P_MATCH 85
1N/A#define P_UNARY 90
1N/A#define P_POW 95
1N/A#define P_AUTO 100
1N/A#define P_MAX 999
1N/A
1N/AEXT int an;