3 # Copyright 2014 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>.
21 # Check that the @safety notes are self-consistent, i.e., that they're
22 # in proper order (mt then as then ac), that remarks appear within
23 # corresponding sections (mt within mt, etc), that unsafety always has
24 # an explicit reason and when there's a reason for unsafety it's not
25 # safe, and that there aren't duplicates remarks.
30 # If no arguments are given, take all *.texi files in the current directory.
31 test $# != 0 ||
set *.texi
33 # Check that all safety remarks have entries for all of MT, AS and AC,
34 # in this order, with an optional prelim note before them.
35 grep -n '^@safety' "$@" |
36 grep -v ':@safety{\(@prelim{}\)\?@mt\(un\)\?safe{.*}'\
37 '@as\(un\)\?safe{.*}@ac\(un\)\?safe{.*}}' &&
40 # Check that @mt-started notes appear within @mtsafe or @mtunsafe,
41 # that @as-started notes appear within @assafe or @asunsafe, and that
42 # @ac-started notes appear within @acsafe or @acunsafe. Also check
43 # that @mt, @as and @ac are followed by an s (for safe) or u (for
44 # unsafe), but let @mt have as, ac or asc before [su], and let @as
45 # have a c (for cancel) before [su]. Also make sure blanks separate
46 # each of the annotations.
47 grep -n '^@safety' "$@" |
48 grep -v ':@safety{\(@prelim{}\)\?'\
49 '@mt\(un\)\?safe{\(@mt\(asc\?\|ac\)\?[su][^ ]*}\)\?'\
50 '\( @mt\(asc\?\|ac\)\?[su][^ ]*}\)*}'\
51 '@as\(un\)\?safe{\(@asc\?[su][^ ]*}\)\?'\
52 '\( @asc\?[su][^ ]*}\)*}'\
53 '@ac\(un\)\?safe{\(@ac[su][^ ]*}\)\?'\
54 '\( @ac[su][^ ]*}\)*}}' &&
57 # Make sure safety lines marked as @mtsafe do not contain any
58 # MT-Unsafe remark; that would be @mtu, but there could be as, ac or
59 # asc between mt and u.
60 grep -n '^@safety.*@mtsafe' "$@" |
61 grep '@mt\(asc\?\|ac\)?u' "$@" &&
64 # Make sure @mtunsafe lines contain at least one @mtu remark (with
65 # optional as, ac or asc between mt and u).
66 grep -n '^@safety.*@mtunsafe' "$@" |
67 grep -v '@mtunsafe{.*@mt\(asc\?\|ac\)\?u' &&
70 # Make sure safety lines marked as @assafe do not contain any AS-Unsafe
71 # remark, which could be @asu or @mtasu note (with an optional c
72 # between as and u in both cases).
73 grep -n '^@safety.*@assafe' "$@" |
74 grep '@\(mt\)\?asc\?u' &&
77 # Make sure @asunsafe lines contain at least one @asu remark (which
78 # could be @ascu, or @mtasu or even @mtascu).
79 grep -n '^@safety.*@asunsafe' "$@" |
80 grep -v '@mtasc\?u.*@asunsafe\|@asunsafe{.*@asc\?u' &&
83 # Make sure safety lines marked as @acsafe do not contain any
84 # AC-Unsafe remark, which could be @acu, @ascu or even @mtacu or
86 grep -n '^@safety.*@acsafe' "$@" |
87 grep '@\(mt\)\?as\?cu' &&
90 # Make sure @acunsafe lines contain at least one @acu remark (possibly
91 # implied by @ascu, @mtacu or @mtascu).
92 grep -n '^@safety.*@acunsafe' "$@" |
93 grep -v '@\(mtas\?\|as\)cu.*@acunsafe\|@acunsafe{.*@acu' &&
96 # Make sure there aren't duplicate remarks in the same safety note.
97 grep -n '^@safety' "$@" |
98 grep '[^:]\(@\(mt\|a[sc]\)[^ {]*{[^ ]*}\).*[^:]\1' &&
101 # Check that comments containing safety remarks do not contain {}s,
102 # that all @mt remarks appear before @as remarks, that in turn appear
103 # before @ac remarks, all properly blank-separated, and that an
104 # optional comment about exclusions is between []s at the end of the
106 grep -n '^@c \+[^@ ]\+\( dup\)\?'\
107 '\( @\(mt\|a[sc]\)[^ ]*\)*\( \[.*\]\)\?$' "$@" |
108 grep -v ':@c *[^@{}]*\( @mt[^ {}]*\)*'\
109 '\( @as[^ {}]*\)*\( @ac[^ {}]*\)*\( \[.*\]\)\?$' &&
112 # Check that comments containing safety remarks do not contain
114 grep -n '^@c \+[^@ ]\+\( dup\)\?'\
115 '\( @\(mt\|a[sc]\)[^ ]*\)*\( \[.*\]\)\?$' "$@" |
116 grep '[^:]\(@\(mt\|a[sc]\)[^ ]*\) \(.*[^:]\)\?\1\($\| \)' &&