Debian Codegraph @

gnulib-tests/test-update-copyright.sh

raw
1 #!/bin/sh
2 # Test suite for update-copyright.
3 # Copyright (C) 2009-2025 Free Software Foundation, Inc.
4 # This file is part of the GNUlib Library.
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19 . "${srcdir=.}/init.sh"; path_prepend_ .
20
21 # Ensure the update-copyright program gets found.
22 PATH=$abs_aux_dir:$PATH
23 export PATH
24
25 TMP_BASE=update-copyright.test
26 trap 'rm -f $TMP_BASE*' EXIT HUP INT QUIT TERM
27
28 ## --------------------------------- ##
29 ## Skip if user does not have perl. ##
30 ## --------------------------------- ##
31
32 TMP=$TMP_BASE
33 s=$TMP-script
34 cat <<\EOF > $s
35 #!/bin/sh
36 #! -*-perl-*-
37 # This is a prologue that allows to run a perl script as an executable
38 # on systems that are compliant to a POSIX version before POSIX:2017.
39 # On such systems, the usual invocation of an executable through execlp()
40 # or execvp() fails with ENOEXEC if it is a script that does not start
41 # with a #! line. The script interpreter mentioned in the #! line has
42 # to be /bin/sh, because on GuixSD systems that is the only program that
43 # has a fixed file name. The second line is essential for perl and is
44 # also useful for editing this file in Emacs. The next two lines below
45 # are valid code in both sh and perl. When executed by sh, they re-execute
46 # the script through the perl program found in $PATH. The '-x' option
47 # is essential as well; without it, perl would re-execute the script
48 # through /bin/sh. When executed by perl, the next two lines are a no-op.
49 eval 'exec perl -wSx -pi "$0" "$@"'
50 if 0;
51
52 s/a/b/
53 EOF
54 chmod a+x $s
55 echo a > $TMP-in
56 ./$s $TMP-in 2>/dev/null && test b = "`cat $TMP-in 2>/dev/null`" ||
57 {
58 printf '%s\n' "$0: skipping this test;" \
59 'your system has insufficient support for Perl' 1>&2
60 exit 77
61 }
62
63 # Skip this test if Perl is too old. FIXME: 5.8.0 is just a guess.
64 # We have a report that 5.6.1 is inadequate and that 5.8.0 works.
65 perl -e 'require 5.8.0' || {
66 echo "$0: skipping this test; Perl version is too old" 1>&2
67 exit 77
68 }
69
70 # Do not let a different envvar setting perturb results.
71 UPDATE_COPYRIGHT_MAX_LINE_LENGTH=72
72 export UPDATE_COPYRIGHT_MAX_LINE_LENGTH
73
74 # This assignment to 'ight' is so that data can contain strings
75 # like "Copy$ight 2024 Free Software Foundation, Inc." without being
76 # mistakenly updated by "cd .. && make update-copyright".
77 ight=right
78
79 ## ----------------------------- ##
80 ## Examples from documentation. ##
81 ## ----------------------------- ##
82
83 TMP=$TMP_BASE-ex
84 cat > $TMP-1 <<EOF
85 Copy$ight @copy$ight{} 1990-2005, 2007-2009 Free Software
86 Foundation, Inc.
87 EOF
88 cat > $TMP-2 <<EOF
89 # Copy$ight (C) 1990-2005, 2007-2009 Free Software
90 # Foundation, Inc.
91 EOF
92 cat > $TMP-3 <<EOF
93 /*
94 * Copy$ight &copy; 90,2005,2007-2009
95 * Free Software Foundation, Inc.
96 */
97 EOF
98 cat > $TMP-4 <<EOF
99 ## Copy$ight (C) 1990-2005, 2007-2009 Free Software
100 # Foundation, Inc.
101 EOF
102 cat > $TMP-5 <<EOF
103 Copy$ight (C) 1990-2005, 2007-2009 Acme, Inc.
104 EOF
105 cat > $TMP-6 <<EOF
106 ## Copy$ight (C) 1990-2005, 2007-2009 Free Software
107 # Foundation, Inc.
108
109 Copy$ight (C) 1990-2005, 2007-2009 Free Software Foundation,
110 Inc.
111 EOF
112 cat > $TMP-7 <<EOF
113 Copy$ight (C) 1990-2005, 2007-2009 Acme, Inc.
114
115 # Copy$ight (C) 1990-2005, 2007-2009 Free Software
116 # Foundation, Inc.
117 EOF
118 cat > $TMP-8 <<EOF
119 Copy$ight (C) 2008 Free Software Foundation, Inc.
120 Copy$ight (C) 2008 Free Software Foundation, Inc.
121 EOF
122 cat > $TMP-9 <<EOF
123 # Copy$ight (C) 2008 Free Software Foundation, Inc.
124
125 Copy$ight (C) 2007 Free Software Foundation, Inc.
126
127 Copy$ight (C) 2008 Free Software Foundation, Inc.
128 EOF
129
130 UPDATE_COPYRIGHT_YEAR=2009 \
131 update-copyright $TMP-? 1> $TMP-stdout 2> $TMP-stderr
132 compare /dev/null $TMP-stdout || exit 1
133 compare - $TMP-stderr <<EOF || exit 1
134 $TMP-4: warning: copyright statement not found
135 $TMP-5: warning: copyright statement not found
136 EOF
137 compare - $TMP-1 <<EOF || exit 1
138 Copy$ight @copy$ight{} 1990-2005, 2007-2009 Free Software
139 Foundation, Inc.
140 EOF
141 compare - $TMP-2 <<EOF || exit 1
142 # Copy$ight (C) 1990-2005, 2007-2009 Free Software
143 # Foundation, Inc.
144 EOF
145 compare - $TMP-3 <<EOF || exit 1
146 /*
147 * Copy$ight &copy; 90,2005,2007-2009
148 * Free Software Foundation, Inc.
149 */
150 EOF
151 compare - $TMP-4 <<EOF || exit 1
152 ## Copy$ight (C) 1990-2005, 2007-2009 Free Software
153 # Foundation, Inc.
154 EOF
155 compare - $TMP-5 <<EOF || exit 1
156 Copy$ight (C) 1990-2005, 2007-2009 Acme, Inc.
157 EOF
158 compare - $TMP-6 <<EOF || exit 1
159 ## Copy$ight (C) 1990-2005, 2007-2009 Free Software
160 # Foundation, Inc.
161
162 Copy$ight (C) 1990-2005, 2007-2009 Free Software Foundation,
163 Inc.
164 EOF
165 compare - $TMP-7 <<EOF || exit 1
166 Copy$ight (C) 1990-2005, 2007-2009 Acme, Inc.
167
168 # Copy$ight (C) 1990-2005, 2007-2009 Free Software
169 # Foundation, Inc.
170 EOF
171 compare - $TMP-8 <<EOF || exit 1
172 Copy$ight (C) 2008, 2009 Free Software Foundation, Inc.
173 Copy$ight (C) 2008, 2009 Free Software Foundation, Inc.
174 EOF
175
176 # Note that expecting "2007, 2009" on the third copyright line below
177 # looks wrong since the corresponding copyright year was "2008".
178 # However, the premise of this test (having inconsistent copyright dates
179 # with the same holder) is not worth handling. What happens is that the
180 # xform for the preceding line matches any list of year numbers with the
181 # same prefix and holder.
182 compare - $TMP-9 <<EOF || exit 1
183 # Copy$ight (C) 2008, 2009 Free Software Foundation, Inc.
184
185 Copy$ight (C) 2007, 2009 Free Software Foundation, Inc.
186
187 Copy$ight (C) 2007, 2009 Free Software Foundation, Inc.
188 EOF
189
190 UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
191 update-copyright $TMP-? 1> $TMP-stdout 2> $TMP-stderr
192 compare /dev/null $TMP-stdout || exit 1
193 compare - $TMP-stderr <<EOF || exit 1
194 $TMP-4: warning: copyright statement not found
195 $TMP-5: warning: copyright statement not found
196 EOF
197 compare - $TMP-1 <<EOF || exit 1
198 Copy$ight @copy$ight{} 1990-2005, 2007-2010 Free Software Foundation,
199 Inc.
200 EOF
201 compare - $TMP-2 <<EOF || exit 1
202 # Copy$ight (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
203 EOF
204 compare - $TMP-3 <<EOF || exit 1
205 /*
206 * Copy$ight &copy; 1990, 2005, 2007-2010 Free Software Foundation, Inc.
207 */
208 EOF
209 compare - $TMP-4 <<EOF || exit 1
210 ## Copy$ight (C) 1990-2005, 2007-2009 Free Software
211 # Foundation, Inc.
212 EOF
213 compare - $TMP-5 <<EOF || exit 1
214 Copy$ight (C) 1990-2005, 2007-2009 Acme, Inc.
215 EOF
216 compare - $TMP-6 <<EOF || exit 1
217 ## Copy$ight (C) 1990-2005, 2007-2009 Free Software
218 # Foundation, Inc.
219
220 Copy$ight (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
221 EOF
222 compare - $TMP-7 <<EOF || exit 1
223 Copy$ight (C) 1990-2005, 2007-2009 Acme, Inc.
224
225 # Copy$ight (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
226 EOF
227
228 UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_FORCE=1 \
229 update-copyright $TMP-? 1> $TMP-stdout 2> $TMP-stderr
230 compare /dev/null $TMP-stdout || exit 1
231 compare - $TMP-stderr <<EOF || exit 1
232 $TMP-4: warning: copyright statement not found
233 $TMP-5: warning: copyright statement not found
234 EOF
235 compare - $TMP-1 <<EOF || exit 1
236 Copy$ight @copy$ight{} 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
237 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
238 Free Software Foundation, Inc.
239 EOF
240 compare - $TMP-2 <<EOF || exit 1
241 # Copy$ight (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
242 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
243 # Software Foundation, Inc.
244 EOF
245 compare - $TMP-3 <<EOF || exit 1
246 /*
247 * Copy$ight &copy; 1990, 2005, 2007, 2008, 2009, 2010 Free Software
248 * Foundation, Inc.
249 */
250 EOF
251 compare - $TMP-4 <<EOF || exit 1
252 ## Copy$ight (C) 1990-2005, 2007-2009 Free Software
253 # Foundation, Inc.
254 EOF
255 compare - $TMP-5 <<EOF || exit 1
256 Copy$ight (C) 1990-2005, 2007-2009 Acme, Inc.
257 EOF
258 compare - $TMP-6 <<EOF || exit 1
259 ## Copy$ight (C) 1990-2005, 2007-2009 Free Software
260 # Foundation, Inc.
261
262 Copy$ight (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
263 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
264 Software Foundation, Inc.
265 EOF
266 compare - $TMP-7 <<EOF || exit 1
267 Copy$ight (C) 1990-2005, 2007-2009 Acme, Inc.
268
269 # Copy$ight (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
270 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
271 # Software Foundation, Inc.
272 EOF
273
274 rm $TMP*
275
276 ## ------------------------ ##
277 ## Examples from man pages ##
278 ## ------------------------ ##
279
280 TMP=$TMP_BASE-man
281 cat > $TMP.1 <<EOF
282 '\" Copy$ight (C) 1998-2009 Free Software Foundation, Inc.
283 EOF
284 cat > $TMP.2 <<EOF
285 Copy$ight \(co 1998-2009 Free Software Foundation, Inc.
286 EOF
287 cat > $TMP.3 <<EOF
288 Copy$ight \(co 1998\(en2009 Free Software Foundation, Inc.
289 EOF
290 cat > $TMP.4 <<EOF
291 Copy$ight \(co 2009 Free Software Foundation, Inc.
292 EOF
293
294 UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
295 update-copyright $TMP.? 1> $TMP-stdout 2> $TMP-stderr
296 compare /dev/null $TMP-stdout || exit 1
297 compare /dev/null $TMP-stderr || exit 1
298 compare - $TMP.1 <<EOF || exit 1
299 '\" Copy$ight (C) 1998\(en2010 Free Software Foundation, Inc.
300 EOF
301 compare - $TMP.2 <<EOF || exit 1
302 Copy$ight \(co 1998\(en2010 Free Software Foundation, Inc.
303 EOF
304 compare - $TMP.3 <<EOF || exit 1
305 Copy$ight \(co 1998\(en2010 Free Software Foundation, Inc.
306 EOF
307 compare - $TMP.4 <<EOF || exit 1
308 Copy$ight \(co 2009\(en2010 Free Software Foundation, Inc.
309 EOF
310
311 rm $TMP*
312
313 ## -------------- ##
314 ## Current year. ##
315 ## -------------- ##
316
317 TMP=$TMP_BASE-current-year
318 YEAR=`date +%Y`
319 cat > $TMP <<EOF
320 '\" Copy$ight (C) 2006
321 '\" Free Software Foundation,
322 '\" Inc.
323 EOF
324 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
325 compare /dev/null $TMP-stdout || exit 1
326 compare /dev/null $TMP-stderr || exit 1
327 compare - $TMP <<EOF || exit 1
328 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
329 EOF
330 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
331 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
332 compare /dev/null $TMP-stdout || exit 1
333 compare /dev/null $TMP-stderr || exit 1
334 compare - $TMP <<EOF || exit 1
335 '\" Copy$ight (C) 2006, $YEAR Free Software Foundation, Inc.
336 EOF
337 rm $TMP*
338
339 ## ------------------ ##
340 ## Surrounding text. ##
341 ## ------------------ ##
342
343 TMP=$TMP_BASE-surrounding-text
344 cat > $TMP <<EOF
345 Undisturbed text.
346 dnl Undisturbed text.
347 dnl Copy$ight (C) 89
348 dnl Free Software Foundation, Inc.
349 dnl Undisturbed text.
350 EOF
351 UPDATE_COPYRIGHT_YEAR=2010 \
352 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
353 compare /dev/null $TMP-stdout || exit 1
354 compare /dev/null $TMP-stderr || exit 1
355 compare - $TMP <<EOF || exit 1
356 Undisturbed text.
357 dnl Undisturbed text.
358 dnl Copy$ight (C) 1989, 2010 Free Software Foundation, Inc.
359 dnl Undisturbed text.
360 EOF
361 rm $TMP*
362
363 ## --------------- ##
364 ## Widest prefix. ##
365 ## --------------- ##
366
367 TMP=$TMP_BASE-widest-prefix
368 cat > $TMP <<EOF
369 #### Copy$ight (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
370 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
371 #### 2008 Free Software Foundation, Inc.
372 EOF
373 UPDATE_COPYRIGHT_YEAR=2010 \
374 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
375 compare /dev/null $TMP-stdout || exit 1
376 compare /dev/null $TMP-stderr || exit 1
377 compare - $TMP <<EOF || exit 1
378 #### Copy$ight (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
379 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
380 #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
381 EOF
382 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
383 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
384 compare /dev/null $TMP-stdout || exit 1
385 compare /dev/null $TMP-stderr || exit 1
386 compare - $TMP <<EOF || exit 1
387 #### Copy$ight (C) 1976-1988, 1999-2008, 2010-2011 Free Software
388 #### Foundation, Inc.
389 EOF
390 rm $TMP*
391
392 ## ------------------- ##
393 ## Prefix too large. ##
394 ## ------------------- ##
395
396 TMP=$TMP_BASE-prefix-too-large
397 cat > $TMP <<EOF
398 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
399 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
400 #### 2008 Free Software Foundation, Inc.
401 EOF
402 UPDATE_COPYRIGHT_YEAR=2010 \
403 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
404 compare /dev/null $TMP-stdout || exit 1
405 compare - $TMP-stderr <<EOF || exit 1
406 $TMP: warning: copyright statement not found
407 EOF
408 compare - $TMP <<EOF || exit 1
409 #### Copy$ight (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
410 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
411 #### 2008 Free Software Foundation, Inc.
412 EOF
413 rm $TMP*
414
415 ## ------------- ##
416 ## Blank lines. ##
417 ## ------------- ##
418
419 TMP=$TMP_BASE-blank-lines
420 cat > $TMP <<EOF
421 #Copy$ight (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
422 #
423 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
424 #2008 Free Software Foundation, Inc.
425
426 Copy$ight (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
427
428 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
429 2008 Free Software Foundation, Inc.
430 EOF
431 UPDATE_COPYRIGHT_YEAR=2010 \
432 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
433 compare /dev/null $TMP-stdout || exit 1
434 compare - $TMP-stderr <<EOF || exit 1
435 $TMP: warning: copyright statement not found
436 EOF
437 compare - $TMP <<EOF || exit 1
438 #Copy$ight (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
439 #
440 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
441 #2008 Free Software Foundation, Inc.
442
443 Copy$ight (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
444
445 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
446 2008 Free Software Foundation, Inc.
447 EOF
448 rm $TMP*
449
450 ## -------------- ##
451 ## Leading tabs. ##
452 ## -------------- ##
453
454 TMP=$TMP_BASE-leading-tabs
455 cat > $TMP <<EOF
456 Copy$ight (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
457 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
458 Software Foundation, Inc.
459 EOF
460 UPDATE_COPYRIGHT_YEAR=2010 \
461 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
462 compare /dev/null $TMP-stdout || exit 1
463 compare /dev/null $TMP-stderr || exit 1
464 compare - $TMP <<EOF || exit 1
465 Copy$ight (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996,
466 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
467 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
468 EOF
469 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
470 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
471 compare /dev/null $TMP-stdout || exit 1
472 compare /dev/null $TMP-stderr || exit 1
473 compare - $TMP <<EOF || exit 1
474 Copy$ight (C) 1987-1988, 1991-2011 Free Software Foundation,
475 Inc.
476 EOF
477 rm $TMP*
478
479 ## -------------------- ##
480 ## Unusual whitespace. ##
481 ## -------------------- ##
482
483 TMP=$TMP_BASE-unusual-ws
484 cat > $TMP <<EOF
485 # Copy$ight (C) 87-88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
486 # 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
487 # 2009 Free Software Foundation, Inc.
488 EOF
489 UPDATE_COPYRIGHT_YEAR=2010 \
490 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
491 compare /dev/null $TMP-stdout || exit 1
492 compare /dev/null $TMP-stderr || exit 1
493 compare - $TMP <<EOF || exit 1
494 # Copy$ight (C) 1987, 1988, 1991, 1992, 1993, 1994,
495 # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
496 # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
497 # Foundation, Inc.
498 EOF
499 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
500 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
501 compare /dev/null $TMP-stdout || exit 1
502 compare /dev/null $TMP-stderr || exit 1
503 compare - $TMP <<EOF || exit 1
504 # Copy$ight (C) 1987-1988, 1991-2011 Free Software
505 # Foundation, Inc.
506 EOF
507 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=2 \
508 UPDATE_COPYRIGHT_FORCE=1 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
509 compare /dev/null $TMP-stdout || exit 1
510 compare /dev/null $TMP-stderr || exit 1
511 compare - $TMP <<EOF || exit 1
512 # Copy$ight (C) 1987-2011 Free Software Foundation, Inc.
513 EOF
514 rm $TMP*
515
516 ## --------- ##
517 ## DOS EOL. ##
518 ## --------- ##
519
520 TMP=$TMP_BASE-dos-eol
521 tr @ '\015' > $TMP <<EOF
522 Rem Copy$ight (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
523 Rem 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
524 Rem 2009 Free Software Foundation, Inc.@
525 EOF
526 UPDATE_COPYRIGHT_YEAR=2010 \
527 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
528 compare /dev/null $TMP-stdout || exit 1
529 compare /dev/null $TMP-stderr || exit 1
530 tr @ '\015' > $TMP-exp <<EOF
531 Rem Copy$ight (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
532 Rem 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
533 Rem 2009, 2010 Free Software Foundation, Inc.@
534 EOF
535 compare $TMP-exp $TMP || exit 1
536 rm $TMP*
537
538 ## --------------- ##
539 ## Omitted "(C)". ##
540 ## --------------- ##
541
542 TMP=$TMP_BASE-omitted-circle-c
543 cat > $TMP <<EOF
544 Copy$ight 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
545 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
546 2009 Free Software Foundation, Inc.
547 EOF
548 UPDATE_COPYRIGHT_YEAR=2010 \
549 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
550 compare /dev/null $TMP-stdout || exit 1
551 compare /dev/null $TMP-stderr || exit 1
552 compare - $TMP <<EOF || exit 1
553 Copy$ight 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
554 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
555 Free Software Foundation, Inc.
556 EOF
557 rm $TMP*
558
559 ## ------------------ ##
560 ## C-style comments. ##
561 ## ------------------ ##
562
563 TMP=$TMP_BASE-c-style-comments
564 cat > $TMP.star <<EOF
565 /* Copy$ight 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
566 * 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
567 * 2009 Free Software Foundation, Inc. */
568 EOF
569 cat > $TMP.space <<EOF
570 /*Copy$ight 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
571 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
572 2009 Free Software Foundation, Inc. */
573 EOF
574 cat > $TMP.single-line <<EOF
575 /* Copy$ight 87, 1991, 1992 Free Software Foundation, Inc. */
576 EOF
577 cat > $TMP.single-line-wrapped <<EOF
578 /* Copy$ight 1988, 1991, 1992, 1993 Free Software Foundation, Inc. */
579 EOF
580 cat > $TMP.extra-text-star <<EOF
581 /* Copy$ight 1987, 1988, 1991, 1992 Free Software Foundation, Inc. End
582 * More comments. */
583 EOF
584 cat > $TMP.extra-text-space <<EOF
585 /* Copy$ight 1987, 1988, 1991, 1992 Free Software Foundation, Inc. ***
586 * End of comments. */
587 EOF
588 cat > $TMP.two-digit-final-is-substr-of-first <<EOF
589 /* Copy$ight 1991, 99 Free Software Foundation, Inc. */
590 EOF
591 UPDATE_COPYRIGHT_YEAR=2010 \
592 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
593 compare /dev/null $TMP-stdout || exit 1
594 compare /dev/null $TMP-stderr || exit 1
595 compare - $TMP.star <<EOF || exit 1
596 /* Copy$ight 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
597 * 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
598 * 2009, 2010 Free Software Foundation, Inc. */
599 EOF
600 compare - $TMP.space <<EOF || exit 1
601 /*Copy$ight 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
602 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
603 2009, 2010 Free Software Foundation, Inc. */
604 EOF
605 compare - $TMP.single-line <<EOF || exit 1
606 /* Copy$ight 1987, 1991, 1992, 2010 Free Software Foundation, Inc. */
607 EOF
608 compare - $TMP.single-line-wrapped <<EOF || exit 1
609 /* Copy$ight 1988, 1991, 1992, 1993, 2010 Free Software Foundation,
610 * Inc. */
611 EOF
612 compare - $TMP.extra-text-star <<EOF || exit 1
613 /* Copy$ight 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
614 * Inc. End
615 * More comments. */
616 EOF
617 compare - $TMP.extra-text-space <<EOF || exit 1
618 /* Copy$ight 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
619 Inc. ***
620 * End of comments. */
621 EOF
622 compare - $TMP.two-digit-final-is-substr-of-first <<EOF || exit 1
623 /* Copy$ight 1991, 1999, 2010 Free Software Foundation, Inc. */
624 EOF
625 rm $TMP*
626
627 exit 0