2 # Automatically update copyright for GDB, the GNU debugger.
4 # Copyright (C) 2007 Free Software Foundation, Inc.
6 # This file is part of GDB.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 # Boston, MA 02110-1301, USA.
23 # Usage: cd src/gdb && sh ./copyright.sh
24 # To use a different version of emacs, set the EMACS environment
25 # variable before running.
27 # After running, update those files mentioned in $byhand by hand.
28 # Always review the output of this script before committing it!
29 # A useful command to review the output is:
30 # filterdiff -x \*.c -x \*.cc -x \*.h -x \*.exp updates.diff
31 # This removes the bulk of the changes which are most likely
38 # As of Emacs 22.0 (snapshot), wrapping and copyright updating do not
39 # handle these file types - all reasonable:
40 # Assembly (weird comment characters, e.g. "!"); .S usually has C
41 # comments, which are fine)
42 # Fortran ("c" comment character)
44 # Autoconf input (dnl)
49 # So these need to be done by hand, as needed
63 # Files which should not be modified, either because they are
64 # generated, non-FSF, or otherwise special (e.g. license text,
65 # or test cases which must be sensitive to line numbering).
90 # Disable filename expansion, so that we can get at the glob patterns
94 version=`$EMACS --version | sed 's/GNU Emacs \([0-9]*\)\..*/\1/; 1q'`
95 if test "$version" -lt 22; then
96 echo "error: $EMACS is too old; use at least an Emacs 22 snapshot." >&2
100 if test $# -lt 1; then
106 if ! test -f doc/gdbint.texinfo; then
107 echo "\"$dir\" is not a GDB source directory."
111 cat > copytmp.el <<EOF
113 (setq vc-cvs-stay-local nil
115 (setq fsf-regexp "Free[#; \t\n]+Software[#; \t\n]+Foundation,[#; \t\n]+Inc\."
116 fsf-copyright-regexp (concat copyright-regexp "[#; \t\n]+" fsf-regexp)
117 generated-regexp "THIS FILE IS MACHINE GENERATED WITH CGEN")
119 (defun gdb-copyright-update (filename)
121 (goto-char (point-min))
122 (if (and (not (re-search-forward generated-regexp (+ (point) copyright-limit) t))
123 (re-search-forward fsf-copyright-regexp (+ (point) copyright-limit) t))
125 (setq copyright-update t
128 start (copy-marker (match-beginning 0))
130 (re-search-backward fsf-regexp)
131 (re-search-forward fsf-regexp
132 (+ (point) copyright-limit) t)
134 fsf-start (copy-marker (match-beginning 0)))
135 (replace-match "Free_Software_Foundation,_Inc." t t)
137 (fill-region-as-paragraph start end)
138 (replace-string "_" " " nil fsf-start end))
139 (message (concat "WARNING: No copyright message found in " filename))))
143 for f in $prunes $byhand; do
144 prune_opts="$prune_opts -name $f -prune -o"
147 for f in $(find "$dir" "$dir/../include/gdb" "$dir/../sim" \
148 $prune_opts -type f -print); do
149 cat >> copytmp.el <<EOF
150 (switch-to-buffer (find-file "$f"))
151 (setq backup-inhibited t)
152 (setq write-file-hooks '())
153 (gdb-copyright-update "$f")
155 (kill-buffer (buffer-name))
159 cat >> copytmp.el <<EOF
160 (delete-file "copytmp.el")
161 ;; Comment out the next line to examine the message buffer.
165 exec $EMACS --no-site-file -q -l ./copytmp.el