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