2 * Plan9 is defined for plan 9
3 * V9 is defined for 9th edition
4 * Sun is defined for sun-os
5 * Please don't litter the code with ifdefs. The three below (and one in
6 * getflags) should be enough.
26 #define YYMAXDEPTH 500
33 #undef pipe /* so that /dev/fd works */
34 #define searchpath rcsearchpath /* avoid new libc function */
36 typedef struct tree tree;
37 typedef struct word word;
39 typedef union code code;
40 typedef struct var var;
41 typedef struct list list;
42 typedef struct redir redir;
43 typedef struct thread thread;
44 typedef struct builtin builtin;
48 int rtype, fd0, fd1; /* details of REDIR PIPE DUP tokens */
56 tree *token(char*, int), *klook(char*), *tree1(int, tree*);
57 tree *tree2(int, tree*, tree*), *tree3(int, tree*, tree*, tree*);
58 tree *mung1(tree*, tree*), *mung2(tree*, tree*, tree*);
59 tree *mung3(tree*, tree*, tree*, tree*), *epimung(tree*, tree*);
60 tree *simplemung(tree*), *heredoc(tree*);
64 * The first word of any code vector is a reference count.
65 * Always create a new reference to a code vector by calling codecopy(.).
66 * Always call codefree(.) when deleting a reference.
84 char *name; /* ascii name */
85 word *val; /* value */
87 code *fn; /* pointer to function's code vector */
89 int pc; /* pc of start of function */
90 var *next; /* next on hash or local list */
91 void (*changefn)(var*);
93 var *vlook(char*), *gvlook(char*), *newvar(char*, var*);
95 var *gvar[NVAR]; /* hash for globals */
96 #define new(type) ((type *)emalloc(sizeof(type)))
100 #define NOFILE 128 /* should come from <param.h> */
108 * Glob character escape in strings:
109 * In a string, GLOB must be followed by *?[ or GLOB.
110 * GLOB* matches any string
111 * GLOB? matches any single character
112 * GLOB[...] matches anything in the brackets
113 * GLOBGLOB matches GLOB
115 #define GLOB ((char)0x01)
117 * onebyte(c), twobyte(c), threebyte(c)
118 * Is c the first character of a one- two- or three-byte utf sequence?
120 #define onebyte(c) ((c&0x80)==0x00)
121 #define twobyte(c) ((c&0xe0)==0xc0)
122 #define threebyte(c) ((c&0xf0)==0xe0)
125 int nerror; /* number of errors encountered during compilation */
126 int doprompt; /* is it time for a prompt? */
128 * Which fds are the reading/writing end of a pipe?
129 * Unfortunately, this can vary from system to system.
130 * 9th edition Unix doesn't care, the following defines
135 extern char *Rcmain(), Fdprefix[];
138 * How many dot commands have we executed?
139 * Used to ensure that -v flag doesn't print rcmain.
142 char *getstatus(void);