#!/bin/sh
|
#!/bin/sh
|
# Automatically update copyright for GDB, the GNU debugger.
|
# Automatically update copyright for GDB, the GNU debugger.
|
#
|
#
|
# Copyright (C) 2007, 2008 Free Software Foundation, Inc.
|
# Copyright (C) 2007, 2008 Free Software Foundation, Inc.
|
#
|
#
|
# This file is part of GDB.
|
# This file is part of GDB.
|
#
|
#
|
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
# (at your option) any later version.
|
# (at your option) any later version.
|
#
|
#
|
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
#
|
#
|
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
# Usage: cd src/gdb && sh ./copyright.sh
|
# Usage: cd src/gdb && sh ./copyright.sh
|
# To use a different version of emacs, set the EMACS environment
|
# To use a different version of emacs, set the EMACS environment
|
# variable before running.
|
# variable before running.
|
|
|
# After running, update those files mentioned in $byhand by hand.
|
# After running, update those files mentioned in $byhand by hand.
|
# Always review the output of this script before committing it!
|
# Always review the output of this script before committing it!
|
# A useful command to review the output is:
|
# A useful command to review the output is:
|
# filterdiff -x \*.c -x \*.cc -x \*.h -x \*.exp updates.diff
|
# filterdiff -x \*.c -x \*.cc -x \*.h -x \*.exp updates.diff
|
# This removes the bulk of the changes which are most likely
|
# This removes the bulk of the changes which are most likely
|
# to be correct.
|
# to be correct.
|
|
|
####
|
####
|
# Configuration
|
# Configuration
|
####
|
####
|
|
|
# As of Emacs 22.0 (snapshot), wrapping and copyright updating do not
|
# As of Emacs 22.0 (snapshot), wrapping and copyright updating do not
|
# handle these file types - all reasonable:
|
# handle these file types - all reasonable:
|
# Assembly (weird comment characters, e.g. "!"); .S usually has C
|
# Assembly (weird comment characters, e.g. "!"); .S usually has C
|
# comments, which are fine)
|
# comments, which are fine)
|
# Fortran ("c" comment character)
|
# Fortran ("c" comment character)
|
# igen
|
# igen
|
# Autoconf input (dnl)
|
# Autoconf input (dnl)
|
# texinfo (@c)
|
# texinfo (@c)
|
# tex (%)
|
# tex (%)
|
# *.defs as C
|
# *.defs as C
|
# man
|
# man
|
# So these need to be done by hand, as needed
|
# So these need to be done by hand, as needed
|
byhand="
|
byhand="
|
*.s
|
*.s
|
*.f
|
*.f
|
*.f90
|
*.f90
|
*.igen
|
*.igen
|
*.ac
|
*.ac
|
*.texi
|
*.texi
|
*.texinfo
|
*.texinfo
|
*.tex
|
*.tex
|
*.defs
|
*.defs
|
*.1
|
*.1
|
"
|
"
|
|
|
# Files which should not be modified, either because they are
|
# Files which should not be modified, either because they are
|
# generated, non-FSF, or otherwise special (e.g. license text,
|
# generated, non-FSF, or otherwise special (e.g. license text,
|
# or test cases which must be sensitive to line numbering).
|
# or test cases which must be sensitive to line numbering).
|
prunes="
|
prunes="
|
COPYING
|
COPYING
|
COPYING.LIB
|
COPYING.LIB
|
CVS
|
CVS
|
configure
|
configure
|
copying.c
|
copying.c
|
gdbarch.c
|
gdbarch.c
|
gdbarch.h
|
gdbarch.h
|
fdl.texi
|
fdl.texi
|
gpl.texi
|
gpl.texi
|
gdbtk
|
gdbtk
|
gdb.gdbtk
|
gdb.gdbtk
|
osf-share
|
osf-share
|
aclocal.m4
|
aclocal.m4
|
step-line.inp
|
step-line.inp
|
step-line.c
|
step-line.c
|
"
|
"
|
|
|
####
|
####
|
# Main program
|
# Main program
|
####
|
####
|
|
|
: ${EMACS:=emacs}
|
: ${EMACS:=emacs}
|
|
|
# Disable filename expansion, so that we can get at the glob patterns
|
# Disable filename expansion, so that we can get at the glob patterns
|
# from $byhand.
|
# from $byhand.
|
set -f
|
set -f
|
|
|
version=`$EMACS --version | sed 's/GNU Emacs \([0-9]*\)\..*/\1/; 1q'`
|
version=`$EMACS --version | sed 's/GNU Emacs \([0-9]*\)\..*/\1/; 1q'`
|
if test "$version" -lt 22; then
|
if test "$version" -lt 22; then
|
echo "error: $EMACS is too old; use at least an Emacs 22.0.XX snapshot." >&2
|
echo "error: $EMACS is too old; use at least an Emacs 22.0.XX snapshot." >&2
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
if test $# -lt 1; then
|
if test $# -lt 1; then
|
dir=.
|
dir=.
|
else
|
else
|
dir=$1
|
dir=$1
|
fi
|
fi
|
|
|
if ! test -f doc/gdbint.texinfo; then
|
if ! test -f doc/gdbint.texinfo; then
|
echo "\"$dir\" is not a GDB source directory."
|
echo "\"$dir\" is not a GDB source directory."
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
cat > copytmp.el <<EOF
|
cat > copytmp.el <<EOF
|
(load "copyright")
|
(load "copyright")
|
(setq vc-cvs-stay-local nil
|
(setq vc-cvs-stay-local nil
|
message-log-max t)
|
message-log-max t)
|
(setq fsf-regexp "Free[#; \t\n]+Software[#; \t\n]+Foundation,[#; \t\n]+Inc\."
|
(setq fsf-regexp "Free[#; \t\n]+Software[#; \t\n]+Foundation,[#; \t\n]+Inc\."
|
fsf-copyright-regexp (concat copyright-regexp "[#; \t\n]+" fsf-regexp)
|
fsf-copyright-regexp (concat copyright-regexp "[#; \t\n]+" fsf-regexp)
|
generated-regexp "THIS FILE IS MACHINE GENERATED WITH CGEN")
|
generated-regexp "THIS FILE IS MACHINE GENERATED WITH CGEN")
|
|
|
(defun gdb-copyright-update (filename)
|
(defun gdb-copyright-update (filename)
|
(widen)
|
(widen)
|
(goto-char (point-min))
|
(goto-char (point-min))
|
(if (and (not (re-search-forward generated-regexp (+ (point) copyright-limit) t))
|
(if (and (not (re-search-forward generated-regexp (+ (point) copyright-limit) t))
|
(re-search-forward fsf-copyright-regexp (+ (point) copyright-limit) t))
|
(re-search-forward fsf-copyright-regexp (+ (point) copyright-limit) t))
|
(progn
|
(progn
|
(setq copyright-update t
|
(setq copyright-update t
|
copyright-query nil
|
copyright-query nil
|
fill-column 78
|
fill-column 78
|
start (copy-marker (match-beginning 0))
|
start (copy-marker (match-beginning 0))
|
end (progn
|
end (progn
|
(re-search-backward fsf-regexp)
|
(re-search-backward fsf-regexp)
|
(re-search-forward fsf-regexp
|
(re-search-forward fsf-regexp
|
(+ (point) copyright-limit) t)
|
(+ (point) copyright-limit) t)
|
(point-marker))
|
(point-marker))
|
fsf-start (copy-marker (match-beginning 0)))
|
fsf-start (copy-marker (match-beginning 0)))
|
(replace-match "Free_Software_Foundation,_Inc." t t)
|
(replace-match "Free_Software_Foundation,_Inc." t t)
|
(copyright-update)
|
(copyright-update)
|
(fill-region-as-paragraph start end)
|
(fill-region-as-paragraph start end)
|
(replace-string "_" " " nil fsf-start end))
|
(replace-string "_" " " nil fsf-start end))
|
(message (concat "WARNING: No copyright message found in " filename))))
|
(message (concat "WARNING: No copyright message found in " filename))))
|
|
|
EOF
|
EOF
|
|
|
for f in $prunes $byhand; do
|
for f in $prunes $byhand; do
|
prune_opts="$prune_opts -name $f -prune -o"
|
prune_opts="$prune_opts -name $f -prune -o"
|
done
|
done
|
|
|
for f in $(find "$dir" "$dir/../include/gdb" "$dir/../sim" \
|
for f in $(find "$dir" "$dir/../include/gdb" "$dir/../sim" \
|
$prune_opts -type f -print); do
|
$prune_opts -type f -print); do
|
cat >> copytmp.el <<EOF
|
cat >> copytmp.el <<EOF
|
(switch-to-buffer (find-file "$f"))
|
(switch-to-buffer (find-file "$f"))
|
(setq backup-inhibited t)
|
(setq backup-inhibited t)
|
(setq write-file-hooks '())
|
(setq write-file-hooks '())
|
(gdb-copyright-update "$f")
|
(gdb-copyright-update "$f")
|
(save-buffer)
|
(save-buffer)
|
(kill-buffer (buffer-name))
|
(kill-buffer (buffer-name))
|
EOF
|
EOF
|
done
|
done
|
|
|
cat >> copytmp.el <<EOF
|
cat >> copytmp.el <<EOF
|
(delete-file "copytmp.el")
|
(delete-file "copytmp.el")
|
;; Comment out the next line to examine the message buffer.
|
;; Comment out the next line to examine the message buffer.
|
(kill-emacs)
|
(kill-emacs)
|
EOF
|
EOF
|
|
|
exec $EMACS --no-site-file -q -l ./copytmp.el
|
exec $EMACS --no-site-file -q -l ./copytmp.el
|
|
|