perl5.000 patch.0j: fix minor portability and build problems remaining even after...
[p5sagit/p5-mst-13.2.git] / x2p / a2p.h
CommitLineData
79072805 1/* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $
a687059c 2 *
2b317908 3 * Copyright (c) 1991, Larry Wall
a687059c 4 *
2b317908 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.
8d063cd8 7 *
8 * $Log: a2p.h,v $
8d063cd8 9 */
10
be04251a 11#define VOIDUSED 1
12#include "../config.h"
13
1aef975c 14#if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
15# define STANDARD_C 1
16#endif
17
9c8d0b29 18/* Use all the "standard" definitions? */
19#if defined(STANDARD_C) && defined(I_STDLIB)
20# include <stdlib.h>
21#endif /* STANDARD_C */
22#include <stdio.h>
23
24#ifdef I_MATH
25#include <math.h>
26#endif
27
28#ifdef USE_NEXT_CTYPE
29#include <appkit/NXCType.h>
30#else
31#include <ctype.h>
32#endif
33
34#define MEM_SIZE Size_t
35
36#if defined(I_STRING) || defined(__cplusplus)
37# include <string.h>
38#else
39# include <strings.h>
40#endif
41
75f92628 42#ifndef HAS_BCOPY
43# define bcopy(s1,s2,l) memcpy(s2,s1,l)
44#endif
45#ifndef HAS_BZERO
46# define bzero(s,l) memset(s,0,l)
47#endif
48
9c8d0b29 49#if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
50#define strchr index
51#define strrchr rindex
52#endif
53
1aef975c 54
55#ifdef I_TIME
56# include <time.h>
57#endif
58
59#ifdef I_SYS_TIME
60# ifdef I_SYS_TIME_KERNEL
61# define KERNEL
62# endif
63# include <sys/time.h>
64# ifdef I_SYS_TIME_KERNEL
65# undef KERNEL
66# endif
67#endif
68
69#ifndef MSDOS
70# if defined(HAS_TIMES) && defined(I_SYS_TIMES)
71# include <sys/times.h>
72# endif
73#endif
74
75#ifndef STANDARD_C
76/* All of these are in stdlib.h or time.h for ANSI C */
77Time_t time();
78struct tm *gmtime(), *localtime();
79char *strchr(), *strrchr();
80char *strcpy(), *strcat();
81#endif /* ! STANDARD_C */
82
8d063cd8 83#include "handy.h"
84#define Nullop 0
85
86#define OPROG 1
87#define OJUNK 2
88#define OHUNKS 3
89#define ORANGE 4
90#define OPAT 5
91#define OHUNK 6
92#define OPPAREN 7
93#define OPANDAND 8
94#define OPOROR 9
95#define OPNOT 10
96#define OCPAREN 11
97#define OCANDAND 12
98#define OCOROR 13
99#define OCNOT 14
100#define ORELOP 15
101#define ORPAREN 16
102#define OMATCHOP 17
103#define OMPAREN 18
104#define OCONCAT 19
105#define OASSIGN 20
106#define OADD 21
a687059c 107#define OSUBTRACT 22
8d063cd8 108#define OMULT 23
109#define ODIV 24
110#define OMOD 25
111#define OPOSTINCR 26
112#define OPOSTDECR 27
113#define OPREINCR 28
114#define OPREDECR 29
115#define OUMINUS 30
116#define OUPLUS 31
117#define OPAREN 32
118#define OGETLINE 33
119#define OSPRINTF 34
120#define OSUBSTR 35
121#define OSTRING 36
122#define OSPLIT 37
123#define OSNEWLINE 38
124#define OINDEX 39
125#define ONUM 40
126#define OSTR 41
127#define OVAR 42
128#define OFLD 43
129#define ONEWLINE 44
130#define OCOMMENT 45
131#define OCOMMA 46
132#define OSEMICOLON 47
133#define OSCOMMENT 48
134#define OSTATES 49
135#define OSTATE 50
136#define OPRINT 51
137#define OPRINTF 52
138#define OBREAK 53
139#define ONEXT 54
140#define OEXIT 55
141#define OCONTINUE 56
142#define OREDIR 57
143#define OIF 58
144#define OWHILE 59
145#define OFOR 60
146#define OFORIN 61
147#define OVFLD 62
148#define OBLOCK 63
149#define OREGEX 64
150#define OLENGTH 65
151#define OLOG 66
152#define OEXP 67
153#define OSQRT 68
154#define OINT 69
a687059c 155#define ODO 70
156#define OPOW 71
157#define OSUB 72
158#define OGSUB 73
159#define OMATCH 74
160#define OUSERFUN 75
161#define OUSERDEF 76
162#define OCLOSE 77
163#define OATAN2 78
164#define OSIN 79
165#define OCOS 80
166#define ORAND 81
167#define OSRAND 82
168#define ODELETE 83
169#define OSYSTEM 84
170#define OCOND 85
171#define ORETURN 86
172#define ODEFINED 87
173#define OSTAR 88
8d063cd8 174
175#ifdef DOINIT
176char *opname[] = {
177 "0",
178 "PROG",
179 "JUNK",
180 "HUNKS",
181 "RANGE",
182 "PAT",
183 "HUNK",
184 "PPAREN",
185 "PANDAND",
186 "POROR",
187 "PNOT",
188 "CPAREN",
189 "CANDAND",
190 "COROR",
191 "CNOT",
192 "RELOP",
193 "RPAREN",
194 "MATCHOP",
195 "MPAREN",
196 "CONCAT",
197 "ASSIGN",
198 "ADD",
a687059c 199 "SUBTRACT",
8d063cd8 200 "MULT",
201 "DIV",
202 "MOD",
203 "POSTINCR",
204 "POSTDECR",
205 "PREINCR",
206 "PREDECR",
207 "UMINUS",
208 "UPLUS",
209 "PAREN",
210 "GETLINE",
211 "SPRINTF",
212 "SUBSTR",
213 "STRING",
214 "SPLIT",
215 "SNEWLINE",
216 "INDEX",
217 "NUM",
218 "STR",
219 "VAR",
220 "FLD",
221 "NEWLINE",
222 "COMMENT",
223 "COMMA",
224 "SEMICOLON",
225 "SCOMMENT",
226 "STATES",
227 "STATE",
228 "PRINT",
229 "PRINTF",
230 "BREAK",
231 "NEXT",
232 "EXIT",
233 "CONTINUE",
234 "REDIR",
235 "IF",
236 "WHILE",
237 "FOR",
238 "FORIN",
239 "VFLD",
240 "BLOCK",
241 "REGEX",
242 "LENGTH",
243 "LOG",
244 "EXP",
245 "SQRT",
246 "INT",
a687059c 247 "DO",
248 "POW",
249 "SUB",
250 "GSUB",
251 "MATCH",
252 "USERFUN",
253 "USERDEF",
254 "CLOSE",
255 "ATAN2",
256 "SIN",
257 "COS",
258 "RAND",
259 "SRAND",
260 "DELETE",
261 "SYSTEM",
262 "COND",
263 "RETURN",
264 "DEFINED",
265 "STAR",
266 "89"
8d063cd8 267};
268#else
269extern char *opname[];
270#endif
271
a687059c 272EXT int mop INIT(1);
273
d8f2e4cc 274union u_ops {
8d063cd8 275 int ival;
276 char *cval;
d8f2e4cc 277};
278#if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
279#define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
280#else
281#define OPSMAX 50000
282#endif /* 80286 hack */
a0d0e21e 283EXT union u_ops ops[OPSMAX];
8d063cd8 284
8d063cd8 285typedef struct string STR;
286typedef struct htbl HASH;
287
288#include "str.h"
289#include "hash.h"
290
9c8d0b29 291
8d063cd8 292/* A string is TRUE if not "" or "0". */
293#define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
294EXT char *Yes INIT("1");
295EXT char *No INIT("");
296
297#define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
298
299#define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
300#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
301#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
302EXT STR *Str;
303
304#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
305
9c8d0b29 306/* Prototypes for things in a2p.c */
307int aryrefarg _(( int arg ));
308int bl _(( int arg, int maybe ));
75f92628 309void dump _(( int branch ));
9c8d0b29 310int fixfargs _(( int name, int arg, int prevargs ));
311int fixrargs _(( char *name, int arg, int prevargs ));
75f92628 312void fixup _(( STR *str ));
9c8d0b29 313int numary _(( int arg ));
314int oper0 _(( int type ));
315int oper1 _(( int type, int arg1 ));
316int oper2 _(( int type, int arg1, int arg2 ));
317int oper3 _(( int type, int arg1, int arg2, int arg3 ));
318int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
319int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
75f92628 320void putlines _(( STR *str ));
321void putone _(( void ));
9c8d0b29 322int rememberargs _(( int arg ));
323char * scannum _(( char *s ));
324char * scanpat _(( char *s ));
325int string _(( char *ptr, int len ));
75f92628 326void yyerror _(( char *s ));
9c8d0b29 327int yylex _(( void ));
8d063cd8 328
329EXT int line INIT(0);
330
331EXT FILE *rsfp;
fe14fcc3 332EXT char buf[2048];
8d063cd8 333EXT char *bufptr INIT(buf);
334
335EXT STR *linestr INIT(Nullstr);
336
fe14fcc3 337EXT char tokenbuf[2048];
8d063cd8 338EXT int expectterm INIT(TRUE);
339
340#ifdef DEBUGGING
341EXT int debug INIT(0);
342EXT int dlevel INIT(0);
9bb9d9f7 343#define YYDEBUG 1
8d063cd8 344extern int yydebug;
345#endif
346
347EXT STR *freestrroot INIT(Nullstr);
348
349EXT STR str_no;
350EXT STR str_yes;
351
352EXT bool do_split INIT(FALSE);
353EXT bool split_to_array INIT(FALSE);
354EXT bool set_array_base INIT(FALSE);
355EXT bool saw_RS INIT(FALSE);
356EXT bool saw_OFS INIT(FALSE);
357EXT bool saw_ORS INIT(FALSE);
358EXT bool saw_line_op INIT(FALSE);
359EXT bool in_begin INIT(TRUE);
360EXT bool do_opens INIT(FALSE);
361EXT bool do_fancy_opens INIT(FALSE);
362EXT bool lval_field INIT(FALSE);
363EXT bool do_chop INIT(FALSE);
364EXT bool need_entire INIT(FALSE);
365EXT bool absmaxfld INIT(FALSE);
a687059c 366EXT bool saw_altinput INIT(FALSE);
8d063cd8 367
bf10efe7 368EXT bool nomemok INIT(FALSE);
369
8d063cd8 370EXT char const_FS INIT(0);
371EXT char *namelist INIT(Nullch);
372EXT char fswitch INIT(0);
373
374EXT int saw_FS INIT(0);
375EXT int maxfld INIT(0);
376EXT int arymax INIT(0);
a0d0e21e 377EXT char *nameary[100];
8d063cd8 378
379EXT STR *opens;
380
381EXT HASH *symtab;
a687059c 382EXT HASH *curarghash;
383
384#define P_MIN 0
385#define P_LISTOP 5
386#define P_COMMA 10
387#define P_ASSIGN 15
388#define P_COND 20
389#define P_DOTDOT 25
390#define P_OROR 30
391#define P_ANDAND 35
392#define P_OR 40
393#define P_AND 45
394#define P_EQ 50
395#define P_REL 55
396#define P_UNI 60
397#define P_FILETEST 65
398#define P_SHIFT 70
399#define P_ADD 75
400#define P_MUL 80
401#define P_MATCH 85
402#define P_UNARY 90
403#define P_POW 95
404#define P_AUTO 100
405#define P_MAX 999
79072805 406
407EXT int an;