|
|
1.1 root 1: /*
2: * A stream editor.
3: * Header file.
4: */
5: #define HUGE ((unsigned)65535L) /* A large integer */
6: #define NBRC 9 /* Number of \( ... \) allowed */
7: #define LHPSIZE 512 /* Size of line, hold and pat buffer */
8: #define LNMSIZE 16 /* Size of label */
9: #define FNMSIZE 16 /* Size of file name */
10:
11: /*
12: * Definition for stream directives in regular expressions.
13: * The order of these must not be changed. In particular,
14: * the `stream of' directives must immediately follow their
15: * single counterparts.
16: */
17: #define CSNUL 000 /* End of expression */
18: #define CSSOL 001 /* Match start of line */
19: #define CSEOL 002 /* End of line */
20: #define CSOPR 003 /* \( */
21: #define CSCPR 004 /* \) */
22: #define CSBRN 005 /* Match nth \( ... \) */
23: #define CSDOT 006 /* Any character */
24: #define CMDOT 007 /* Stream of any characters */
25: #define CSCHR 010 /* Match given character */
26: #define CMCHR 011 /* Match stream of given characters */
27: #define CSSCC 012 /* Char in single case */
28: #define CMSCC 013 /* Stream of chars in single case */
29: #define CSCCL 014 /* Character class */
30: #define CMCCL 015 /* Stream of character class */
31: #define CSNCL 016 /* Not character class */
32: #define CMNCL 017 /* Stream of not char class */
33:
34: /*
35: * A function for finding whether a character is a letter and a
36: * function to switch case (lower to upper and vice versa).
37: */
38: #define isallet(c) (_ctype[(c)+1]&(_L|_N))
39: #define toother(c) ((c)^040)
40:
41: /*
42: * Address.
43: */
44: typedef struct add {
45: unsigned a_lno; /* Line number */
46: char *a_pat; /* Pattern */
47: } ADD;
48:
49: /*
50: * Structure for remembering \( ... \).
51: */
52: typedef struct {
53: char *b_bp; /* Ptr to start of string matched */
54: char *b_ep; /* Ptr to end of string matched */
55: } BRC;
56:
57: /*
58: * Commands.
59: */
60: typedef struct com {
61: struct com *c_next; /* Pointer to next */
62: char c_name; /* Command name */
63: char c_nadd; /* Number of addresses */
64: char c_notf; /* Not flag */
65: char c_iran; /* In range */
66: ADD c_a[2]; /* Line addesses */
67: union {
68: struct com *p_com; /* Command */
69: struct lab *p_lab; /* Label */
70: struct sub *p_sub; /* Substitute */
71: struct fil *p_fil; /* File */
72: char *p_buf; /* Buffer */
73: } c_p; /* Parameters */
74: } COM;
75:
76: /*
77: * Argument list.
78: */
79: typedef struct ecl {
80: struct ecl *e_next; /* Pointer to next */
81: char *e_argp; /* Argument pointer */
82: } ECL;
83:
84: /*
85: * Files.
86: */
87: typedef struct fil {
88: struct fil *f_next; /* Pointer to next */
89: char f_name[FNMSIZE]; /* Pointer to file name */
90: FILE *f_filp; /* File pointer */
91: } FIL;
92:
93: /*
94: * Labels.
95: */
96: typedef struct lab {
97: struct lab *l_next; /* Pointer to next */
98: char l_name[LNMSIZE]; /* Name */
99: struct com *l_comp; /* Address */
100: int l_refc; /* Reference count */
101: } LAB;
102:
103: /*
104: * Substitute.
105: */
106: typedef struct sub {
107: char *s_pat; /* Pattern */
108: char *s_rep; /* Replacement */
109: int s_nth; /* N'th */
110: int s_cop; /* Copy flag */
111: struct fil *s_fil; /* File to write to */
112: } SUB;
113:
114: /*
115: * Queue.
116: */
117: typedef struct qcl {
118: struct que *q_next; /* Pointer to next */
119: struct com *q_comp; /* Pointer to command */
120: } QCL;
121:
122: /*
123: * Global variables.
124: */
125: extern FILE *ifp; /* Input file pointer */
126: extern BRC brcl[1+NBRC]; /* For remembering \( \) */
127: extern COM *comp; /* Pointer to command list */
128: extern COM **compp; /* Ptr to add next element */
129: extern ECL *eclp; /* Argument list pointer */
130: extern FIL *filp; /* Pointer to file list */
131: extern LAB *labp; /* Label list */
132: extern QCL *qcbp; /* For stacking braces */
133: extern int pattlen; /* Length of pattern */
134: extern int holdlen; /* Length of hold buffer */
135: extern int dolflag; /* Last line in file */
136: extern int addnone; /* Number was not found */
137: extern int nflag; /* Don't copy to output */
138: extern int sflag; /* Case insensitive */
139: extern int nerr; /* Number of errors */
140: extern int lno; /* Current line number */
141: extern char linebuf[LHPSIZE]; /* Line buffer */
142: extern char holdbuf[LHPSIZE]; /* Hold buffer */
143: extern char pattbuf[LHPSIZE]; /* Pattern buffer */
144: extern char *ncp; /* Pointer in input */
145:
146: extern char *salloc(); /* Memory allocation function */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.