| 1 |
#!/usr/bin/awk -f |
| 2 |
# Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| 3 |
# |
| 4 |
# This program is free software; you can redistribute it and/or modify it |
| 5 |
# under the terms of the GNU General Public License as published by the |
| 6 |
# Free Software Foundation; either version 3, or (at your option) any |
| 7 |
# later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program; see the file COPYING3. If not see |
| 16 |
# <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
# This awk script checks that aarch64-sve.md (passed either on the |
| 19 |
# command line or via stdin) has an up-to-date contents section. |
| 20 |
|
| 21 |
BEGIN { |
| 22 |
seen1 = 0 |
| 23 |
seen2 = 0 |
| 24 |
errors = 0 |
| 25 |
} |
| 26 |
|
| 27 |
# The headings in the comments use a two-level hierarchy: ";; == ..." |
| 28 |
# for major sections and ";; ---- ..." for minor sections. Each section |
| 29 |
# heading must be unique. |
| 30 |
# |
| 31 |
# The contents section should list all the section headings, using the |
| 32 |
# same text and in the same order. We should therefore see exactly two |
| 33 |
# copies of the section list. |
| 34 |
/^;; == / || /^;; ---- / { |
| 35 |
if ($0 in seen || seen2 > 0) |
| 36 |
{ |
| 37 |
if (seen2 >= seen1) |
| 38 |
{ |
| 39 |
printf "error: line not in contents: %s\n", $0 > "/dev/stderr" |
| 40 |
errors += 1 |
| 41 |
exit(1) |
| 42 |
} |
| 43 |
if ($0 != order[seen2]) |
| 44 |
{ |
| 45 |
printf "error: mismatched contents\n saw: %s\nexpected: %s\n", \ |
| 46 |
$0, order[seen2] > "/dev/stderr" |
| 47 |
errors += 1 |
| 48 |
exit(1) |
| 49 |
} |
| 50 |
seen2 += 1 |
| 51 |
} |
| 52 |
else |
| 53 |
{ |
| 54 |
seen[$0] = 1 |
| 55 |
order[seen1] = $0 |
| 56 |
seen1 += 1 |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
END { |
| 61 |
if (seen2 < seen1 && errors == 0) |
| 62 |
{ |
| 63 |
printf "error: line only in contents: %s\n", order[seen2] > "/dev/stderr" |
| 64 |
exit(1) |
| 65 |
} |
| 66 |
} |