* gdb.mi/mi-var-cmd.exp: Correct test name. Allow any value for
[deliverable/binutils-gdb.git] / gdb / copyright.sh
1 #!/bin/sh
2 # Automatically update copyright for GDB, the GNU debugger.
3 #
4 # Copyright (C) 2007 Free Software Foundation, Inc.
5 #
6 # This file is part of GDB.
7 #
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.
12 #
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.
17 #
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.
22
23 # Usage: cd src/gdb && sh ./copyright.sh
24 # To use a different version of emacs, set the EMACS environment
25 # variable before running.
26
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
32 # to be correct.
33
34 ####
35 # Configuration
36 ####
37
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)
43 # igen
44 # Autoconf input (dnl)
45 # texinfo (@c)
46 # tex (%)
47 # *.defs as C
48 # man
49 # So these need to be done by hand, as needed
50 byhand="
51 *.s
52 *.f
53 *.f90
54 *.igen
55 *.ac
56 *.texi
57 *.texinfo
58 *.tex
59 *.defs
60 *.1
61 "
62
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).
66 prunes="
67 COPYING
68 COPYING.LIB
69 CVS
70 configure
71 copying.c
72 gdbarch.c
73 gdbarch.h
74 fdl.texi
75 gpl.texi
76 gdbtk
77 gdb.gdbtk
78 osf-share
79 aclocal.m4
80 step-line.inp
81 step-line.c
82 "
83
84 ####
85 # Main program
86 ####
87
88 : ${EMACS:=emacs}
89
90 # Disable filename expansion, so that we can get at the glob patterns
91 # from $byhand.
92 set -f
93
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.0.XX snapshot." >&2
97 exit 1
98 fi
99
100 if test $# -lt 1; then
101 dir=.
102 else
103 dir=$1
104 fi
105
106 if ! test -f doc/gdbint.texinfo; then
107 echo "\"$dir\" is not a GDB source directory."
108 exit 1
109 fi
110
111 cat > copytmp.el <<EOF
112 (load "copyright")
113 (setq vc-cvs-stay-local nil
114 message-log-max t)
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")
118
119 (defun gdb-copyright-update (filename)
120 (widen)
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))
124 (progn
125 (setq copyright-update t
126 copyright-query nil
127 fill-column 78
128 start (copy-marker (match-beginning 0))
129 end (progn
130 (re-search-backward fsf-regexp)
131 (re-search-forward fsf-regexp
132 (+ (point) copyright-limit) t)
133 (point-marker))
134 fsf-start (copy-marker (match-beginning 0)))
135 (replace-match "Free_Software_Foundation,_Inc." t t)
136 (copyright-update)
137 (fill-region-as-paragraph start end)
138 (replace-string "_" " " nil fsf-start end))
139 (message (concat "WARNING: No copyright message found in " filename))))
140
141 EOF
142
143 for f in $prunes $byhand; do
144 prune_opts="$prune_opts -name $f -prune -o"
145 done
146
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")
154 (save-buffer)
155 (kill-buffer (buffer-name))
156 EOF
157 done
158
159 cat >> copytmp.el <<EOF
160 (delete-file "copytmp.el")
161 ;; Comment out the next line to examine the message buffer.
162 (kill-emacs)
163 EOF
164
165 exec $EMACS --no-site-file -q -l ./copytmp.el
This page took 0.038106 seconds and 4 git commands to generate.