| 1 |
@load "filefuncs" # get file functions |
| 2 |
|
| 3 |
# comments/for.awk |
| 4 |
|
| 5 |
BEGIN { |
| 6 |
for (i = 1; i <= 10; i++) { |
| 7 |
print i |
| 8 |
} |
| 9 |
for (i = 1; i <= 10; i++) { # comment 0 |
| 10 |
print i |
| 11 |
} |
| 12 |
for (i = 1; # comment 1a |
| 13 |
i <= 10; i++) { |
| 14 |
print i |
| 15 |
} |
| 16 |
for (i = 1; i <= 10; # comment 2a |
| 17 |
i++) { |
| 18 |
print i |
| 19 |
} |
| 20 |
for (i = 1; # comment 1b |
| 21 |
i <= 10; # comment 2b |
| 22 |
i++) { |
| 23 |
print i |
| 24 |
} |
| 25 |
for (i = 1; # comment 1c |
| 26 |
i <= 10; # comment 2c |
| 27 |
i++) { # comment 3c |
| 28 |
print i |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
# comments/for0.awk |
| 33 |
|
| 34 |
BEGIN { |
| 35 |
for (iggy in foo) { |
| 36 |
# comment 5 |
| 37 |
|
| 38 |
# comment 6 |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
# comments/for1.awk |
| 43 |
|
| 44 |
BEGIN { |
| 45 |
for (iggy in foo) { |
| 46 |
# comment 1 |
| 47 |
|
| 48 |
# comment 2 |
| 49 |
print iggy |
| 50 |
} |
| 51 |
for (iggy in foo) { |
| 52 |
# comment 3 |
| 53 |
|
| 54 |
# comment 4 |
| 55 |
print iggy |
| 56 |
} |
| 57 |
for (iggy in foo) { |
| 58 |
# comment 5 |
| 59 |
|
| 60 |
# comment 6 |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
# comments/for2.awk |
| 65 |
|
| 66 |
BEGIN { |
| 67 |
for (;;) { |
| 68 |
print i |
| 69 |
} |
| 70 |
for (;;) { # comment 0 |
| 71 |
print i |
| 72 |
} |
| 73 |
for (; # comment 1a |
| 74 |
; ) { |
| 75 |
print i |
| 76 |
} |
| 77 |
for (; ; # comment 2a |
| 78 |
) { |
| 79 |
print i |
| 80 |
} |
| 81 |
for (; # comment 1b |
| 82 |
; # comment 2b |
| 83 |
) { |
| 84 |
print i |
| 85 |
} |
| 86 |
for (; # comment 1c |
| 87 |
; # comment 2c |
| 88 |
) { # comment 3c |
| 89 |
print i |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
# comments/for_del.awk |
| 94 |
|
| 95 |
BEGIN { |
| 96 |
for (iggy in foo) { |
| 97 |
delete foo[iggy] |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
# comments/do.awk |
| 102 |
|
| 103 |
BEGIN { |
| 104 |
do { # DO comment |
| 105 |
# LBRACE comment |
| 106 |
# block comment |
| 107 |
print 42 |
| 108 |
} while (0) # WHILE comment |
| 109 |
# rbrace comment |
| 110 |
} |
| 111 |
|
| 112 |
# comments/do2.awk |
| 113 |
|
| 114 |
BEGIN { |
| 115 |
do { # DO comment |
| 116 |
# LBRACE comment |
| 117 |
# block comment |
| 118 |
print 42 |
| 119 |
} while (0) # rbrace comment |
| 120 |
} |
| 121 |
|
| 122 |
# comments2/do.awk |
| 123 |
|
| 124 |
BEGIN { |
| 125 |
do { # do comment |
| 126 |
# lbrace comment |
| 127 |
# block comment |
| 128 |
print 42 |
| 129 |
} while (1) # while comment |
| 130 |
# rbace EOL comment |
| 131 |
# rbrace block comment |
| 132 |
} |
| 133 |
|
| 134 |
# comments2/if.awk |
| 135 |
|
| 136 |
BEGIN { |
| 137 |
if (a) { |
| 138 |
# IF comment |
| 139 |
print "foo" # print comment |
| 140 |
} |
| 141 |
if (a) { # lbrace comment |
| 142 |
# IF comment 2 |
| 143 |
print "bar" |
| 144 |
} else { |
| 145 |
# ELSE comment |
| 146 |
print "baz" |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
# comments/if0.awk |
| 151 |
|
| 152 |
BEGIN { |
| 153 |
if (a) { |
| 154 |
# nothing |
| 155 |
} else { |
| 156 |
print "b" |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
# comments/switch.awk |
| 161 |
|
| 162 |
BEGIN { |
| 163 |
a = 5 |
| 164 |
switch (a) { # switch EOL comment |
| 165 |
|
| 166 |
# switch block comment |
| 167 |
# lbrace EOL comment |
| 168 |
|
| 169 |
# lbrace block comment |
| 170 |
case 5: # comment after case |
| 171 |
print "five!" |
| 172 |
break |
| 173 |
# block comment after case |
| 174 |
default: # comment after default |
| 175 |
print "default" # print comment |
| 176 |
break |
| 177 |
} |
| 178 |
# rbrace EOL comment |
| 179 |
# rbrace block comment |
| 180 |
} |
| 181 |
|
| 182 |
# comments2/switch.awk |
| 183 |
|
| 184 |
BEGIN { |
| 185 |
a = 5 |
| 186 |
switch (a) { # switch EOL comment |
| 187 |
|
| 188 |
# switch block comment |
| 189 |
# lbrace EOL comment |
| 190 |
|
| 191 |
# lbrace block comment |
| 192 |
case 5: |
| 193 |
print "five!" |
| 194 |
break |
| 195 |
# block comment after case |
| 196 |
} |
| 197 |
# rbrace EOL comment |
| 198 |
# rbrace block comment |
| 199 |
} |
| 200 |
|
| 201 |
# comments2/switch0.awk |
| 202 |
|
| 203 |
BEGIN { |
| 204 |
a = 5 |
| 205 |
switch (a) { |
| 206 |
case 5: # case comment |
| 207 |
print "five!" |
| 208 |
break |
| 209 |
default: # default comment |
| 210 |
print "default" |
| 211 |
break |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
# comments2/switch1.awk |
| 216 |
|
| 217 |
BEGIN { |
| 218 |
a = 5 |
| 219 |
switch (a) { |
| 220 |
case 5: |
| 221 |
# case comment |
| 222 |
print "five!" |
| 223 |
break |
| 224 |
default: # default comment |
| 225 |
print "default" |
| 226 |
break |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
# comments2/while.awk |
| 231 |
|
| 232 |
BEGIN { |
| 233 |
while (1) { |
| 234 |
# while comment |
| 235 |
# lbrace comment |
| 236 |
# block comment |
| 237 |
print 42 |
| 238 |
} |
| 239 |
} |
| 240 |
|
| 241 |
# comments2/while2.awk |
| 242 |
|
| 243 |
BEGIN { |
| 244 |
while (1) { |
| 245 |
# while comment |
| 246 |
# lbrace comment |
| 247 |
# block comment |
| 248 |
} |
| 249 |
} |
| 250 |
|
| 251 |
BEGIN { |
| 252 |
callme(1, # 1 comment |
| 253 |
2, # 2 comment |
| 254 |
3) |
| 255 |
} |
| 256 |
|
| 257 |
# comments/load.awk |
| 258 |
|
| 259 |
BEGIN { |
| 260 |
stat("/etc/passwd", data) |
| 261 |
for (i in data) { |
| 262 |
print i, data[i] |
| 263 |
} |
| 264 |
} |
| 265 |
|
| 266 |
# comments/andor.awk |
| 267 |
|
| 268 |
BEGIN { |
| 269 |
if (a && # and comment |
| 270 |
b || # or comment |
| 271 |
c) { |
| 272 |
print "foo" |
| 273 |
} |
| 274 |
} |
| 275 |
|
| 276 |
# comments/qmcol-qm.awk |
| 277 |
|
| 278 |
BEGIN { |
| 279 |
a = 1 ? # qm comment |
| 280 |
2 : 3 |
| 281 |
print a |
| 282 |
} |
| 283 |
|
| 284 |
# comments/qmcol-colon.awk |
| 285 |
|
| 286 |
BEGIN { |
| 287 |
a = 1 ? 2 : # colon comment |
| 288 |
3 |
| 289 |
print a |
| 290 |
} |
| 291 |
|
| 292 |
# comments/qmcolboth.awk |
| 293 |
|
| 294 |
BEGIN { |
| 295 |
a = 1 ? # qm comment |
| 296 |
2 : # colon comment |
| 297 |
3 |
| 298 |
print a |
| 299 |
} |
| 300 |
|
| 301 |
# test beginning of line block comments (com2.awk) |
| 302 |
|
| 303 |
BEGIN { |
| 304 |
print "hi" # comment 1 |
| 305 |
# comment 2 |
| 306 |
print "there" |
| 307 |
if (foo) { |
| 308 |
print "hello" # comment 3 |
| 309 |
# comment 4 |
| 310 |
print "world" |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
# comments/exp.awk |
| 316 |
# range comment |
| 317 |
|
| 318 |
# range comment 2 |
| 319 |
|
| 320 |
# range comment b |
| 321 |
|
| 322 |
# range comment c |
| 323 |
/foo/, /bar/ { |
| 324 |
print |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
# comments2/f.awk |
| 329 |
function bar(p1, p2) |
| 330 |
{ |
| 331 |
print "foo" |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
# rbrace eol bar |
| 336 |
|
| 337 |
# rbrace block bar |
| 338 |
|
| 339 |
# comments2/function.awk |
| 340 |
# comment |
| 341 |
# comment before braces |
| 342 |
function baz(p1, p2) |
| 343 |
{ |
| 344 |
# lbrace eol |
| 345 |
# lbrace block |
| 346 |
print "foo" |
| 347 |
} |
| 348 |
|
| 349 |
|
| 350 |
# rbrace EOL comment funnyhaha |
| 351 |
|
| 352 |
# rbrace block comment funnyhaha |
| 353 |
|
| 354 |
# comments/callcoma.awk |
| 355 |
function callme(a, b, c) |
| 356 |
{ |
| 357 |
printf "a = %s, b = %s, c = %s\n", # format comment |
| 358 |
a, # a2 comment |
| 359 |
b, # b2 comment |
| 360 |
c |
| 361 |
} |
| 362 |
|
| 363 |
|
| 364 |
# rbrace eol baz |
| 365 |
|
| 366 |
# rbrace block baz |
| 367 |
|
| 368 |
# comments/function.awk |
| 369 |
# param comment 1 |
| 370 |
# param comment 2 |
| 371 |
# Comment between header and body |
| 372 |
function funny(param1, param2, param3, param4) |
| 373 |
{ |
| 374 |
# lbrace EOL comment |
| 375 |
# lbrace block comment |
| 376 |
print "funny" |
| 377 |
} |
| 378 |
|
| 379 |
|
| 380 |
# rbrace EOL comment funny |
| 381 |
|
| 382 |
# rbrace block comment funny |
| 383 |
|
| 384 |
# comments/function2.awk |
| 385 |
function funnyhaha(param1, param2, param3, param4) |
| 386 |
{ |
| 387 |
# lbrace EOL comment |
| 388 |
# lbrace block comment |
| 389 |
print "funny" |
| 390 |
} |