-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathawk.vim
More file actions
614 lines (554 loc) · 17.7 KB
/
awk.vim
File metadata and controls
614 lines (554 loc) · 17.7 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
" Vim indent file
" Language: AWK Script
" Maintainer: Clavelito <maromomo@hotmail.com>
" Id: $Date: 2016-11-21 20:22:55+09 $
" $Revision: 1.72 $
"
" Description:
" let g:awk_indent_switch_labels = 0
" switch (label) {
" case /A/:
"
" let g:awk_indent_switch_labels = 1
" switch (label) {
" case /A/:
" (default: 1, disable: -1)
"
" let g:awk_indent_curly_braces = 0
" if (brace)
" {
"
" let g:awk_indent_curly_braces = 1
" if (brace)
" {
" (default: 0)
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal indentexpr=GetAwkIndent()
setlocal indentkeys=0{,0},:,!^F,o,O,e
if exists("*GetAwkIndent")
finish
endif
let s:cpo_save = &cpo
set cpo&vim
if !exists("g:awk_indent_switch_labels")
let g:awk_indent_switch_labels = 1
endif
if !exists("g:awk_indent_curly_braces")
let g:awk_indent_curly_braces = 0
endif
function GetAwkIndent()
let lnum = prevnonblank(v:lnum - 1)
if lnum == 0
return 0
endif
let cline = getline(v:lnum)
if cline =~# '^#'
return 0
endif
let line = getline(lnum)
let [line, lnum, ind] = s:ContinueLineIndent(line, lnum, cline)
if line =~# '\\$\|\%(&&\|||\|,\)\s*$'
unlet! s:prev_lnum s:ncp_cnum
return ind
endif
let nnum = lnum
let [line, lnum] = s:JoinContinueLine(line, lnum, 0)
let [pline, pnum] = s:JoinContinueLine(line, lnum, 1)
if cline =~# '^\s*else\>'
let ind = s:CurrentElseIndent(line, lnum, pline, pnum)
unlet! s:prev_lnum s:next_lnum s:ncp_cnum
return ind
endif
let ind = s:MorePrevLineIndent(pline, pnum, line, lnum)
let ind = s:PrevLineIndent(line, lnum, nnum, ind)
let ind = s:CurrentLineIndent(cline, line, lnum, pline, ind)
unlet! s:prev_lnum s:next_lnum s:ncp_cnum
return ind
endfunction
function s:ContinueLineIndent(line, lnum, cline)
let [pline, line, lnum, ind] = s:PreContinueLine(a:line, a:lnum)
if line =~# '^\s*\%(if\|}\=\s*else\s\+if\|for\|}\=\s*while\)\>'
\ && line =~# '\\$\|\%(&&\|||\)\s*$'
let ind = ind + &sw * 2
elseif line =~# '^\s*printf\=\>\s*\%([^,[:blank:]][^,]\{-},\s*\)\+$'
\ || line =~# '^\s*printf\=\>\%(\s*(\)\@!' && line =~# '\\$'
let ind = s:GetMatchWidth(line, lnum, '\C\%(\s*printf\=\>\)\@<=.')
elseif line =~# '(\s*\%([^,[:blank:]][^,]\{-},\s*\)\+$'
\ && pline !~# '\\$\|\%(&&\|||\|,\)\s*$'
\ && s:NoClosedPair(lnum, '(', ')', lnum)
let ind = s:GetMatchWidth(line, lnum, s:ncp_cnum)
elseif line =~# '\[\s*\%([^,[:blank:]][^,]\{-},\s*\)\+$'
\ && pline !~# '\\$\|\%(&&\|||\|,\)\s*$'
\ && s:NoClosedPair(lnum, '\M[', '\M]', lnum)
let ind = s:GetMatchWidth(line, lnum, s:ncp_cnum)
elseif line =~# '\<\%(function\|func\)\s\+\h\w*\s*(\s\{2,}\\$'
\ && s:NoClosedPair(lnum, '(', ')', lnum)
let ind = &sw * 2 > s:ncp_cnum ? s:ncp_cnum : &sw * 2
elseif line =~# '\<\h\w*\s*(.*\\$'
\ && pline !~# '\\$\|\%(&&\|||\|,\)\s*$'
\ && s:NoClosedPair(lnum, '(', ')', lnum)
let ind = s:GetMatchWidth(line, lnum, s:ncp_cnum)
elseif line =~# '[^<>=!]==\@!'
\ && line =~# '\\$\|\%(&&\|||\)\s*$'
\ && pline !~# '\\$\|\%(&&\|||\)\s*$'
let ind = s:GetMatchWidth(line, lnum, '\%([^<>=!]=\)\@<=.')
elseif line =~# '\\$' && a:cline =~# '^\s*{'
let ind = indent(get(s:JoinContinueLine(line, lnum, 0), 1))
elseif ind && line =~# '\\$' && pline !~# '\\$\|\%(&&\|||\|,\)\s*$'
let ind = ind + &sw
elseif !ind && line =~# '\\$\|\%(&&\|||\)\s*$'
\ && pline !~# '\\$\|\%(&&\|||\)\s*$'
let ind = ind + &sw * 2
endif
return [line, lnum, ind]
endfunction
function s:MorePrevLineIndent(pline, pnum, line, lnum)
let [pline, pnum, ind] = s:PreMorePrevLine(a:pline, a:pnum, a:line, a:lnum)
while pnum
\ &&
\ (pline =~# '^\s*\%(if\|}\=\s*else\s\+if\|for\|while\)\s*(.*)\s*$'
\ && s:AfterParenPairNoStr(pnum, 0)
\ || pline =~# '^\s*}\=\s*else\s*$'
\ || pline =~# '^\s*do\s*$')
let ind = indent(pnum)
if pline =~# '^\s*do\s*$'
\ && s:NoClosedPair(pnum, '\C\<do\>', '\C\<while\>', a:lnum)
break
elseif pline =~# '^\s*}\=\s*else\>'
let [pline, pnum] = s:GetIfLine(pline, pnum, 1)
elseif pline =~# '^\s*while\>'
let [pline, pnum] = s:GetDoLine(pline, pnum)
endif
let [pline, pnum] = s:JoinContinueLine(pline, pnum, 1)
endwhile
return ind
endfunction
function s:PrevLineIndent(line, lnum, nnum, ind)
let ind = a:ind
if a:line =~# '^\s*\%(else\|do\)\s*{\=\s*$'
\ || a:line =~# '^\s*}\s*else\s*{\=\s*$'
\ || a:line =~# '^\s*{\s*$'
let ind = indent(a:lnum) + &sw
elseif a:line =~# '^\s*do\>\s*\S'
\ && s:GetHideStringLine(a:line) !~# '\%(;\|}\)\s*while\>\s*(.*)'
let ind = indent(a:lnum)
elseif (a:line =~# '^\s*\%(if\|else\s\+if\|for\)\s*(.*)\s*{\=\s*$'
\ || a:line =~# '^\s*}\s*else\s\+if\s*(.*)\s*{\=\s*$'
\ || a:line =~# '^\s*while\s*(.*)\s*{\s*$'
\ || a:line =~# '^\s*while\s*(.*)\s*$'
\ && get(s:GetDoLine(a:line, a:lnum), 1) == a:lnum)
\ && s:AfterParenPairNoStr(a:lnum, 1)
let ind = indent(a:lnum) + &sw
elseif a:line =~# '{' && s:NoClosedPair(a:lnum, '{', '}', a:nnum)
let ind = indent(a:lnum) + &sw
elseif a:line =~# '^\s*\%(case\|default\)\>'
\ && g:awk_indent_switch_labels > -1
let ind = ind + &sw
endif
return ind
endfunction
function s:CurrentLineIndent(cline, line, lnum, pline, ind)
let ind = a:ind
if a:cline =~# '^\s*}'
let ind = s:CloseBraceIndent(a:cline, ind)
elseif a:cline =~# '^\s*{\s*\%(#.*\)\=$' && !g:awk_indent_curly_braces
\ &&
\ (a:line =~# '^\s*\%(if\|else\s\+if\|while\|for\)\s*(.*)'
\ && s:AfterParenPairNoStr(a:lnum, 0)
\ || a:line =~# '^\s*\%(else\|do\)\s*$')
let ind = ind - &sw
elseif a:cline =~# '^\s*\%(case\|default\)\>'
\ && g:awk_indent_switch_labels > -1
\ &&
\ !(a:line =~# '^\s*switch\>' && g:awk_indent_switch_labels
\ || a:line =~# '^\s*{\s*$' && a:pline =~# '^\s*switch\>'
\ || (a:line =~# '^\s*}\%(\s*;\)\=\s*$'
\ || a:line =~# '}\%(\s*;\)\=\s*$' && a:line !~# '^\s*case\>')
\ && get(s:GetStartBraceLine(a:line, a:lnum), 0) =~# '^\s*case\>')
let ind = ind - &sw
endif
return ind
endfunction
function s:PreContinueLine(line, lnum)
let [line, lnum] = s:SkipCommentLine(a:line, a:lnum)
let pnum = prevnonblank(lnum - 1)
let pline = getline(pnum)
let [pline, pnum] = s:SkipCommentLine(pline, pnum)
let ind = indent(lnum)
if line =~# '\\$\|\%(&&\|||\|,\)\s*\%(#.*\)\=$'
let pline = s:GetHideStringLine(pline)
let line = s:GetHideStringLine(line)
endif
return [pline, line, lnum, ind]
endfunction
function s:JoinContinueLine(line, lnum, prev)
if a:prev && s:GetPrevNonBlank(a:lnum)
let lnum = s:prev_lnum
let line = getline(lnum)
elseif a:prev
let lnum = 0
let line = ""
else
let line = a:line
let lnum = a:lnum
endif
let [line, lnum] = s:SkipCommentLine(line, lnum)
if line =~# '#'
let line = s:GetHideStringLine(line)
endif
let pnum = lnum
while pnum && s:GetPrevNonBlank(pnum)
let pline = getline(s:prev_lnum)
if pline =~# '^\s*#'
let pnum = s:prev_lnum
continue
elseif pline =~# '#'
let pline = s:GetHideStringLine(pline)
endif
if pline !~# '\\$\|\%(&&\|||\|,\)\s*$'
break
endif
let pnum = s:prev_lnum
let lnum = s:prev_lnum
let line = pline. line
endwhile
return [line, lnum]
endfunction
function s:SkipCommentLine(line, lnum)
let line = a:line
let lnum = a:lnum
while lnum && line =~# '^\s*#' && s:GetPrevNonBlank(lnum)
let lnum = s:prev_lnum
let line = getline(lnum)
endwhile
return [line, lnum]
endfunction
function s:JoinNextContinueLine(line, lnum)
let line = a:line
let lnum = a:lnum
if line =~# '#'
let line = s:GetHideStringLine(line)
endif
let nnum = lnum
while nnum && line =~# '\\$\|\%(&&\|||\|,\)\s*$' && s:GetNextNonBlank(nnum)
let nnum = s:next_lnum
let nline = getline(nnum)
if nline =~# '^\s*#'
continue
elseif nline =~# '#'
let nline = s:GetHideStringLine(nline)
endif
let line = line. nline
endwhile
return [line, lnum]
endfunction
function s:GetPrevNonBlank(lnum)
let s:prev_lnum = prevnonblank(a:lnum - 1)
return s:prev_lnum
endfunction
function s:GetNextNonBlank(lnum)
let s:next_lnum = nextnonblank(a:lnum + 1)
return s:next_lnum
endfunction
function s:PreMorePrevLine(pline, pnum, line, lnum)
let pline = a:pline
let pnum = a:pnum
let line = a:line
let lnum = a:lnum
if a:line =~# '^\s*}\%(\s*else\>\)\@!' || a:line =~# '}\%(\s*;\)\=\s*$'
let [line, lnum] = s:GetStartBraceLine(line, lnum)
elseif a:line =~# '^\s*}\=\s*else\>'
let [line, lnum] = s:GetIfLine(line, lnum, 1)
elseif a:line =~# '^\s*while\>'
let [line, lnum] = s:GetDoLine(line, lnum)
endif
if lnum != a:lnum
let [pline, pnum] = s:JoinContinueLine(line, lnum, 1)
endif
let ind = indent(lnum)
return [pline, pnum, ind]
endfunction
function s:GetStartBraceLine(line, lnum)
let line = a:line
let lnum = a:lnum
let [line, lnum] = s:GetStartPairLine(line, '}', '{', lnum)
if line =~# '^\s*}\=\s*else\>'
let [line, lnum] = s:GetIfLine(line, lnum, 1)
endif
return [line, lnum]
endfunction
function s:GetStartPairLine(line, item1, item2, lnum)
let save_cursor = getpos(".")
call cursor(a:lnum, strlen(getline(a:lnum)))
let lnum = search(a:item1, 'cbW', a:lnum)
while lnum && s:InsideAwkItemOrCommentStr()
let lnum = search(a:item1, 'bW', a:lnum)
endwhile
if lnum
let lnum = searchpair(
\ a:item2, '', a:item1, 'bW', 's:InsideAwkItemOrCommentStr()')
endif
if lnum > 0
let line = getline(lnum)
let [line, lnum] = s:JoinContinueLine(line, lnum, 0)
else
let line = a:line
let lnum = a:lnum
endif
call setpos(".", save_cursor)
return [line, lnum]
endfunction
function s:GetIfLine(line, lnum, into)
let save_cursor = getpos(".")
if a:into
call cursor(a:lnum, 1)
else
call cursor(v:lnum, 1)
endif
let lnum = searchpair('\C^\s*if\>', '', '\C\<else\>\%(\s\+if\)\@!', 'bW',
\ 'indent(".") > indent(a:lnum) || s:InsideAwkItemOrCommentStr()')
call setpos(".", save_cursor)
if lnum > 0
let line = getline(lnum)
let [line, lnum] = s:JoinNextContinueLine(line, lnum)
else
let line = a:line
let lnum = a:lnum
endif
return [line, lnum]
endfunction
function s:GetDoLine(line, lnum)
let save_cursor = getpos(".")
call cursor(a:lnum, 1)
let lnum = s:SearchDoLoop(a:lnum)
call setpos(".", save_cursor)
if lnum
let line = getline(lnum)
else
let line = a:line
let lnum = a:lnum
endif
return [line, lnum]
endfunction
function s:SearchDoLoop(snum)
let lnum = 0
let onum = 0
while search('\C^\s*do\>', 'ebW')
let save_cursor = getpos(".")
let lnum = searchpair('\C\<do\>', '', '\C\<while\>', 'W',
\ 'indent(".") > indent(get(save_cursor, 1))'
\. '|| s:InsideAwkItemOrCommentStr()', a:snum)
if lnum < onum || lnum < 1
let lnum = 0
break
elseif lnum == a:snum
let lnum = get(save_cursor, 1)
break
else
let onum = lnum
let lnum = 0
endif
call setpos(".", save_cursor)
endwhile
return lnum
endfunction
function s:NoClosedPair(lnum, item1, item2, nnum)
let snum = 0
let enum = 0
let s:ncp_cnum = 0
let save_cursor = getpos(".")
call cursor(a:nnum, strlen(getline(a:nnum)))
let snum = search(a:item1, 'cbW', a:lnum)
while snum
if s:InsideAwkItemOrCommentStr()
let snum = search(a:item1, 'bW', a:lnum)
continue
endif
let s:ncp_cnum = col(".")
let enum = searchpair(
\ a:item1, '', a:item2, 'W', 's:InsideAwkItemOrCommentStr()')
if snum == enum
call cursor(snum, s:ncp_cnum)
let s:ncp_cnum = 0
let snum = search(a:item1, 'bW', a:lnum)
continue
endif
break
endwhile
call setpos(".", save_cursor)
return s:ncp_cnum
endfunction
function s:GetMatchWidth(line, lnum, item)
let line = getline(a:lnum)
if type(a:item) == type("")
let msum = match(line, a:item)
if a:line =~# '\\$' && strpart(line, msum) =~# '^\s*\\$'
let ind = indent(a:lnum) + &sw
else
let tsum = matchend(line, '\t*', 0)
let ind = strwidth(strpart(line, 0, msum)) - tsum + tsum * &tabstop + 1
endif
elseif type(a:item) == type(0)
let msum = match(strpart(line, a:item), '\S')
if a:line =~# '\\$' && msum > 1 && strpart(line, a:item) =~# '^\s*\\$'
let ind = indent(a:lnum) + &sw
else
let tsum = matchend(line, '\t*', 0)
let msum = strwidth(strpart(line, 0, a:item + msum))
let ind = msum - tsum + tsum * &tabstop
endif
else
let ind = indent(a:lnum)
endif
return ind
endfunction
function s:CloseBraceIndent(cline, ind)
let [line, lnum] = s:GetStartPairLine(a:cline, '}', '{', v:lnum)
if line =~# '^\s*{\s*$' || line =~# '^\s*switch\s*(.*)\s*{\s*$'
return indent(lnum)
else
return a:ind - &sw
endif
endfunction
function s:CurrentElseIndent(line, lnum, pline, pnum)
let pline = a:pline
let pnum = a:pnum
let line = a:line
let lnum = a:lnum
if line =~# '^\s*}\%(\s*\<else\>\%(\s\+if\)\@!\)\@!'
\ || line =~# '}\%(\s*;\)\=\s*$'
let [line, lnum] = s:GetStartPairLine(line, '}', '{', lnum)
if line =~# '^\s*\%(if\|}\=\s*else\s\+if\)\s*(.*)\s*{\s*$'
return indent(lnum)
elseif line =~# '^\s*}\=\s*else\>\%(\s\+if\)\@!'
let [line, lnum] = s:GetIfLine(line, lnum, 1)
endif
let [pline, pnum] = s:JoinContinueLine(line, lnum, 1)
elseif line =~# '^\s*\%(if\|}\=\s*else\s\+if\)\s*(.*)\s*\S'
\ && !s:AfterParenPairNoStr(lnum, 1)
\ && s:GetHideStringLine(line) !~# '\<else\>\%(\s\+if\)\@!'
return indent(lnum)
elseif line =~# '^\s*}\=\s*else\>\%(\s\+if\)\@!'
let [line, lnum] = s:GetIfLine(line, lnum, 1)
let [pline, pnum] = s:JoinContinueLine(line, lnum, 1)
elseif line =~# '^\s*while\>\s*(.*)'
\ && s:AfterParenPairNoStr(lnum, 0)
let [line, lnum] = s:GetDoLine(line, lnum)
let [pline, pnum] = s:JoinContinueLine(line, lnum, 1)
endif
while pnum
\ &&
\ (pline =~# '^\s*\%(if\|}\=\s*else\s\+if\|for\|while\)\s*(.*)'
\ && s:AfterParenPairNoStr(pnum, 0)
\ || pline =~# '^\s*}\=\s*else\s*$')
if pline =~# '^\s*\%(if\|}\=\s*else\s\+if\)\s*(.*)'
let line = pline
let lnum = pnum
break
elseif pline =~# '^\s*}\=\s*else\>\s*$'
let [pline, pnum] = s:GetIfLine(pline, pnum, 1)
endif
let line = pline
let lnum = pnum
let [pline, pnum] = s:JoinContinueLine(pline, pnum, 1)
endwhile
return indent(get(s:GetIfLine(line, lnum, 0), 1))
endfunction
function s:GetHideStringLine(line)
return s:InsideAwkItemOrCommentStr(a:line)
endfunction
function s:InsideAwkItemOrCommentStr(...)
let line = a:0 ? a:1 : getline(".")
let cnum = a:0 ? strlen(line) : col(".")
let sum = match(line, '\S')
let slash = 0
let dquote = 0
let bracket = 0
let laststr = ""
let nb_laststr = ""
let rt_line = ""
let slist = split(line, '\zs')
while sum < cnum
let str = slist[sum]
if str ==# '#' && !slash && !dquote
return a:0 ? rt_line : 1
elseif str ==# '\' && (slash || dquote) && slist[sum + 1] ==# '\'
let str = laststr
let sum += 1
elseif str ==# '[' && slash && !bracket && laststr !=# '\'
let bracket = 1
if slist[sum + 1] ==# '^' && slist[sum + 2] ==# ']'
let str = ']'
let sum += 2
elseif slist[sum + 1] ==# ']'
let str = ']'
let sum += 1
endif
elseif str ==# '[' && slash && bracket && laststr !=# '\'
\ && (slist[sum + 1] ==# ':'
\ || slist[sum + 1] ==# '.'
\ || slist[sum + 1] ==# '=')
\ && slist[matchend(line, '['. slist[sum + 1]. ']', sum + 2)] ==# ']'
let str = ']'
let sum = matchend(line, '['. slist[sum + 1]. ']', sum + 2)
elseif str ==# ']' && slash && bracket && laststr !=# '\'
let bracket = 0
elseif str ==# '/' && !slash && !dquote
\ && (!strlen(nb_laststr)
\ || nb_laststr =~# '}\|(\|\~\|,\|=\|&\||\|!\|+\|-\|*\|?\|:\|;'
\ || strpart(line, 0, sum)
\ =~# '\%(\%(^\|:\)\s*case\|\<printf\=\|\<return\)\>\s*$')
let slash = 1
let rt_line = rt_line. str
elseif str ==# '/' && slash && laststr !=# '\' && !bracket
let slash = 0
elseif str ==# '"' && !dquote && !slash
let dquote = 1
let rt_line = rt_line. str
elseif str ==# '"' && dquote && laststr !=# '\'
let dquote = 0
endif
if str !~# '\s'
let nb_laststr = str
endif
let laststr = str
let sum += 1
if !slash && !dquote
let rt_line = rt_line. str
endif
endwhile
return a:0 ? rt_line : slash || dquote
endfunction
function s:AfterParenPairNoStr(lnum, brace)
let snum = 0
let enum = 0
let cnum = 0
let estr = ""
let save_cursor = getpos(".")
call cursor(a:lnum, 1)
let snum = search('(', 'cW', a:lnum)
while snum && s:InsideAwkItemOrCommentStr()
let snum = search('(', 'W', a:lnum)
endwhile
if snum
let enum = searchpair('(', '', ')', 'W', 's:InsideAwkItemOrCommentStr()')
endif
if enum > 0
let cnum = col(".")
let estr = strpart(getline(enum), cnum)
endif
call setpos(".", save_cursor)
if cnum && a:brace && estr =~# '^\s*{\=\s*\%(#.*\)\=$'
return 1
elseif cnum && estr =~# '^\s*\%(#.*\)\=$'
return 1
else
return 0
endif
endfunction
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: set sts=2 sw=2 expandtab: