| #! /bin/sh | |
| # Check GNAT's P A C K A G E . N A M E S | |
| # Copyright (C) 2026 Free Software Foundation, Inc. | |
| # This file is part of GCC. | |
| # GCC is free software; you can redistribute it and/or modify it under | |
| # the terms of the GNU General Public License as published by the Free | |
| # Software Foundation; either version 3, or (at your option) any later | |
| # version. | |
| # GCC is distributed in the hope that it will be useful, but WITHOUT | |
| # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | |
| # License for more details. | |
| # You should have received a copy of the GNU General Public License | |
| # along with GCC; see the file COPYING3. If not see | |
| # <http://www.gnu.org/licenses/>. | |
| grep -l '^package ' "$@" /dev/null | | |
| { | |
| success=: | |
| while read f; do | |
| pkg=`sed -n '/^separate/ { | |
| : loop | |
| N; | |
| /\npackage body /! { s,\n.*,,; b loop; } | |
| s,^separate (\(.*\))\n*\(package body \),\2\1.,; | |
| } | |
| s,^package \(body \)\?\([^ ]*\)\( is\)\?$,\2,p' "$f"` | |
| PKG=`printf "%s\n" "$pkg" | tr '[:lower:]' '[:upper:]'` | |
| P_K_G=`printf "%s\n" "$PKG" | sed 's,.,& ,g;s, $,,'` | |
| xpkg=`printf "%s\n" "$pkg" | sed 's,[.],[.],g'` | |
| xPKG=`printf "%s\n" "$PKG" | sed 's,[.],[.],g'` | |
| xP_K_G=`printf "%s\n" "$P_K_G" | sed 's,[.],[.],g'` | |
| pat="\($xpkg\|$xPKG\|$xP_K_G\)" | |
| if grep -q "^-- *$pat *--$" "$f" || | |
| grep '^-- *\([^ ] \)\{3,\}[^ ] *--$' "$f" | tr -d '\n' | | |
| sed 's, *---- *, ,g' | | |
| grep -q " $pat "; then | |
| : | |
| else | |
| success=false | |
| echo $f: no $P_K_G >&2 | |
| fi | |
| done | |
| $success | |
| } |