1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
CPPAWK-FIELD(1) Field Utilities CPPAWK-FIELD(1)
NAME
field - utilities for working with positional parameters ("fields")
SYNOPSIS
#include <field.h>
delf(i[, n]) // delete n fields starting with i.
insf(i, ...) // insert one or more fields at position i.
DESCRIPTION
The <field.h> header provides utilities for performing bulk operations on Awk positional
parameters, also referred to as fields.
Function delf
Syntax:
delf(i[ ,n])
Description:
The delf function deletes n fields starting at field i.
If i exceeds NF or is less than 1, or if n is less than 1, the function has no effect.
If n is omitted, it defaults to 1: one field is deleted.
If there are fields after the deleted fields, they are relocated so that they start at po-
sition i and NF is adjusted accordingly.
If there are are only n or fewer fields starting at position i, then no fields have to be
moved. In this case, NF is simply adjusted to the value of i - 1 to trim the fields away.
In all cases when NF is adjusted or fields are moved, the record $0 is re-calculated in
accordance with the Awk semantics for field manipulation.
Macro insf
Syntax:
insf(i, ...)
Description:
The insf macro expands to a statement which inserts one or more fields at position i. The
number of fields inserted is determined by the number of variable arguments after i, of
which there must be between 1 and 32. These are the field arguments.
If i is less than 1, there is no effect. In that case, the argument expressions which give
the inserted field values are also not evaluated.
Let n be the number of field arguments being inserted.
The i argument may be greater than NF, in which case the specified fields are created, and
NF is adjusted to include all of them in the position parameter array; NF will take on the
value i + n.
If i is between 1 and NF, then the existing fields from i to NF move to higher positions
to create a space for the inserted fields. Field $i moves to $(i + n) and so forth. Then
the n field parameters are assigned into the positions $i, $(i + 1), ..., $(i + n - 1).
In all cases when NF is adjusted and fields are assigned or moved, the record $0 is re-
calculated in accordance with the Awk semantics for field manipulation.
SEE ALSO
cppawk(1), cppawk-cons(1)
BUGS
The insf function is limited to 32 variadic arguments.
AUTHOR
Kaz Kylheku <kaz@kylheku.com>
COPYRIGHT
Copyright 2022, BSD2 License.
cppawk Libraries 19 April 2022 CPPAWK-FIELD(1)
|