Arm: Remove unused feature files and tests
[deliverable/binutils-gdb.git] / gdb / contrib / ari / gdb_ari.sh
CommitLineData
b786c521
PM
1#!/bin/sh
2
3# GDB script to list of problems using awk.
4#
42a4f53d 5# Copyright (C) 2002-2019 Free Software Foundation, Inc.
b786c521
PM
6#
7# This file is part of GDB.
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22# Make certain that the script is not running in an internationalized
23# environment.
24
84f13595
PM
25LANG=C ; export LANG
26LC_ALL=C ; export LC_ALL
b786c521
PM
27
28# Permanent checks take the form:
29
30# Do not use XXXX, ISO C 90 implies YYYY
31# Do not use XXXX, instead use YYYY''.
32
33# and should never be removed.
34
35# Temporary checks take the form:
36
37# Replace XXXX with YYYY
38
39# and once they reach zero, can be eliminated.
40
41# FIXME: It should be able to override this on the command line
42error="regression"
43warning="regression"
44ari="regression eol code comment deprecated legacy obsolete gettext"
45all="regression eol code comment deprecated legacy obsolete gettext deprecate internal gdbarch macro"
46print_doc=0
47print_idx=0
48
49usage ()
50{
51 cat <<EOF 1>&2
52Error: $1
53
54Usage:
55 $0 --print-doc --print-idx -Wall -Werror -W<category> <file> ...
56Options:
57 --print-doc Print a list of all potential problems, then exit.
58 --print-idx Include the problems IDX (index or key) in every message.
59 --src=file Write source lines to file.
60 -Werror Treat all problems as errors.
61 -Wall Report all problems.
62 -Wari Report problems that should be fixed in new code.
3bbd9f18 63 -W<category> Report problems in the specifed category. Valid categories
b786c521
PM
64 are: ${all}
65EOF
66 exit 1
67}
68
69
70# Parse the various options
71Woptions=
72srclines=""
73while test $# -gt 0
74do
75 case "$1" in
76 -Wall ) Woptions="${all}" ;;
77 -Wari ) Woptions="${ari}" ;;
78 -Werror ) Werror=1 ;;
79 -W* ) Woptions="${Woptions} `echo x$1 | sed -e 's/x-W//'`" ;;
80 --print-doc ) print_doc=1 ;;
81 --print-idx ) print_idx=1 ;;
82 --src=* ) srclines="`echo $1 | sed -e 's/--src=/srclines=\"/'`\"" ;;
83 -- ) shift ; break ;;
84 - ) break ;;
85 -* ) usage "$1: unknown option" ;;
86 * ) break ;;
87 esac
88 shift
89done
90if test -n "$Woptions" ; then
91 warning="$Woptions"
92 error=
93fi
94
95
96# -Werror implies treating all warnings as errors.
97if test -n "${Werror}" ; then
98 error="${error} ${warning}"
99fi
100
101
102# Validate all errors and warnings.
103for w in ${warning} ${error}
104do
105 case " ${all} " in
106 *" ${w} "* ) ;;
107 * ) usage "Unknown option -W${w}" ;;
108 esac
109done
110
111
112# make certain that there is at least one file.
113if test $# -eq 0 -a ${print_doc} = 0
114then
115 usage "Missing file."
116fi
117
118
119# Convert the errors/warnings into corresponding array entries.
120for a in ${all}
121do
122 aris="${aris} ari_${a} = \"${a}\";"
123done
124for w in ${warning}
125do
126 warnings="${warnings} warning[ari_${w}] = 1;"
127done
128for e in ${error}
129do
130 errors="${errors} error[ari_${e}] = 1;"
131done
132
84f13595 133if [ "$AWK" = "" ] ; then
b786c521
PM
134 AWK=awk
135fi
136
137${AWK} -- '
138BEGIN {
139 # NOTE, for a per-file begin use "FNR == 1".
140 '"${aris}"'
141 '"${errors}"'
142 '"${warnings}"'
143 '"${srclines}"'
144 print_doc = '$print_doc'
145 print_idx = '$print_idx'
146 PWD = "'`pwd`'"
147}
148
149# Print the error message for BUG. Append SUPLEMENT if non-empty.
150function print_bug(file,line,prefix,category,bug,doc,supplement, suffix,idx) {
151 if (print_idx) {
152 idx = bug ": "
153 } else {
154 idx = ""
155 }
156 if (supplement) {
157 suffix = " (" supplement ")"
158 } else {
159 suffix = ""
160 }
161 # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
162 print file ":" line ": " prefix category ": " idx doc suffix
163 if (srclines != "") {
164 print file ":" line ":" $0 >> srclines
165 }
166}
167
168function fix(bug,file,count) {
169 skip[bug, file] = count
170 skipped[bug, file] = 0
171}
172
173function fail(bug,supplement) {
174 if (doc[bug] == "") {
175 print_bug("", 0, "internal: ", "internal", "internal", "Missing doc for bug " bug)
176 exit
177 }
178 if (category[bug] == "") {
179 print_bug("", 0, "internal: ", "internal", "internal", "Missing category for bug " bug)
180 exit
181 }
182
183 if (ARI_OK == bug) {
184 return
185 }
186 # Trim the filename down to just DIRECTORY/FILE so that it can be
187 # robustly used by the FIX code.
188
189 if (FILENAME ~ /^\//) {
190 canonicalname = FILENAME
191 } else {
192 canonicalname = PWD "/" FILENAME
193 }
194 shortname = gensub (/^.*\/([^\\]*\/[^\\]*)$/, "\\1", 1, canonicalname)
195
196 skipped[bug, shortname]++
197 if (skip[bug, shortname] >= skipped[bug, shortname]) {
198 # print FILENAME, FNR, skip[bug, FILENAME], skipped[bug, FILENAME], bug
199 # Do nothing
200 } else if (error[category[bug]]) {
201 # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
202 print_bug(FILENAME, FNR, "", category[bug], bug, doc[bug], supplement)
203 } else if (warning[category[bug]]) {
204 # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
205 print_bug(FILENAME, FNR, "warning: ", category[bug], bug, doc[bug], supplement)
206 }
207}
208
209FNR == 1 {
210 seen[FILENAME] = 1
211 if (match(FILENAME, "\\.[ly]$")) {
212 # FILENAME is a lex or yacc source
213 is_yacc_or_lex = 1
214 }
215 else {
216 is_yacc_or_lex = 0
217 }
218}
219END {
220 if (print_idx) {
221 idx = bug ": "
222 } else {
223 idx = ""
224 }
225 # Did we do only a partial skip?
226 for (bug_n_file in skip) {
227 split (bug_n_file, a, SUBSEP)
228 bug = a[1]
229 file = a[2]
230 if (seen[file] && (skipped[bug_n_file] < skip[bug_n_file])) {
231 # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
232 b = file " missing " bug
233 print_bug(file, 0, "", "internal", file " missing " bug, "Expecting " skip[bug_n_file] " occurances of bug " bug " in file " file ", only found " skipped[bug_n_file])
234 }
235 }
236}
237
238
239# Skip OBSOLETE lines
240/(^|[^_[:alnum:]])OBSOLETE([^_[:alnum:]]|$)/ { next; }
241
242# Skip ARI lines
243
244BEGIN {
245 ARI_OK = ""
246}
247
248/\/\* ARI:[[:space:]]*(.*)[[:space:]]*\*\// {
249 ARI_OK = gensub(/^.*\/\* ARI:[[:space:]]*(.*[^[:space:]])[[:space:]]*\*\/.*$/, "\\1", 1, $0)
250 # print "ARI line found \"" $0 "\""
251 # print "ARI_OK \"" ARI_OK "\""
252}
253! /\/\* ARI:[[:space:]]*(.*)[[:space:]]*\*\// {
254 ARI_OK = ""
255}
256
257
258# Things in comments
259
b786c521
PM
260BEGIN { doc["ARGSUSED"] = "\
261Do not use ARGSUSED, unnecessary"
262 category["ARGSUSED"] = ari_regression
263}
264/(^|[^_[:alnum:]])ARGSUSED([^_[:alnum:]]|$)/ {
265 fail("ARGSUSED")
266}
267
268
269# SNIP - Strip out comments - SNIP
270
271FNR == 1 {
272 comment_p = 0
273}
274comment_p && /\*\// { gsub (/^([^\*]|\*+[^\/\*])*\*+\//, " "); comment_p = 0; }
275comment_p { next; }
276!comment_p { gsub (/\/\*([^\*]|\*+[^\/\*])*\*+\//, " "); }
277!comment_p && /(^|[^"])\/\*/ { gsub (/\/\*.*$/, " "); comment_p = 1; }
278
279
280BEGIN { doc["_ markup"] = "\
281All messages should be marked up with _."
282 category["_ markup"] = ari_gettext
283}
284/^[^"]*[[:space:]](warning|error|error_no_arg|query|perror_with_name)[[:space:]]*\([^_\(a-z]/ {
285 if (! /\("%s"/) {
286 fail("_ markup")
287 }
288}
289
290BEGIN { doc["trailing new line"] = "\
291A message should not have a trailing new line"
292 category["trailing new line"] = ari_gettext
293}
294/(^|[^_[:alnum:]])(warning|error)[[:space:]]*\(_\(".*\\n"\)[\),]/ {
295 fail("trailing new line")
296}
297
298# Include files for which GDB has a custom version.
299
300BEGIN { doc["assert.h"] = "\
301Do not include assert.h, instead include \"gdb_assert.h\"";
302 category["assert.h"] = ari_regression
303 fix("assert.h", "gdb/gdb_assert.h", 0) # it does not use it
304}
305/^#[[:space:]]*include[[:space:]]+.assert\.h./ {
306 fail("assert.h")
307}
308
b786c521
PM
309BEGIN { doc["regex.h"] = "\
310Do not include regex.h, instead include gdb_regex.h"
311 category["regex.h"] = ari_regression
312 fix("regex.h", "gdb/gdb_regex.h", 1)
313}
314/^#[[:space:]]*include[[:space:]]*.regex\.h./ {
315 fail("regex.h")
316}
317
318BEGIN { doc["xregex.h"] = "\
319Do not include xregex.h, instead include gdb_regex.h"
320 category["xregex.h"] = ari_regression
321 fix("xregex.h", "gdb/gdb_regex.h", 1)
322}
323/^#[[:space:]]*include[[:space:]]*.xregex\.h./ {
324 fail("xregex.h")
325}
326
327BEGIN { doc["gnu-regex.h"] = "\
328Do not include gnu-regex.h, instead include gdb_regex.h"
329 category["gnu-regex.h"] = ari_regression
330}
331/^#[[:space:]]*include[[:space:]]*.gnu-regex\.h./ {
332 fail("gnu regex.h")
333}
334
b786c521
PM
335BEGIN { doc["wait.h"] = "\
336Do not include wait.h or sys/wait.h, instead include gdb_wait.h"
268a13a5 337 fix("wait.h", "gdbsupport/gdb_wait.h", 2);
b786c521
PM
338 category["wait.h"] = ari_regression
339}
340/^#[[:space:]]*include[[:space:]]*.wait\.h./ \
341|| /^#[[:space:]]*include[[:space:]]*.sys\/wait\.h./ {
342 fail("wait.h")
343}
344
345BEGIN { doc["vfork.h"] = "\
346Do not include vfork.h, instead include gdb_vfork.h"
347 fix("vfork.h", "gdb/gdb_vfork.h", 1);
348 category["vfork.h"] = ari_regression
349}
350/^#[[:space:]]*include[[:space:]]*.vfork\.h./ {
351 fail("vfork.h")
352}
353
354BEGIN { doc["error not internal-warning"] = "\
355Do not use error(\"internal-warning\"), instead use internal_warning"
356 category["error not internal-warning"] = ari_regression
357}
358/error.*\"[Ii]nternal.warning/ {
359 fail("error not internal-warning")
360}
361
362BEGIN { doc["%p"] = "\
363Do not use printf(\"%p\"), instead use printf(\"%s\",paddr()) to dump a \
364target address, or host_address_to_string() for a host address"
365 category["%p"] = ari_code
366}
367/%p/ && !/%prec/ {
368 fail("%p")
369}
370
371BEGIN { doc["%ll"] = "\
372Do not use printf(\"%ll\"), instead use printf(\"%s\",phex()) to dump a \
373`long long'\'' value"
374 category["%ll"] = ari_code
375}
376# Allow %ll in scanf
377/%[0-9]*ll/ && !/scanf \(.*%[0-9]*ll/ {
378 fail("%ll")
379}
380
381
382# SNIP - Strip out strings - SNIP
383
384# Test on top.c, scm-valprint.c, remote-rdi.c, ada-lang.c
385FNR == 1 {
386 string_p = 0
387 trace_string = 0
388}
389# Strip escaped characters.
390{ gsub(/\\./, "."); }
391# Strip quoted quotes.
392{ gsub(/'\''.'\''/, "'\''.'\''"); }
393# End of multi-line string
394string_p && /\"/ {
395 if (trace_string) print "EOS:" FNR, $0;
396 gsub (/^[^\"]*\"/, "'\''");
397 string_p = 0;
398}
399# Middle of multi-line string, discard line.
400string_p {
401 if (trace_string) print "MOS:" FNR, $0;
402 $0 = ""
403}
404# Strip complete strings from the middle of the line
405!string_p && /\"[^\"]*\"/ {
406 if (trace_string) print "COS:" FNR, $0;
407 gsub (/\"[^\"]*\"/, "'\''");
408}
409# Start of multi-line string
410BEGIN { doc["multi-line string"] = "\
411Multi-line string must have the newline escaped"
412 category["multi-line string"] = ari_regression
413}
414!string_p && /\"/ {
415 if (trace_string) print "SOS:" FNR, $0;
416 if (/[^\\]$/) {
417 fail("multi-line string")
418 }
419 gsub (/\"[^\"]*$/, "'\''");
420 string_p = 1;
421}
422# { print }
423
424# Multi-line string
425string_p &&
426
427# Accumulate continuation lines
428FNR == 1 {
429 cont_p = 0
430}
431!cont_p { full_line = ""; }
432/[^\\]\\$/ { gsub (/\\$/, ""); full_line = full_line $0; cont_p = 1; next; }
433cont_p { $0 = full_line $0; cont_p = 0; full_line = ""; }
434
435
436# GDB uses ISO C 90. Check for any non pure ISO C 90 code
437
438BEGIN { doc["PARAMS"] = "\
439Do not use PARAMS(), ISO C 90 implies prototypes"
440 category["PARAMS"] = ari_regression
441}
442/(^|[^_[:alnum:]])PARAMS([^_[:alnum:]]|$)/ {
443 fail("PARAMS")
444}
445
446BEGIN { doc["__func__"] = "\
447Do not use __func__, ISO C 90 does not support this macro"
448 category["__func__"] = ari_regression
268a13a5 449 fix("__func__", "gdbsupport/gdb_assert.h", 1)
b786c521
PM
450}
451/(^|[^_[:alnum:]])__func__([^_[:alnum:]]|$)/ {
452 fail("__func__")
453}
454
455BEGIN { doc["__FUNCTION__"] = "\
456Do not use __FUNCTION__, ISO C 90 does not support this macro"
457 category["__FUNCTION__"] = ari_regression
458}
459/(^|[^_[:alnum:]])__FUNCTION__([^_[:alnum:]]|$)/ {
460 fail("__FUNCTION__")
461}
462
463BEGIN { doc["__CYGWIN32__"] = "\
464Do not use __CYGWIN32__, instead use __CYGWIN__ or, better, an explicit \
465autoconf tests"
466 category["__CYGWIN32__"] = ari_regression
467}
468/(^|[^_[:alnum:]])__CYGWIN32__([^_[:alnum:]]|$)/ {
469 fail("__CYGWIN32__")
470}
471
472BEGIN { doc["PTR"] = "\
473Do not use PTR, ISO C 90 implies `void *'\''"
474 category["PTR"] = ari_regression
475 #fix("PTR", "gdb/utils.c", 6)
476}
477/(^|[^_[:alnum:]])PTR([^_[:alnum:]]|$)/ {
478 fail("PTR")
479}
480
481BEGIN { doc["UCASE function"] = "\
482Function name is uppercase."
483 category["UCASE function"] = ari_code
484 possible_UCASE = 0
485 UCASE_full_line = ""
486}
487(possible_UCASE) {
488 if (ARI_OK == "UCASE function") {
489 possible_UCASE = 0
490 }
491 # Closing brace found?
492 else if (UCASE_full_line ~ \
493 /^[A-Z][[:alnum:]_]*[[:space:]]*\([^()]*\).*$/) {
494 if ((UCASE_full_line ~ \
495 /^[A-Z][[:alnum:]_]*[[:space:]]*\([^()]*\)[[:space:]]*$/) \
496 && ($0 ~ /^\{/) && (is_yacc_or_lex == 0)) {
497 store_FNR = FNR
498 FNR = possible_FNR
499 store_0 = $0;
500 $0 = UCASE_full_line;
501 fail("UCASE function")
502 FNR = store_FNR
503 $0 = store_0;
504 }
505 possible_UCASE = 0
506 UCASE_full_line = ""
507 } else {
508 UCASE_full_line = UCASE_full_line $0;
509 }
510}
511/^[A-Z][[:alnum:]_]*[[:space:]]*\([^()]*(|\))[[:space:]]*$/ {
512 possible_UCASE = 1
513 if (ARI_OK == "UCASE function") {
514 possible_UCASE = 0
515 }
516 possible_FNR = FNR
517 UCASE_full_line = $0
518}
519
520
521BEGIN { doc["editCase function"] = "\
522Function name starts lower case but has uppercased letters."
523 category["editCase function"] = ari_code
524 possible_editCase = 0
525 editCase_full_line = ""
526}
527(possible_editCase) {
47d21dc5 528 if (ARI_OK == "editCase function") {
b786c521
PM
529 possible_editCase = 0
530 }
531 # Closing brace found?
532 else if (editCase_full_line ~ \
533/^[a-z][a-z0-9_]*[A-Z][a-z0-9A-Z_]*[[:space:]]*\([^()]*\).*$/) {
534 if ((editCase_full_line ~ \
535/^[a-z][a-z0-9_]*[A-Z][a-z0-9A-Z_]*[[:space:]]*\([^()]*\)[[:space:]]*$/) \
536 && ($0 ~ /^\{/) && (is_yacc_or_lex == 0)) {
537 store_FNR = FNR
538 FNR = possible_FNR
539 store_0 = $0;
540 $0 = editCase_full_line;
541 fail("editCase function")
542 FNR = store_FNR
543 $0 = store_0;
544 }
545 possible_editCase = 0
546 editCase_full_line = ""
547 } else {
548 editCase_full_line = editCase_full_line $0;
549 }
550}
551/^[a-z][a-z0-9_]*[A-Z][a-z0-9A-Z_]*[[:space:]]*\([^()]*(|\))[[:space:]]*$/ {
552 possible_editCase = 1
553 if (ARI_OK == "editCase function") {
554 possible_editCase = 0
555 }
556 possible_FNR = FNR
557 editCase_full_line = $0
558}
559
560# Only function implementation should be on first column
561BEGIN { doc["function call in first column"] = "\
562Function name in first column should be restricted to function implementation"
563 category["function call in first column"] = ari_code
564}
565/^[a-z][a-z0-9_]*[[:space:]]*\((|[^*][^()]*)\)[[:space:]]*[^ \t]+/ {
566 fail("function call in first column")
567}
568
569
b786c521
PM
570BEGIN { doc["hash"] = "\
571Do not use ` #...'\'', instead use `#...'\''(some compilers only correctly \
572parse a C preprocessor directive when `#'\'' is the first character on \
573the line)"
574 category["hash"] = ari_regression
575}
576/^[[:space:]]+#/ {
577 fail("hash")
578}
579
580BEGIN { doc["OP eol"] = "\
581Do not use &&, or || at the end of a line"
582 category["OP eol"] = ari_code
583}
e3f1ad4f
PM
584# * operator needs a special treatment as it can be a
585# valid end of line for a pointer type definition
586# Only catch case where an assignment or an opening brace is present
587/(\|\||\&\&|==|!=|[[:space:]][+\-\/])[[:space:]]*$/ \
588|| /(\(|=)[[:space:]].*[[:space:]]\*[[:space:]]*$/ {
b786c521
PM
589 fail("OP eol")
590}
591
592BEGIN { doc["strerror"] = "\
593Do not use strerror(), instead use safe_strerror()"
594 category["strerror"] = ari_regression
595 fix("strerror", "gdb/gdb_string.h", 1)
268a13a5
TT
596 fix("strerror", "gdb/gdbsupport/mingw-strerror.c", 1)
597 fix("strerror", "gdb/gdbsupport/posix-strerror.c", 1)
b786c521
PM
598}
599/(^|[^_[:alnum:]])strerror[[:space:]]*\(/ {
600 fail("strerror")
601}
602
603BEGIN { doc["long long"] = "\
604Do not use `long long'\'', instead use LONGEST"
605 category["long long"] = ari_code
606 # defs.h needs two such patterns for LONGEST and ULONGEST definitions
607 fix("long long", "gdb/defs.h", 2)
608}
609/(^|[^_[:alnum:]])long[[:space:]]+long([^_[:alnum:]]|$)/ {
610 fail("long long")
611}
612
613BEGIN { doc["ATTRIBUTE_UNUSED"] = "\
614Do not use ATTRIBUTE_UNUSED, do not bother (GDB is compiled with -Werror and, \
615consequently, is not able to tolerate false warnings. Since -Wunused-param \
616produces such warnings, neither that warning flag nor ATTRIBUTE_UNUSED \
617are used by GDB"
618 category["ATTRIBUTE_UNUSED"] = ari_regression
619}
620/(^|[^_[:alnum:]])ATTRIBUTE_UNUSED([^_[:alnum:]]|$)/ {
621 fail("ATTRIBUTE_UNUSED")
622}
623
624BEGIN { doc["ATTR_FORMAT"] = "\
625Do not use ATTR_FORMAT, use ATTRIBUTE_PRINTF instead"
626 category["ATTR_FORMAT"] = ari_regression
627}
628/(^|[^_[:alnum:]])ATTR_FORMAT([^_[:alnum:]]|$)/ {
629 fail("ATTR_FORMAT")
630}
631
632BEGIN { doc["ATTR_NORETURN"] = "\
633Do not use ATTR_NORETURN, use ATTRIBUTE_NORETURN instead"
634 category["ATTR_NORETURN"] = ari_regression
635}
636/(^|[^_[:alnum:]])ATTR_NORETURN([^_[:alnum:]]|$)/ {
637 fail("ATTR_NORETURN")
638}
639
640BEGIN { doc["NORETURN"] = "\
641Do not use NORETURN, use ATTRIBUTE_NORETURN instead"
642 category["NORETURN"] = ari_regression
643}
644/(^|[^_[:alnum:]])NORETURN([^_[:alnum:]]|$)/ {
645 fail("NORETURN")
646}
647
648
649# General problems
650
651BEGIN { doc["multiple messages"] = "\
652Do not use multiple calls to warning or error, instead use a single call"
653 category["multiple messages"] = ari_gettext
654}
655FNR == 1 {
656 warning_fnr = -1
657}
658/(^|[^_[:alnum:]])(warning|error)[[:space:]]*\(/ {
659 if (FNR == warning_fnr + 1) {
660 fail("multiple messages")
661 } else {
662 warning_fnr = FNR
663 }
664}
665
666# Commented out, but left inside sources, just in case.
667# BEGIN { doc["inline"] = "\
668# Do not use the inline attribute; \
669# since the compiler generally ignores this, better algorithm selection \
670# is needed to improved performance"
671# category["inline"] = ari_code
672# }
673# /(^|[^_[:alnum:]])inline([^_[:alnum:]]|$)/ {
674# fail("inline")
675# }
676
677# This test is obsolete as this type
678# has been deprecated and finally suppressed from GDB sources
679#BEGIN { doc["obj_private"] = "\
680#Replace obj_private with objfile_data"
681# category["obj_private"] = ari_obsolete
682#}
683#/(^|[^_[:alnum:]])obj_private([^_[:alnum:]]|$)/ {
684# fail("obj_private")
685#}
686
687BEGIN { doc["abort"] = "\
688Do not use abort, instead use internal_error; GDB should never abort"
689 category["abort"] = ari_regression
690 fix("abort", "gdb/utils.c", 3)
691}
692/(^|[^_[:alnum:]])abort[[:space:]]*\(/ {
693 fail("abort")
694}
695
696BEGIN { doc["basename"] = "\
697Do not use basename, instead use lbasename"
698 category["basename"] = ari_regression
699}
700/(^|[^_[:alnum:]])basename[[:space:]]*\(/ {
701 fail("basename")
702}
703
704BEGIN { doc["assert"] = "\
705Do not use assert, instead use gdb_assert or internal_error; assert \
706calls abort and GDB should never call abort"
707 category["assert"] = ari_regression
708}
709/(^|[^_[:alnum:]])assert[[:space:]]*\(/ {
710 fail("assert")
711}
712
713BEGIN { doc["TARGET_HAS_HARDWARE_WATCHPOINTS"] = "\
714Replace TARGET_HAS_HARDWARE_WATCHPOINTS with nothing, not needed"
715 category["TARGET_HAS_HARDWARE_WATCHPOINTS"] = ari_regression
716}
717/(^|[^_[:alnum:]])TARGET_HAS_HARDWARE_WATCHPOINTS([^_[:alnum:]]|$)/ {
718 fail("TARGET_HAS_HARDWARE_WATCHPOINTS")
719}
720
721BEGIN { doc["ADD_SHARED_SYMBOL_FILES"] = "\
722Replace ADD_SHARED_SYMBOL_FILES with nothing, not needed?"
723 category["ADD_SHARED_SYMBOL_FILES"] = ari_regression
724}
725/(^|[^_[:alnum:]])ADD_SHARED_SYMBOL_FILES([^_[:alnum:]]|$)/ {
726 fail("ADD_SHARED_SYMBOL_FILES")
727}
728
729BEGIN { doc["SOLIB_ADD"] = "\
730Replace SOLIB_ADD with nothing, not needed?"
27fd0c6b 731 category["SOLIB_ADD"] = ari_regression
b786c521
PM
732}
733/(^|[^_[:alnum:]])SOLIB_ADD([^_[:alnum:]]|$)/ {
734 fail("SOLIB_ADD")
735}
736
737BEGIN { doc["SOLIB_CREATE_INFERIOR_HOOK"] = "\
738Replace SOLIB_CREATE_INFERIOR_HOOK with nothing, not needed?"
27fd0c6b 739 category["SOLIB_CREATE_INFERIOR_HOOK"] = ari_regression
b786c521
PM
740}
741/(^|[^_[:alnum:]])SOLIB_CREATE_INFERIOR_HOOK([^_[:alnum:]]|$)/ {
742 fail("SOLIB_CREATE_INFERIOR_HOOK")
743}
744
745BEGIN { doc["SOLIB_LOADED_LIBRARY_PATHNAME"] = "\
746Replace SOLIB_LOADED_LIBRARY_PATHNAME with nothing, not needed?"
747 category["SOLIB_LOADED_LIBRARY_PATHNAME"] = ari_regression
748}
749/(^|[^_[:alnum:]])SOLIB_LOADED_LIBRARY_PATHNAME([^_[:alnum:]]|$)/ {
750 fail("SOLIB_LOADED_LIBRARY_PATHNAME")
751}
752
753BEGIN { doc["REGISTER_U_ADDR"] = "\
754Replace REGISTER_U_ADDR with nothing, not needed?"
755 category["REGISTER_U_ADDR"] = ari_regression
756}
757/(^|[^_[:alnum:]])REGISTER_U_ADDR([^_[:alnum:]]|$)/ {
758 fail("REGISTER_U_ADDR")
759}
760
761BEGIN { doc["PROCESS_LINENUMBER_HOOK"] = "\
762Replace PROCESS_LINENUMBER_HOOK with nothing, not needed?"
763 category["PROCESS_LINENUMBER_HOOK"] = ari_regression
764}
765/(^|[^_[:alnum:]])PROCESS_LINENUMBER_HOOK([^_[:alnum:]]|$)/ {
766 fail("PROCESS_LINENUMBER_HOOK")
767}
768
769BEGIN { doc["PC_SOLIB"] = "\
770Replace PC_SOLIB with nothing, not needed?"
27fd0c6b 771 category["PC_SOLIB"] = ari_regression
b786c521
PM
772}
773/(^|[^_[:alnum:]])PC_SOLIB([^_[:alnum:]]|$)/ {
774 fail("PC_SOLIB")
775}
776
777BEGIN { doc["IN_SOLIB_DYNSYM_RESOLVE_CODE"] = "\
778Replace IN_SOLIB_DYNSYM_RESOLVE_CODE with nothing, not needed?"
779 category["IN_SOLIB_DYNSYM_RESOLVE_CODE"] = ari_regression
780}
781/(^|[^_[:alnum:]])IN_SOLIB_DYNSYM_RESOLVE_CODE([^_[:alnum:]]|$)/ {
782 fail("IN_SOLIB_DYNSYM_RESOLVE_CODE")
783}
784
785BEGIN { doc["GCC_COMPILED_FLAG_SYMBOL"] = "\
786Replace GCC_COMPILED_FLAG_SYMBOL with nothing, not needed?"
787 category["GCC_COMPILED_FLAG_SYMBOL"] = ari_deprecate
788}
789/(^|[^_[:alnum:]])GCC_COMPILED_FLAG_SYMBOL([^_[:alnum:]]|$)/ {
790 fail("GCC_COMPILED_FLAG_SYMBOL")
791}
792
793BEGIN { doc["GCC2_COMPILED_FLAG_SYMBOL"] = "\
794Replace GCC2_COMPILED_FLAG_SYMBOL with nothing, not needed?"
795 category["GCC2_COMPILED_FLAG_SYMBOL"] = ari_deprecate
796}
797/(^|[^_[:alnum:]])GCC2_COMPILED_FLAG_SYMBOL([^_[:alnum:]]|$)/ {
798 fail("GCC2_COMPILED_FLAG_SYMBOL")
799}
800
801BEGIN { doc["FUNCTION_EPILOGUE_SIZE"] = "\
802Replace FUNCTION_EPILOGUE_SIZE with nothing, not needed?"
803 category["FUNCTION_EPILOGUE_SIZE"] = ari_regression
804}
805/(^|[^_[:alnum:]])FUNCTION_EPILOGUE_SIZE([^_[:alnum:]]|$)/ {
806 fail("FUNCTION_EPILOGUE_SIZE")
807}
808
809BEGIN { doc["HAVE_VFORK"] = "\
810Do not use HAVE_VFORK, instead include \"gdb_vfork.h\" and call vfork() \
811unconditionally"
812 category["HAVE_VFORK"] = ari_regression
813}
814/(^|[^_[:alnum:]])HAVE_VFORK([^_[:alnum:]]|$)/ {
815 fail("HAVE_VFORK")
816}
817
818BEGIN { doc["bcmp"] = "\
819Do not use bcmp(), ISO C 90 implies memcmp()"
820 category["bcmp"] = ari_regression
821}
822/(^|[^_[:alnum:]])bcmp[[:space:]]*\(/ {
823 fail("bcmp")
824}
825
826BEGIN { doc["setlinebuf"] = "\
827Do not use setlinebuf(), ISO C 90 implies setvbuf()"
828 category["setlinebuf"] = ari_regression
829}
830/(^|[^_[:alnum:]])setlinebuf[[:space:]]*\(/ {
831 fail("setlinebuf")
832}
833
834BEGIN { doc["bcopy"] = "\
835Do not use bcopy(), ISO C 90 implies memcpy() and memmove()"
836 category["bcopy"] = ari_regression
837}
838/(^|[^_[:alnum:]])bcopy[[:space:]]*\(/ {
839 fail("bcopy")
840}
841
842BEGIN { doc["get_frame_base"] = "\
843Replace get_frame_base with get_frame_id, get_frame_base_address, \
844get_frame_locals_address, or get_frame_args_address."
845 category["get_frame_base"] = ari_obsolete
846}
847/(^|[^_[:alnum:]])get_frame_base([^_[:alnum:]]|$)/ {
848 fail("get_frame_base")
849}
850
851BEGIN { doc["floatformat_to_double"] = "\
852Do not use floatformat_to_double() from libierty, \
853instead use floatformat_to_doublest()"
854 fix("floatformat_to_double", "gdb/doublest.c", 1)
855 category["floatformat_to_double"] = ari_regression
856}
857/(^|[^_[:alnum:]])floatformat_to_double[[:space:]]*\(/ {
858 fail("floatformat_to_double")
859}
860
861BEGIN { doc["floatformat_from_double"] = "\
862Do not use floatformat_from_double() from libierty, \
863instead use floatformat_from_doublest()"
864 category["floatformat_from_double"] = ari_regression
865}
866/(^|[^_[:alnum:]])floatformat_from_double[[:space:]]*\(/ {
867 fail("floatformat_from_double")
868}
869
870BEGIN { doc["BIG_ENDIAN"] = "\
871Do not use BIG_ENDIAN, instead use BFD_ENDIAN_BIG"
872 category["BIG_ENDIAN"] = ari_regression
873}
874/(^|[^_[:alnum:]])BIG_ENDIAN([^_[:alnum:]]|$)/ {
875 fail("BIG_ENDIAN")
876}
877
878BEGIN { doc["LITTLE_ENDIAN"] = "\
879Do not use LITTLE_ENDIAN, instead use BFD_ENDIAN_LITTLE";
880 category["LITTLE_ENDIAN"] = ari_regression
881}
882/(^|[^_[:alnum:]])LITTLE_ENDIAN([^_[:alnum:]]|$)/ {
883 fail("LITTLE_ENDIAN")
884}
885
886BEGIN { doc["BIG_ENDIAN"] = "\
887Do not use BIG_ENDIAN, instead use BFD_ENDIAN_BIG"
888 category["BIG_ENDIAN"] = ari_regression
889}
890/(^|[^_[:alnum:]])BIG_ENDIAN([^_[:alnum:]]|$)/ {
891 fail("BIG_ENDIAN")
892}
893
894BEGIN { doc["sec_ptr"] = "\
895Instead of sec_ptr, use struct bfd_section";
896 category["sec_ptr"] = ari_regression
897}
898/(^|[^_[:alnum:]])sec_ptr([^_[:alnum:]]|$)/ {
899 fail("sec_ptr")
900}
901
902BEGIN { doc["frame_unwind_unsigned_register"] = "\
903Replace frame_unwind_unsigned_register with frame_unwind_register_unsigned"
904 category["frame_unwind_unsigned_register"] = ari_regression
905}
906/(^|[^_[:alnum:]])frame_unwind_unsigned_register([^_[:alnum:]]|$)/ {
907 fail("frame_unwind_unsigned_register")
908}
909
910BEGIN { doc["frame_register_read"] = "\
911Replace frame_register_read() with get_frame_register(), or \
912possibly introduce a new method safe_get_frame_register()"
913 category["frame_register_read"] = ari_obsolete
914}
915/(^|[^_[:alnum:]])frame_register_read([^_[:alnum:]]|$)/ {
916 fail("frame_register_read")
917}
918
919BEGIN { doc["read_register"] = "\
920Replace read_register() with regcache_read() et.al."
921 category["read_register"] = ari_regression
922}
923/(^|[^_[:alnum:]])read_register([^_[:alnum:]]|$)/ {
924 fail("read_register")
925}
926
927BEGIN { doc["write_register"] = "\
928Replace write_register() with regcache_read() et.al."
929 category["write_register"] = ari_regression
930}
931/(^|[^_[:alnum:]])write_register([^_[:alnum:]]|$)/ {
932 fail("write_register")
933}
934
935function report(name) {
936 # Drop any trailing _P.
937 name = gensub(/(_P|_p)$/, "", 1, name)
938 # Convert to lower case
939 name = tolower(name)
940 # Split into category and bug
941 cat = gensub(/^([[:alpha:]]+)_([_[:alnum:]]*)$/, "\\1", 1, name)
942 bug = gensub(/^([[:alpha:]]+)_([_[:alnum:]]*)$/, "\\2", 1, name)
943 # Report it
944 name = cat " " bug
945 doc[name] = "Do not use " cat " " bug ", see declaration for details"
946 category[name] = cat
947 fail(name)
948}
949
950/(^|[^_[:alnum:]])(DEPRECATED|deprecated|set_gdbarch_deprecated|LEGACY|legacy|set_gdbarch_legacy)_/ {
951 line = $0
952 # print "0 =", $0
953 while (1) {
954 name = gensub(/^(|.*[^_[:alnum:]])((DEPRECATED|deprecated|LEGACY|legacy)_[_[:alnum:]]*)(.*)$/, "\\2", 1, line)
955 line = gensub(/^(|.*[^_[:alnum:]])((DEPRECATED|deprecated|LEGACY|legacy)_[_[:alnum:]]*)(.*)$/, "\\1 \\4", 1, line)
956 # print "name =", name, "line =", line
957 if (name == line) break;
958 report(name)
959 }
960}
961
962# Count the number of times each architecture method is set
963/(^|[^_[:alnum:]])set_gdbarch_[_[:alnum:]]*([^_[:alnum:]]|$)/ {
964 name = gensub(/^.*set_gdbarch_([_[:alnum:]]*).*$/, "\\1", 1, $0)
965 doc["set " name] = "\
966Call to set_gdbarch_" name
967 category["set " name] = ari_gdbarch
968 fail("set " name)
969}
970
971# Count the number of times each tm/xm/nm macro is defined or undefined
972/^#[[:space:]]*(undef|define)[[:space:]]+[[:alnum:]_]+.*$/ \
973&& !/^#[[:space:]]*(undef|define)[[:space:]]+[[:alnum:]_]+_H($|[[:space:]])/ \
974&& FILENAME ~ /(^|\/)config\/(|[^\/]*\/)(tm-|xm-|nm-).*\.h$/ {
975 basename = gensub(/(^|.*\/)([^\/]*)$/, "\\2", 1, FILENAME)
976 type = gensub(/^(tm|xm|nm)-.*\.h$/, "\\1", 1, basename)
977 name = gensub(/^#[[:space:]]*(undef|define)[[:space:]]+([[:alnum:]_]+).*$/, "\\2", 1, $0)
978 if (type == basename) {
979 type = "macro"
980 }
981 doc[type " " name] = "\
982Do not define macros such as " name " in a tm, nm or xm file, \
983in fact do not provide a tm, nm or xm file"
984 category[type " " name] = ari_macro
985 fail(type " " name)
986}
987
988BEGIN { doc["deprecated_registers"] = "\
989Replace deprecated_registers with nothing, they have reached \
990end-of-life"
991 category["deprecated_registers"] = ari_eol
992}
993/(^|[^_[:alnum:]])deprecated_registers([^_[:alnum:]]|$)/ {
994 fail("deprecated_registers")
995}
996
997BEGIN { doc["read_pc"] = "\
998Replace READ_PC() with frame_pc_unwind; \
999at present the inferior function call code still uses this"
1000 category["read_pc"] = ari_deprecate
1001}
1002/(^|[^_[:alnum:]])read_pc[[:space:]]*\(/ || \
1003/(^|[^_[:alnum:]])set_gdbarch_read_pc[[:space:]]*\(/ || \
1004/(^|[^_[:alnum:]])TARGET_READ_PC[[:space:]]*\(/ {
1005 fail("read_pc")
1006}
1007
1008BEGIN { doc["write_pc"] = "\
1009Replace write_pc() with get_frame_base_address or get_frame_id; \
1010at present the inferior function call code still uses this when doing \
1011a DECR_PC_AFTER_BREAK"
1012 category["write_pc"] = ari_deprecate
1013}
1014/(^|[^_[:alnum:]])write_pc[[:space:]]*\(/ || \
b786c521
PM
1015/(^|[^_[:alnum:]])TARGET_WRITE_PC[[:space:]]*\(/ {
1016 fail("write_pc")
1017}
1018
1019BEGIN { doc["generic_target_write_pc"] = "\
1020Replace generic_target_write_pc with a per-architecture implementation, \
1021this relies on PC_REGNUM which is being eliminated"
1022 category["generic_target_write_pc"] = ari_regression
1023}
1024/(^|[^_[:alnum:]])generic_target_write_pc([^_[:alnum:]]|$)/ {
1025 fail("generic_target_write_pc")
1026}
1027
1028BEGIN { doc["read_sp"] = "\
1029Replace read_sp() with frame_sp_unwind"
1030 category["read_sp"] = ari_regression
1031}
1032/(^|[^_[:alnum:]])read_sp[[:space:]]*\(/ || \
1033/(^|[^_[:alnum:]])set_gdbarch_read_sp[[:space:]]*\(/ || \
1034/(^|[^_[:alnum:]])TARGET_READ_SP[[:space:]]*\(/ {
1035 fail("read_sp")
1036}
1037
1038BEGIN { doc["register_cached"] = "\
1039Replace register_cached() with nothing, does not have a regcache parameter"
1040 category["register_cached"] = ari_regression
1041}
1042/(^|[^_[:alnum:]])register_cached[[:space:]]*\(/ {
1043 fail("register_cached")
1044}
1045
1046BEGIN { doc["set_register_cached"] = "\
1047Replace set_register_cached() with nothing, does not have a regcache parameter"
1048 category["set_register_cached"] = ari_regression
1049}
1050/(^|[^_[:alnum:]])set_register_cached[[:space:]]*\(/ {
1051 fail("set_register_cached")
1052}
1053
1054# Print functions: Use versions that either check for buffer overflow
1055# or safely allocate a fresh buffer.
1056
1057BEGIN { doc["sprintf"] = "\
1058Do not use sprintf, instead use xsnprintf or xstrprintf"
1059 category["sprintf"] = ari_code
1060}
1061/(^|[^_[:alnum:]])sprintf[[:space:]]*\(/ {
1062 fail("sprintf")
1063}
1064
1065BEGIN { doc["vsprintf"] = "\
1066Do not use vsprintf(), instead use xstrvprintf"
1067 category["vsprintf"] = ari_regression
1068}
1069/(^|[^_[:alnum:]])vsprintf[[:space:]]*\(/ {
1070 fail("vsprintf")
1071}
1072
1073BEGIN { doc["asprintf"] = "\
1074Do not use asprintf(), instead use xstrprintf()"
1075 category["asprintf"] = ari_regression
1076}
1077/(^|[^_[:alnum:]])asprintf[[:space:]]*\(/ {
1078 fail("asprintf")
1079}
1080
1081BEGIN { doc["vasprintf"] = "\
1082Do not use vasprintf(), instead use xstrvprintf"
268a13a5 1083 fix("vasprintf", "gdbsupport/common-utils.c", 1)
b786c521
PM
1084 category["vasprintf"] = ari_regression
1085}
1086/(^|[^_[:alnum:]])vasprintf[[:space:]]*\(/ {
1087 fail("vasprintf")
1088}
1089
cc188e5f
JB
1090BEGIN { doc["printf_vma"] = "\
1091Do not use printf_vma, instead use paddress or phex_nz"
1092 category["printf_vma"] = ari_code
1093}
1094/(^|[^_[:alnum:]])printf_vma[[:space:]]*\(/ {
1095 fail("printf_vma")
1096}
1097
1098BEGIN { doc["sprintf_vma"] = "\
1099Do not use sprintf_vma, instead use paddress or phex_nz"
1100 category["sprintf_vma"] = ari_code
1101}
1102/(^|[^_[:alnum:]])sprintf_vma[[:space:]]*\(/ {
1103 fail("sprintf_vma")
1104}
1105
b786c521
PM
1106# More generic memory operations
1107
1108BEGIN { doc["bzero"] = "\
1109Do not use bzero(), instead use memset()"
1110 category["bzero"] = ari_regression
1111}
1112/(^|[^_[:alnum:]])bzero[[:space:]]*\(/ {
1113 fail("bzero")
1114}
1115
1116BEGIN { doc["strdup"] = "\
1117Do not use strdup(), instead use xstrdup()";
1118 category["strdup"] = ari_regression
1119}
1120/(^|[^_[:alnum:]])strdup[[:space:]]*\(/ {
1121 fail("strdup")
1122}
1123
1124BEGIN { doc["strsave"] = "\
1125Do not use strsave(), instead use xstrdup() et.al."
1126 category["strsave"] = ari_regression
1127}
1128/(^|[^_[:alnum:]])strsave[[:space:]]*\(/ {
1129 fail("strsave")
1130}
1131
1132# String compare functions
1133
1134BEGIN { doc["strnicmp"] = "\
1135Do not use strnicmp(), instead use strncasecmp()"
1136 category["strnicmp"] = ari_regression
1137}
1138/(^|[^_[:alnum:]])strnicmp[[:space:]]*\(/ {
1139 fail("strnicmp")
1140}
1141
1142# Boolean expressions and conditionals
1143
1144BEGIN { doc["boolean"] = "\
1f2e9c5e 1145Do not use `boolean'\'', use `bool'\'' instead"
b786c521
PM
1146 category["boolean"] = ari_regression
1147}
1148/(^|[^_[:alnum:]])boolean([^_[:alnum:]]|$)/ {
1149 if (is_yacc_or_lex == 0) {
1150 fail("boolean")
1151 }
1152}
1153
b786c521
PM
1154# Typedefs that are either redundant or can be reduced to `struct
1155# type *''.
1156# Must be placed before if assignment otherwise ARI exceptions
1157# are not handled correctly.
1158
1159BEGIN { doc["d_namelen"] = "\
1160Do not use dirent.d_namelen, instead use NAMELEN"
1161 category["d_namelen"] = ari_regression
1162}
1163/(^|[^_[:alnum:]])d_namelen([^_[:alnum:]]|$)/ {
1164 fail("d_namelen")
1165}
1166
1167BEGIN { doc["strlen d_name"] = "\
1168Do not use strlen dirent.d_name, instead use NAMELEN"
1169 category["strlen d_name"] = ari_regression
1170}
1171/(^|[^_[:alnum:]])strlen[[:space:]]*\(.*[^_[:alnum:]]d_name([^_[:alnum:]]|$)/ {
1172 fail("strlen d_name")
1173}
1174
1175BEGIN { doc["var_boolean"] = "\
1176Replace var_boolean with add_setshow_boolean_cmd"
1177 category["var_boolean"] = ari_regression
1178 fix("var_boolean", "gdb/command.h", 1)
1179 # fix only uses the last directory level
1180 fix("var_boolean", "cli/cli-decode.c", 2)
1181}
1182/(^|[^_[:alnum:]])var_boolean([^_[:alnum:]]|$)/ {
84f13595
PM
1183 if (($0 !~ /(^|[^_[:alnum:]])case *var_boolean:/) \
1184 && ($0 !~ /(^|[^_[:alnum:]])[=!]= *var_boolean/)) {
b786c521
PM
1185 fail("var_boolean")
1186 }
1187}
1188
1189BEGIN { doc["generic_use_struct_convention"] = "\
1190Replace generic_use_struct_convention with nothing, \
1191EXTRACT_STRUCT_VALUE_ADDRESS is a predicate"
1192 category["generic_use_struct_convention"] = ari_regression
1193}
1194/(^|[^_[:alnum:]])generic_use_struct_convention([^_[:alnum:]]|$)/ {
1195 fail("generic_use_struct_convention")
1196}
1197
1198BEGIN { doc["if assignment"] = "\
1199An IF statement'\''s expression contains an assignment (the GNU coding \
1200standard discourages this)"
1201 category["if assignment"] = ari_code
1202}
1203BEGIN { doc["if clause more than 50 lines"] = "\
1204An IF statement'\''s expression expands over 50 lines"
1205 category["if clause more than 50 lines"] = ari_code
1206}
1207#
1208# Accumulate continuation lines
1209FNR == 1 {
1210 in_if = 0
1211}
1212
1213/(^|[^_[:alnum:]])if / {
1214 in_if = 1;
1215 if_brace_level = 0;
1216 if_cont_p = 0;
1217 if_count = 0;
1218 if_brace_end_pos = 0;
1219 if_full_line = "";
1220}
1221(in_if) {
1222 # We want everything up to closing brace of same level
1223 if_count++;
1224 if (if_count > 50) {
1225 print "multiline if: " if_full_line $0
1226 fail("if clause more than 50 lines")
1227 if_brace_level = 0;
1228 if_full_line = "";
1229 } else {
1230 if (if_count == 1) {
1231 i = index($0,"if ");
1232 } else {
1233 i = 1;
1234 }
1235 for (i=i; i <= length($0); i++) {
1236 char = substr($0,i,1);
1237 if (char == "(") { if_brace_level++; }
1238 if (char == ")") {
1239 if_brace_level--;
1240 if (!if_brace_level) {
1241 if_brace_end_pos = i;
1242 after_if = substr($0,i+1,length($0));
1243 # Do not parse what is following
1244 break;
1245 }
1246 }
1247 }
1248 if (if_brace_level == 0) {
1249 $0 = substr($0,1,i);
1250 in_if = 0;
1251 } else {
1252 if_full_line = if_full_line $0;
1253 if_cont_p = 1;
1254 next;
1255 }
1256 }
1257}
1258# if we arrive here, we need to concatenate, but we are at brace level 0
1259
1260(if_brace_end_pos) {
1261 $0 = if_full_line substr($0,1,if_brace_end_pos);
1262 if (if_count > 1) {
1263 # print "IF: multi line " if_count " found at " FILENAME ":" FNR " \"" $0 "\""
1264 }
1265 if_cont_p = 0;
1266 if_full_line = "";
1267}
1268/(^|[^_[:alnum:]])if .* = / {
1269 # print "fail in if " $0
1270 fail("if assignment")
1271}
1272(if_brace_end_pos) {
1273 $0 = $0 after_if;
1274 if_brace_end_pos = 0;
1275 in_if = 0;
1276}
1277
1278# Printout of all found bug
1279
1280BEGIN {
1281 if (print_doc) {
1282 for (bug in doc) {
1283 fail(bug)
1284 }
1285 exit
1286 }
1287}' "$@"
1288
This page took 0.589584 seconds and 4 git commands to generate.