1#! /bin/sh
2
3########################################################################
4##
5## Copyright (C) 2009-2021 The Octave Project Developers
6##
7## See the file COPYRIGHT.md in the top-level directory of this
8## distribution or <https://octave.org/copyright/>.
9##
10## This file is part of Octave.
11##
12## Octave is free software: you can redistribute it and/or modify it
13## under the terms of the GNU General Public License as published by
14## the Free Software Foundation, either version 3 of the License, or
15## (at your option) any later version.
16##
17## Octave is distributed in the hope that it will be useful, but
18## WITHOUT ANY WARRANTY; without even the implied warranty of
19## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20## GNU General Public License for more details.
21##
22## You should have received a copy of the GNU General Public License
23## along with Octave; see the file COPYING.  If not, see
24## <https://www.gnu.org/licenses/>.
25##
26########################################################################
27
28set -e
29
30SED=gsed
31EGREP=${EGREP:-egrep}
32
33# Some stupid egreps don't like empty elements in alternation patterns,
34# so we have to repeat ourselves because some stupid egreps don't like
35# empty elements in alternation patterns.
36
37DEFUN_PATTERN="^[ \t]*DEF(CONSTFUN|CONSTMETHOD|METHOD|METHOD_DLD|METHODX|METHODX_DLD|UN|UN_DLD|UNX|UNX_DLD)[ \t]*\\("
38
39srcdir="$1"
40if [ "$1" ]; then
41  shift
42fi
43
44for arg
45do
46  if [ -f "$arg" ]; then
47    file="$arg"
48  else
49    file="$srcdir/$arg"
50  fi
51  if [ -f "$file" ]; then
52    if [ "`$EGREP -l "$DEFUN_PATTERN" $file`" ]; then
53      echo "$file" | $SED "s,\\$srcdir/,,"
54    fi
55  fi
56done
57