Git init
[external/mawk.git] / field.h
1
2 /********************************************
3 field.h
4 copyright 1991, Michael D. Brennan
5
6 This is a source file for mawk, an implementation of
7 the AWK programming language.
8
9 Mawk is distributed without warranty under the terms of
10 the GNU General Public License, version 2, 1991.
11 ********************************************/
12
13 /* $Log: field.h,v $
14  * Revision 1.2  1995/06/18  19:42:16  mike
15  * Remove some redundant declarations and add some prototypes
16  *
17  * Revision 1.1.1.1  1993/07/03  18:58:12  mike
18  * move source to cvs
19  *
20  * Revision 5.2  1992/01/06  08:10:24  brennan
21  * set_binmode() proto for MSDOS
22  *
23  * Revision 5.1  91/12/05  07:59:16  brennan
24  * 1.1 pre-release
25  * 
26 */
27
28 /* field.h */
29
30
31 #ifndef  FIELD_H
32 #define  FIELD_H   1
33
34 void  PROTO( set_field0, (char *, unsigned) ) ;
35 void  PROTO( split_field0, (void) ) ;
36 int   PROTO( space_split, (char *, unsigned) ) ;
37 int   PROTO( re_split, (char *, PTR) ) ;
38 int   PROTO( null_split, (char *)) ;
39 void  PROTO( field_assign, (CELL*, CELL *) ) ;
40 char *PROTO( is_string_split, (PTR , unsigned *) ) ;
41 void  PROTO( slow_cell_assign, (CELL*, CELL*)) ;
42 CELL *PROTO( slow_field_ptr, (int)) ;
43 int   PROTO( field_addr_to_index, (CELL*)) ;
44 void  PROTO( set_binmode, (int)) ;
45
46
47 #define  NUM_PFIELDS            5
48 extern  CELL  field[FBANK_SZ+NUM_PFIELDS] ;
49         /* $0, $1 ... $(MAX_SPLIT), NF, RS, RS, CONVFMT, OFMT */
50
51 /* more fields if needed go here */
52 extern CELL *fbank[NUM_FBANK] ; /* fbank[0] == field */
53
54 /* index to CELL *  for a field */
55 #define field_ptr(i) ((i)<=MAX_SPLIT?field+(i):slow_field_ptr(i))
56
57 /* the pseudo fields, assignment has side effects */
58 #define  NF     (field+MAX_SPLIT+1)   /* must be first */
59 #define  RS     (field+MAX_SPLIT+2)
60 #define  FS     (field+MAX_SPLIT+3)
61 #define  CONVFMT  (field+MAX_SPLIT+4)
62 #define  OFMT   (field+MAX_SPLIT+5)   /* must be last */
63
64 #define  LAST_PFIELD    OFMT
65
66 /* some compilers choke on (NF-field) in a case statement
67    even though it's constant so ...
68 */
69 #define  NF_field    (MAX_SPLIT+1)
70 #define  RS_field    (MAX_SPLIT+2) 
71 #define  FS_field    (MAX_SPLIT+3) 
72 #define  CONVFMT_field (MAX_SPLIT+4)
73 #define  OFMT_field  (MAX_SPLIT+5) 
74
75
76 extern  int  nf ; /* shadows NF */
77
78 /* a shadow type for RS and FS */
79 #define  SEP_SPACE      0
80 #define  SEP_CHAR       1
81 #define  SEP_STR        2
82 #define  SEP_RE         3
83 #define  SEP_MLR        4
84
85 typedef  struct {
86 char  type ;
87 char  c ;
88 PTR ptr ; /* STRING* or RE machine* */
89 } SEPARATOR ;
90
91 extern   SEPARATOR  rs_shadow  ;
92 extern   CELL  fs_shadow ;
93
94
95 /*  types for splitting overflow */
96
97 typedef  struct spov {
98 struct spov  *link ;
99 STRING  *sval ;
100 } SPLIT_OV ;
101
102 extern  SPLIT_OV  *split_ov_list ;
103
104
105 #endif   /* FIELD_H  */