This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix to installing non-xs ext's in priv lib
[perl5.git] / x2p / a2p.h
CommitLineData
8665f9e4 1/* a2p.h
a687059c 2 *
4bb101f2
JH
3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 * 2000, 2001, 2002, by Larry Wall and others
a687059c 5 *
2b317908
LW
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
8d063cd8
LW
8 */
9
be04251a 10#define VOIDUSED 1
d07c2202
GS
11
12#ifdef WIN32
13#define _INC_WIN32_PERL5 /* kludge around win32 stdio layer */
14#endif
15
774d564b 16#ifdef VMS
17# include "config.h"
cf267c36
JH
18#elif defined(NETWARE)
19# include "../NetWare/config.h"
774d564b 20#else
21# include "../config.h"
22#endif
be04251a 23
4d09c4de 24#if defined(__STDC__) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
3730b96e
GS
25# define STANDARD_C 1
26#endif
27
d07c2202
GS
28#ifdef WIN32
29#undef USE_STDIO_PTR /* XXX fast gets won't work, must investigate */
30# ifndef STANDARD_C
31# define STANDARD_C
32# endif
33# if defined(__BORLANDC__)
34# pragma warn -ccc
35# pragma warn -rch
36# pragma warn -sig
37# pragma warn -pia
38# pragma warn -par
39# pragma warn -aus
40# pragma warn -use
41# pragma warn -csu
42# pragma warn -pro
43# elif defined(_MSC_VER)
44# elif defined(__MINGW32__)
45# endif
46#endif
47
9c8d0b29
AD
48/* Use all the "standard" definitions? */
49#if defined(STANDARD_C) && defined(I_STDLIB)
50# include <stdlib.h>
51#endif /* STANDARD_C */
fed7345c 52
9c8d0b29
AD
53#include <stdio.h>
54
55#ifdef I_MATH
56#include <math.h>
57#endif
58
fed7345c
AD
59#ifdef I_SYS_TYPES
60# include <sys/types.h>
61#endif
62
dfe0b228 63#ifdef USE_NEXT_CTYPE
64
65#if NX_CURRENT_COMPILER_RELEASE >= 400
66#include <objc/NXCType.h>
67#else /* NX_CURRENT_COMPILER_RELEASE < 400 */
9c8d0b29 68#include <appkit/NXCType.h>
dfe0b228 69#endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
70
71#else /* !USE_NEXT_CTYPE */
9c8d0b29 72#include <ctype.h>
dfe0b228 73#endif /* USE_NEXT_CTYPE */
9c8d0b29
AD
74
75#define MEM_SIZE Size_t
bc82975d
AD
76#ifdef PERL_MEM_LOG
77/* Blindly copied from ../perl.h. -- AD 2/2006. */
78/* Configure gets this right but the UTS compiler gets it wrong.
79 -- Hal Morris <hom00@utsglobal.com> */
80# ifdef UTS
81# undef UVTYPE
82# define UVTYPE unsigned
83# endif
84
85 typedef IVTYPE IV;
86 typedef UVTYPE UV;
87#endif
9c8d0b29 88
c1d22f6b 89#ifndef STANDARD_C
20ce7b12
GS
90 Malloc_t malloc (MEM_SIZE nbytes);
91 Malloc_t calloc (MEM_SIZE elements, MEM_SIZE size);
92 Malloc_t realloc (Malloc_t where, MEM_SIZE nbytes);
93 Free_t free (Malloc_t where);
55497cff 94#endif
95
9c8d0b29
AD
96#if defined(I_STRING) || defined(__cplusplus)
97# include <string.h>
98#else
99# include <strings.h>
100#endif
101
102#if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
103#define strchr index
104#define strrchr rindex
105#endif
106
1aef975c
AD
107#ifdef I_TIME
108# include <time.h>
109#endif
110
111#ifdef I_SYS_TIME
112# ifdef I_SYS_TIME_KERNEL
113# define KERNEL
114# endif
115# include <sys/time.h>
116# ifdef I_SYS_TIME_KERNEL
117# undef KERNEL
118# endif
119#endif
120
121#ifndef MSDOS
122# if defined(HAS_TIMES) && defined(I_SYS_TIMES)
123# include <sys/times.h>
124# endif
125#endif
126
4633a7c4
LW
127#ifdef DOSISH
128# if defined(OS2)
23da6c43 129# define PTHX_UNUSED
4633a7c4
LW
130# include "../os2ish.h"
131# else
132# include "../dosish.h"
133# endif
134#else
135# if defined(VMS)
44a8e56a 136# define NO_PERL_TYPEDEFS
774d564b 137# include "vmsish.h"
4633a7c4
LW
138# endif
139#endif
140
1aef975c
AD
141#ifndef STANDARD_C
142/* All of these are in stdlib.h or time.h for ANSI C */
143Time_t time();
144struct tm *gmtime(), *localtime();
092bebab
JH
145#if defined(OEMVS) || defined(__OPEN_VM)
146char *(strchr)(), *(strrchr)();
147char *(strcpy)(), *(strcat)();
148#else
1aef975c
AD
149char *strchr(), *strrchr();
150char *strcpy(), *strcat();
092bebab 151#endif
1aef975c
AD
152#endif /* ! STANDARD_C */
153
159e8d64
MHM
154#ifdef __cplusplus
155# define PERL_EXPORT_C extern "C"
156#else
157# define PERL_EXPORT_C extern
158#endif
159
774d564b 160#ifdef VMS
161# include "handy.h"
162#else
163# include "../handy.h"
164#endif
55497cff 165
8d063cd8
LW
166#define Nullop 0
167
168#define OPROG 1
169#define OJUNK 2
170#define OHUNKS 3
171#define ORANGE 4
172#define OPAT 5
173#define OHUNK 6
174#define OPPAREN 7
175#define OPANDAND 8
176#define OPOROR 9
177#define OPNOT 10
178#define OCPAREN 11
179#define OCANDAND 12
180#define OCOROR 13
181#define OCNOT 14
182#define ORELOP 15
183#define ORPAREN 16
184#define OMATCHOP 17
185#define OMPAREN 18
186#define OCONCAT 19
187#define OASSIGN 20
188#define OADD 21
a687059c 189#define OSUBTRACT 22
8d063cd8
LW
190#define OMULT 23
191#define ODIV 24
192#define OMOD 25
193#define OPOSTINCR 26
194#define OPOSTDECR 27
195#define OPREINCR 28
196#define OPREDECR 29
197#define OUMINUS 30
198#define OUPLUS 31
199#define OPAREN 32
200#define OGETLINE 33
201#define OSPRINTF 34
202#define OSUBSTR 35
203#define OSTRING 36
204#define OSPLIT 37
205#define OSNEWLINE 38
206#define OINDEX 39
207#define ONUM 40
208#define OSTR 41
209#define OVAR 42
210#define OFLD 43
211#define ONEWLINE 44
212#define OCOMMENT 45
213#define OCOMMA 46
214#define OSEMICOLON 47
215#define OSCOMMENT 48
216#define OSTATES 49
217#define OSTATE 50
218#define OPRINT 51
219#define OPRINTF 52
220#define OBREAK 53
221#define ONEXT 54
222#define OEXIT 55
223#define OCONTINUE 56
224#define OREDIR 57
225#define OIF 58
226#define OWHILE 59
227#define OFOR 60
228#define OFORIN 61
229#define OVFLD 62
230#define OBLOCK 63
231#define OREGEX 64
232#define OLENGTH 65
233#define OLOG 66
234#define OEXP 67
235#define OSQRT 68
236#define OINT 69
a687059c
LW
237#define ODO 70
238#define OPOW 71
239#define OSUB 72
240#define OGSUB 73
241#define OMATCH 74
242#define OUSERFUN 75
243#define OUSERDEF 76
244#define OCLOSE 77
245#define OATAN2 78
246#define OSIN 79
247#define OCOS 80
248#define ORAND 81
249#define OSRAND 82
250#define ODELETE 83
251#define OSYSTEM 84
252#define OCOND 85
253#define ORETURN 86
254#define ODEFINED 87
255#define OSTAR 88
8d063cd8
LW
256
257#ifdef DOINIT
aab39148 258const char *opname[] = {
8d063cd8
LW
259 "0",
260 "PROG",
261 "JUNK",
262 "HUNKS",
263 "RANGE",
264 "PAT",
265 "HUNK",
266 "PPAREN",
267 "PANDAND",
268 "POROR",
269 "PNOT",
270 "CPAREN",
271 "CANDAND",
272 "COROR",
273 "CNOT",
274 "RELOP",
275 "RPAREN",
276 "MATCHOP",
277 "MPAREN",
278 "CONCAT",
279 "ASSIGN",
280 "ADD",
a687059c 281 "SUBTRACT",
8d063cd8
LW
282 "MULT",
283 "DIV",
284 "MOD",
285 "POSTINCR",
286 "POSTDECR",
287 "PREINCR",
288 "PREDECR",
289 "UMINUS",
290 "UPLUS",
291 "PAREN",
292 "GETLINE",
293 "SPRINTF",
294 "SUBSTR",
295 "STRING",
296 "SPLIT",
297 "SNEWLINE",
298 "INDEX",
299 "NUM",
300 "STR",
301 "VAR",
302 "FLD",
303 "NEWLINE",
304 "COMMENT",
305 "COMMA",
306 "SEMICOLON",
307 "SCOMMENT",
308 "STATES",
309 "STATE",
310 "PRINT",
311 "PRINTF",
312 "BREAK",
313 "NEXT",
314 "EXIT",
315 "CONTINUE",
316 "REDIR",
317 "IF",
318 "WHILE",
319 "FOR",
320 "FORIN",
321 "VFLD",
322 "BLOCK",
323 "REGEX",
324 "LENGTH",
325 "LOG",
326 "EXP",
327 "SQRT",
328 "INT",
a687059c
LW
329 "DO",
330 "POW",
331 "SUB",
332 "GSUB",
333 "MATCH",
334 "USERFUN",
335 "USERDEF",
336 "CLOSE",
337 "ATAN2",
338 "SIN",
339 "COS",
340 "RAND",
341 "SRAND",
342 "DELETE",
343 "SYSTEM",
344 "COND",
345 "RETURN",
346 "DEFINED",
347 "STAR",
348 "89"
8d063cd8
LW
349};
350#else
aab39148 351extern const char *opname[];
8d063cd8
LW
352#endif
353
a687059c
LW
354EXT int mop INIT(1);
355
d8f2e4cc 356union u_ops {
8d063cd8
LW
357 int ival;
358 char *cval;
d8f2e4cc
LW
359};
360#if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
361#define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
362#else
363#define OPSMAX 50000
364#endif /* 80286 hack */
a0d0e21e 365EXT union u_ops ops[OPSMAX];
8d063cd8 366
8d063cd8
LW
367typedef struct string STR;
368typedef struct htbl HASH;
369
370#include "str.h"
371#include "hash.h"
372
9c8d0b29 373
8d063cd8
LW
374/* A string is TRUE if not "" or "0". */
375#define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
aab39148
RB
376EXT const char *Yes INIT("1");
377EXT const char *No INIT("");
8d063cd8 378
8d063cd8 379#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
8d063cd8
LW
380EXT STR *Str;
381
382#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
383
9c8d0b29 384/* Prototypes for things in a2p.c */
20ce7b12
GS
385int aryrefarg ( int arg );
386int bl ( int arg, int maybe );
387void dump ( int branch );
388int fixfargs ( int name, int arg, int prevargs );
389int fixrargs ( char *name, int arg, int prevargs );
390void fixup ( STR *str );
391int numary ( int arg );
392int oper0 ( int type );
393int oper1 ( int type, int arg1 );
394int oper2 ( int type, int arg1, int arg2 );
395int oper3 ( int type, int arg1, int arg2, int arg3 );
396int oper4 ( int type, int arg1, int arg2, int arg3, int arg4 );
397int oper5 ( int type, int arg1, int arg2, int arg3, int arg4, int arg5 );
398void putlines ( STR *str );
399void putone ( void );
400int rememberargs ( int arg );
401char * scannum ( char *s );
402char * scanpat ( char *s );
aab39148
RB
403int string ( const char *ptr, int len );
404void yyerror ( const char *s );
20ce7b12 405int yylex ( void );
8d063cd8
LW
406
407EXT int line INIT(0);
408
409EXT FILE *rsfp;
fe14fcc3 410EXT char buf[2048];
8d063cd8
LW
411EXT char *bufptr INIT(buf);
412
d34ed59f 413EXT STR *linestr INIT(NULL);
8d063cd8 414
fe14fcc3 415EXT char tokenbuf[2048];
8d063cd8
LW
416EXT int expectterm INIT(TRUE);
417
418#ifdef DEBUGGING
419EXT int debug INIT(0);
420EXT int dlevel INIT(0);
9bb9d9f7 421#define YYDEBUG 1
8d063cd8 422extern int yydebug;
9d116dd7
JH
423#else
424# ifndef YYDEBUG
425# define YYDEBUG 0
426# endif
8d063cd8
LW
427#endif
428
d34ed59f 429EXT STR *freestrroot INIT(NULL);
8d063cd8
LW
430
431EXT STR str_no;
432EXT STR str_yes;
433
434EXT bool do_split INIT(FALSE);
435EXT bool split_to_array INIT(FALSE);
436EXT bool set_array_base INIT(FALSE);
437EXT bool saw_RS INIT(FALSE);
438EXT bool saw_OFS INIT(FALSE);
439EXT bool saw_ORS INIT(FALSE);
440EXT bool saw_line_op INIT(FALSE);
441EXT bool in_begin INIT(TRUE);
442EXT bool do_opens INIT(FALSE);
443EXT bool do_fancy_opens INIT(FALSE);
444EXT bool lval_field INIT(FALSE);
445EXT bool do_chop INIT(FALSE);
446EXT bool need_entire INIT(FALSE);
447EXT bool absmaxfld INIT(FALSE);
a687059c 448EXT bool saw_altinput INIT(FALSE);
8d063cd8 449
bf10efe7
LW
450EXT bool nomemok INIT(FALSE);
451
8d063cd8 452EXT char const_FS INIT(0);
d34ed59f 453EXT char *namelist INIT(NULL);
8d063cd8 454EXT char fswitch INIT(0);
a5571d59 455EXT bool old_awk INIT(0);
8d063cd8
LW
456
457EXT int saw_FS INIT(0);
458EXT int maxfld INIT(0);
459EXT int arymax INIT(0);
a0d0e21e 460EXT char *nameary[100];
8d063cd8
LW
461
462EXT STR *opens;
463
464EXT HASH *symtab;
a687059c
LW
465EXT HASH *curarghash;
466
467#define P_MIN 0
468#define P_LISTOP 5
469#define P_COMMA 10
470#define P_ASSIGN 15
471#define P_COND 20
472#define P_DOTDOT 25
473#define P_OROR 30
474#define P_ANDAND 35
475#define P_OR 40
476#define P_AND 45
477#define P_EQ 50
478#define P_REL 55
479#define P_UNI 60
480#define P_FILETEST 65
481#define P_SHIFT 70
482#define P_ADD 75
483#define P_MUL 80
484#define P_MATCH 85
485#define P_UNARY 90
486#define P_POW 95
487#define P_AUTO 100
488#define P_MAX 999
79072805
LW
489
490EXT int an;