Mercurial > emacs
annotate lib-src/rcs2log @ 3248:9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
as RCS/*. Don't report an error if RCS is empty or nonexistent.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 29 May 1993 06:22:48 +0000 |
parents | 0e6a6d065a94 |
children | 65ef94a9e2c4 |
rev | line source |
---|---|
527 | 1 #!/bin/sh |
2 | |
3 # RCS to ChangeLog generator | |
4 | |
5 # Generate a change log prefix from RCS/* and the existing ChangeLog (if any). | |
6 # Output the new prefix to standard output. | |
7 # You can edit this prefix by hand, and then prepend it to ChangeLog. | |
8 | |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
9 # Ignore log entries that start with `#'. |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
10 # Clump together log entries that start with `{topic} ', |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
11 # where `topic' contains neither white space nor `}'. |
527 | 12 |
1800
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
13 # Author: Paul Eggert <eggert@twinsun.com> |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
14 |
3248
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
15 # $Id: rcs2log,v 1.11 1993/05/03 17:55:22 eggert Exp rms $ |
1800
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
16 |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
17 # Copyright 1992, 1993 Free Software Foundation, Inc. |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
18 |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
19 # This program is free software; you can redistribute it and/or modify |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
20 # it under the terms of the GNU General Public License as published by |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
21 # the Free Software Foundation; either version 2, or (at your option) |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
22 # any later version. |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
23 # |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
24 # This program is distributed in the hope that it will be useful, |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
27 # GNU General Public License for more details. |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
28 # |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
29 # You should have received a copy of the GNU General Public License |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
30 # along with this program; see the file COPYING. If not, write to |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
31 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
32 |
3248
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
33 nl=' |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
34 ' |
1800
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
35 |
534 | 36 # Parse options. |
37 | |
38 # defaults | |
39 indent=8 # indent of log line | |
40 length=79 # suggested max width of log line | |
41 tabwidth=8 # width of horizontal tab | |
42 | |
43 while : | |
44 do | |
45 case $1 in | |
46 -i) indent=${2?};; | |
47 -l) length=${2?};; | |
48 -t) tabwidth=${2?};; | |
49 -*) echo >&2 "$0: usage: $0 [-i indent] [-l length] [-t tabwidth] [file ...]" | |
50 exit 1;; | |
51 *) break | |
52 esac | |
53 shift; shift | |
54 done | |
55 | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
56 month_data=' |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
57 m[0]="Jan"; m[1]="Feb"; m[2]="Mar" |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
58 m[3]="Apr"; m[4]="May"; m[5]="Jun" |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
59 m[6]="Jul"; m[7]="Aug"; m[8]="Sep" |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
60 m[9]="Oct"; m[10]="Nov"; m[11]="Dec" |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
61 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
62 # days in non-leap year thus far, indexed by month (0-12) |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
63 mo[0]=0; mo[1]=31; mo[2]=59; mo[3]=90 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
64 mo[4]=120; mo[5]=151; mo[6]=181; mo[7]=212 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
65 mo[8]=243; mo[9]=273; mo[10]=304; mo[11]=334 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
66 mo[12]=365 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
67 ' |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
68 |
534 | 69 |
527 | 70 # Log into $rlogout the revisions checked in since the first ChangeLog entry. |
71 | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
72 date=1970 |
527 | 73 if test -s ChangeLog |
74 then | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
75 # Add 1 to seconds to avoid duplicating most recent log. |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
76 e=' |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
77 /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{ |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
78 '"$month_data"' |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
79 year = $5 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
80 for (i=0; i<=11; i++) if (m[i] == $2) break |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
81 dd = $3 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
82 hh = substr($0,12,2) |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
83 mm = substr($0,15,2) |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
84 ss = substr($0,18,2) |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
85 ss++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
86 if (ss == 60) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
87 ss = 0 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
88 mm++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
89 if (mm == 60) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
90 mm = 0 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
91 hh++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
92 if (hh == 24) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
93 hh = 0 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
94 dd++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
95 monthdays = mo[i+1] - mo[i] |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
96 if (i == 1 && year%4 == 0 && (year%100 != 0 || year%400 == 0)) monthdays++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
97 if (dd == monthdays + 1) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
98 dd = 1 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
99 i++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
100 if (i == 12) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
101 i = 0 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
102 year++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
103 } |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
104 } |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
105 } |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
106 } |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
107 } |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
108 printf "%d/%02d/%02d %02d:%02d:%02d\n", year, i+1, dd, hh, mm, ss |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
109 exit |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
110 } |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
111 ' |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
112 d=`awk "$e" <ChangeLog` || exit |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
113 case $d in |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
114 ?*) date=$d |
535
4b75abb93479
Don't munge $* when getting date from ChangeLog.
Paul Eggert <eggert@twinsun.com>
parents:
534
diff
changeset
|
115 esac |
527 | 116 fi |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
117 datearg="-d>$date" |
527 | 118 |
3248
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
119 # With no arguments, examine all files under the RCS directory. |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
120 case $# in |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
121 0) |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
122 files= |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
123 for file in RCS/.* RCS/* |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
124 do |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
125 case $file in |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
126 RCS/. | RCS/..) ;; |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
127 RCS/.\* | RCS/\*) test -f "$file" && files=$files$nl$file;; |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
128 *) files=$files$nl$file |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
129 esac |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
130 done |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
131 case $files in |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
132 '') exit 0 |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
133 esac |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
134 oldIFS=$IFS |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
135 IFS=$nl |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
136 set $files |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
137 IFS=$oldIFS |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
138 esac |
9ee93fc9aba0
When given no file arguments, inspect RCS/.* as well
Richard M. Stallman <rms@gnu.org>
parents:
2639
diff
changeset
|
139 |
527 | 140 rlogout=/tmp/chg$$ |
141 trap exit 1 2 13 15 | |
142 trap 'rm -f $rlogout; exit 1' 0 | |
143 | |
534 | 144 rlog "$datearg" "$@" >$rlogout || exit |
527 | 145 |
146 | |
147 # Get the full name of each author the logs mention, and set initialize_fullname | |
148 # to awk code that initializes the `fullname' awk associative array. | |
149 # Warning: foreign authors (i.e. not known in the passwd file) are mishandled; | |
150 # you have to fix the resulting output by hand. | |
151 | |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
152 initialize_fullname= |
527 | 153 authors=` |
154 sed -n 's|^date: *[0-9]*/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]; *author: *\([^; ]*\).*|\1|p' <$rlogout | | |
155 sort -u | |
156 ` | |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
157 case $authors in |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
158 ?*) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
159 initialize_author= |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
160 for author in $authors |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
161 do |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
162 initialize_author="$initialize_author |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
163 author[\"$author\"] = 1 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
164 " |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
165 done |
527 | 166 |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
167 awkscript=' |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
168 BEGIN { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
169 alphabet = "abcdefghijklmnopqrstuvwxyz" |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
170 ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
171 '"$initialize_author"' |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
172 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
173 { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
174 if (author[$1]) { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
175 fullname = $5 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
176 abbr = index(fullname, "&") |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
177 if (abbr) { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
178 a = substr($1, 1, 1) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
179 A = a |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
180 i = index(alphabet, a) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
181 if (i) A = substr(ALPHABET, i, 1) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
182 fullname = substr(fullname, 1, abbr-1) A substr($1, 2) substr(fullname, abbr+1) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
183 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
184 printf "fullname[\"%s\"] = \"%s\"\n", $1, fullname |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
185 author[$1] = 0 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
186 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
187 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
188 ' |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
189 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
190 initialize_fullname=` |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
191 (cat /etc/passwd; ypmatch $authors passwd) 2>/dev/null | |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
192 awk -F: "$awkscript" |
527 | 193 ` |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
194 esac |
527 | 195 |
196 | |
197 # Function to print a single log line. | |
198 # We don't use awk functions, to stay compatible with old awk versions. | |
199 # `Log' is the log message (with \n replaced by \r). | |
594 | 200 # `files' contains the affected files. |
527 | 201 printlogline='{ |
202 | |
203 # Following the GNU coding standards, rewrite | |
204 # * file: (function): comment | |
205 # to | |
206 # * file (function): comment | |
207 if (Log ~ /^\([^)]*\): /) { | |
208 i = index(Log, ")") | |
209 files = files " " substr(Log, 1, i) | |
210 Log = substr(Log, i+3) | |
211 } | |
212 | |
213 # If "label: comment" is too long, break the line after the ":". | |
214 sep = " " | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
215 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, CR)) sep = "\n" indent_string |
527 | 216 |
217 # Print the label. | |
534 | 218 printf "%s*%s:", indent_string, files |
527 | 219 |
220 # Print each line of the log, transliterating \r to \n. | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
221 while ((i = index(Log, CR)) != 0) { |
527 | 222 printf "%s%s\n", sep, substr(Log, 1, i-1) |
534 | 223 sep = indent_string |
527 | 224 Log = substr(Log, i+1) |
225 } | |
226 }' | |
227 | |
228 hostname=`( | |
229 hostname || cat /etc/whoami || uuname -l || uname -n | |
230 ) 2>/dev/null` || { | |
231 echo >&2 "$0: cannot deduce hostname" | |
232 exit 1 | |
233 } | |
234 | |
235 | |
236 # Process the rlog output, generating ChangeLog style entries. | |
237 | |
238 # First, reformat the rlog output so that each line contains one log entry. | |
239 # Transliterate \n to \r so that multiline entries fit on a single line. | |
240 # Discard irrelevant rlog output. | |
241 awk <$rlogout ' | |
242 /^Working file:/ { filename = $3 } | |
243 /^date: /, /^(-----------*|===========*)$/ { | |
244 if ($0 ~ /^branches: /) { next } | |
2639
0e6a6d065a94
mawk, SunOS 4.1.3 nawk, and Ultrix/MKS nawk all barf on /[/]/, so change
Paul Eggert <eggert@twinsun.com>
parents:
2220
diff
changeset
|
245 if ($0 ~ /^date: [0-9][ \/0-9:]*;/) { |
527 | 246 time = substr($3, 1, length($3)-1) |
247 author = substr($5, 1, length($5)-1) | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
248 printf "%s %s %s %s %c", filename, $2, time, author, 13 |
527 | 249 next |
250 } | |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
251 if ($0 ~ /^(-----------*|===========*)$/) { print ""; next } |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
252 printf "%s%c", $0, 13 |
527 | 253 } |
254 ' | | |
255 | |
256 # Now each line is of the form | |
257 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG | |
258 # where \r stands for a carriage return, | |
259 # and each line of the log is terminated by \r instead of \n. | |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
260 # Sort the log entries, first by date+time (in reverse order), |
527 | 261 # then by author, then by log entry, and finally by file name (just in case). |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
262 sort +1 -3r +3 +0 | |
527 | 263 |
264 # Finally, reformat the sorted log entries. | |
265 awk ' | |
266 BEGIN { | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
267 # Some awks do not understand "\r" or "\013", so we have to |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
268 # put a carriage return directly in the file. |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
269 CR=" " # <-- There is a single CR between the " chars here. |
527 | 270 |
271 # Initialize the fullname associative array. | |
272 '"$initialize_fullname"' | |
273 | |
534 | 274 # Initialize indent string. |
275 indent_string = "" | |
276 i = '"$indent"' | |
277 if (0 < '"$tabwidth"') | |
278 for (; '"$tabwidth"' <= i; i -= '"$tabwidth"') | |
279 indent_string = indent_string "\t" | |
280 while (1 <= i--) | |
281 indent_string = indent_string " " | |
282 | |
527 | 283 # Set up date conversion tables. |
284 # RCS uses a nice, clean, sortable format, | |
285 # but ChangeLog wants the traditional, ugly ctime format. | |
286 | |
287 # January 1, 0 AD (Gregorian) was Saturday = 6 | |
288 EPOCH_WEEKDAY = 6 | |
289 # Of course, there was no 0 AD, but the algorithm works anyway. | |
290 | |
291 w[0]="Sun"; w[1]="Mon"; w[2]="Tue"; w[3]="Wed" | |
292 w[4]="Thu"; w[5]="Fri"; w[6]="Sat" | |
293 | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
294 '"$month_data"' |
527 | 295 } |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
296 |
527 | 297 { |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
298 newlog = substr($0, 1 + index($0, CR)) |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
299 |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
300 # Ignore log entries prefixed by "#". |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
301 if (newlog ~ /^#/) { next } |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
302 |
527 | 303 if (Log != newlog || date != $2 || author != $4) { |
594 | 304 |
527 | 305 # The previous log and this log differ. |
594 | 306 |
307 # Print the old log. | |
527 | 308 if (date != "") '"$printlogline"' |
309 | |
594 | 310 # Logs that begin with "{clumpname} " should be grouped together, |
311 # and the clumpname should be removed. | |
312 # Extract the new clumpname from the log header, | |
313 # and use it to decide whether to output a blank line. | |
314 newclumpname = "" | |
315 sep = "\n" | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
316 if (date == "") sep = "" |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
317 if (newlog ~ /^{[^ }]*}[ ]/) { |
594 | 318 i = index(newlog, "}") |
319 newclumpname = substr(newlog, 1, i) | |
320 while (substr(newlog, i+1) ~ /^[ ]/) i++ | |
321 newlog = substr(newlog, i+1) | |
322 if (clumpname == newclumpname) sep = "" | |
323 } | |
324 printf sep | |
325 clumpname = newclumpname | |
326 | |
527 | 327 # Get ready for the next log. |
328 Log = newlog | |
534 | 329 if (files != "") |
330 for (i in filesknown) | |
331 filesknown[i] = 0 | |
527 | 332 files = "" |
333 } | |
334 if (date != $2 || author != $4) { | |
335 # The previous date+author and this date+author differ. | |
336 # Print the new one. | |
337 date = $2 | |
338 author = $4 | |
339 | |
340 # Convert nice RCS date like "1992/01/03 00:03:44" | |
341 # into ugly ctime date like "Fri Jan 3 00:03:44 1992". | |
342 # Calculate day of week from Gregorian calendar. | |
343 i = index($2, "/") | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
344 year = substr($2, 1, i-1) + 0 |
527 | 345 monthday = substr($2, i+1) |
346 i = index(monthday, "/") | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
347 month = substr(monthday, 1, i-1) + 0 |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
348 day = substr(monthday, i+1) + 0 |
527 | 349 leap = 0 |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
350 if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1 |
527 | 351 days_since_Sunday_before_epoch = EPOCH_WEEKDAY + year * 365 + int((year + 3) / 4) - int((year + 99) / 100) + int((year + 399) / 400) + mo[month-1] + leap + day - 1 |
352 | |
534 | 353 # Print "date fullname (email address)" if the fullname is known; |
354 # print "date author" otherwise. | |
527 | 355 # Get the fullname from the associative array. |
356 # The email address is just author@thishostname. | |
534 | 357 printf "%s %s %2d %s %d ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year |
358 if (fullname[author]) | |
359 printf "%s (%s@%s)\n\n", fullname[author], author, "'"$hostname"'" | |
360 else | |
361 printf "%s\n\n", author | |
527 | 362 } |
534 | 363 if (! filesknown[$1]) { |
364 filesknown[$1] = 1 | |
594 | 365 if (files == "") files = " " $1 |
366 else files = files ", " $1 | |
534 | 367 } |
527 | 368 } |
369 END { | |
370 # Print the last log. | |
594 | 371 if (date != "") { |
372 '"$printlogline"' | |
373 printf "\n" | |
374 } | |
527 | 375 } |
376 ' && | |
377 | |
378 | |
379 # Exit successfully. | |
380 | |
381 exec rm -f $rlogout |