Mercurial > emacs
annotate lib-src/rcs2log @ 3067:38fa0e3705f6
Fix the fix.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Tue, 25 May 1993 09:26:44 +0000 |
parents | 0e6a6d065a94 |
children | 9ee93fc9aba0 |
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 |
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
|
15 # $Id: rcs2log,v 1.10 1993/03/16 22:49:00 eggert Exp eggert $ |
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 |
05cb79ebdb23
Add copyright and authorship notices.
Paul Eggert <eggert@twinsun.com>
parents:
1228
diff
changeset
|
33 |
534 | 34 # Parse options. |
35 | |
36 # defaults | |
37 indent=8 # indent of log line | |
38 length=79 # suggested max width of log line | |
39 tabwidth=8 # width of horizontal tab | |
40 | |
41 while : | |
42 do | |
43 case $1 in | |
44 -i) indent=${2?};; | |
45 -l) length=${2?};; | |
46 -t) tabwidth=${2?};; | |
47 -*) echo >&2 "$0: usage: $0 [-i indent] [-l length] [-t tabwidth] [file ...]" | |
48 exit 1;; | |
49 *) break | |
50 esac | |
51 shift; shift | |
52 done | |
53 | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
54 month_data=' |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 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
|
59 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
60 # 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
|
61 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
|
62 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
|
63 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
|
64 mo[12]=365 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
65 ' |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
66 |
534 | 67 |
527 | 68 # Log into $rlogout the revisions checked in since the first ChangeLog entry. |
69 | |
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
|
70 date=1970 |
527 | 71 if test -s ChangeLog |
72 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
|
73 # 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
|
74 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
|
75 /^... ... [ 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
|
76 '"$month_data"' |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
77 year = $5 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
78 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
|
79 dd = $3 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
80 hh = substr($0,12,2) |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
81 mm = substr($0,15,2) |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
82 ss = substr($0,18,2) |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
83 ss++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
84 if (ss == 60) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
85 ss = 0 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
86 mm++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
87 if (mm == 60) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
88 mm = 0 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
89 hh++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
90 if (hh == 24) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
91 hh = 0 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
92 dd++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
93 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
|
94 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
|
95 if (dd == monthdays + 1) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
96 dd = 1 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
97 i++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
98 if (i == 12) { |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
99 i = 0 |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
100 year++ |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
101 } |
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
102 } |
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 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
|
107 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
|
108 } |
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 ' |
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 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
|
111 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
|
112 ?*) date=$d |
535
4b75abb93479
Don't munge $* when getting date from ChangeLog.
Paul Eggert <eggert@twinsun.com>
parents:
534
diff
changeset
|
113 esac |
527 | 114 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
|
115 datearg="-d>$date" |
527 | 116 |
117 rlogout=/tmp/chg$$ | |
118 trap exit 1 2 13 15 | |
119 trap 'rm -f $rlogout; exit 1' 0 | |
120 | |
534 | 121 case $# in |
122 0) set RCS/* | |
123 esac | |
124 | |
125 rlog "$datearg" "$@" >$rlogout || exit | |
527 | 126 |
127 | |
128 # Get the full name of each author the logs mention, and set initialize_fullname | |
129 # to awk code that initializes the `fullname' awk associative array. | |
130 # Warning: foreign authors (i.e. not known in the passwd file) are mishandled; | |
131 # you have to fix the resulting output by hand. | |
132 | |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
133 initialize_fullname= |
527 | 134 authors=` |
135 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 | | |
136 sort -u | |
137 ` | |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
138 case $authors in |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
139 ?*) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
140 initialize_author= |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
141 for author in $authors |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
142 do |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
143 initialize_author="$initialize_author |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
144 author[\"$author\"] = 1 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
145 " |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
146 done |
527 | 147 |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
148 awkscript=' |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
149 BEGIN { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
150 alphabet = "abcdefghijklmnopqrstuvwxyz" |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
151 ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
152 '"$initialize_author"' |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
153 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
154 { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
155 if (author[$1]) { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
156 fullname = $5 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
157 abbr = index(fullname, "&") |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
158 if (abbr) { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
159 a = substr($1, 1, 1) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
160 A = a |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
161 i = index(alphabet, a) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
162 if (i) A = substr(ALPHABET, i, 1) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
163 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
|
164 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
165 printf "fullname[\"%s\"] = \"%s\"\n", $1, fullname |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
166 author[$1] = 0 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
167 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
168 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
169 ' |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
170 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
171 initialize_fullname=` |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
172 (cat /etc/passwd; ypmatch $authors passwd) 2>/dev/null | |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
173 awk -F: "$awkscript" |
527 | 174 ` |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
175 esac |
527 | 176 |
177 | |
178 # Function to print a single log line. | |
179 # We don't use awk functions, to stay compatible with old awk versions. | |
180 # `Log' is the log message (with \n replaced by \r). | |
594 | 181 # `files' contains the affected files. |
527 | 182 printlogline='{ |
183 | |
184 # Following the GNU coding standards, rewrite | |
185 # * file: (function): comment | |
186 # to | |
187 # * file (function): comment | |
188 if (Log ~ /^\([^)]*\): /) { | |
189 i = index(Log, ")") | |
190 files = files " " substr(Log, 1, i) | |
191 Log = substr(Log, i+3) | |
192 } | |
193 | |
194 # If "label: comment" is too long, break the line after the ":". | |
195 sep = " " | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
196 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, CR)) sep = "\n" indent_string |
527 | 197 |
198 # Print the label. | |
534 | 199 printf "%s*%s:", indent_string, files |
527 | 200 |
201 # 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
|
202 while ((i = index(Log, CR)) != 0) { |
527 | 203 printf "%s%s\n", sep, substr(Log, 1, i-1) |
534 | 204 sep = indent_string |
527 | 205 Log = substr(Log, i+1) |
206 } | |
207 }' | |
208 | |
209 hostname=`( | |
210 hostname || cat /etc/whoami || uuname -l || uname -n | |
211 ) 2>/dev/null` || { | |
212 echo >&2 "$0: cannot deduce hostname" | |
213 exit 1 | |
214 } | |
215 | |
216 | |
217 # Process the rlog output, generating ChangeLog style entries. | |
218 | |
219 # First, reformat the rlog output so that each line contains one log entry. | |
220 # Transliterate \n to \r so that multiline entries fit on a single line. | |
221 # Discard irrelevant rlog output. | |
222 awk <$rlogout ' | |
223 /^Working file:/ { filename = $3 } | |
224 /^date: /, /^(-----------*|===========*)$/ { | |
225 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
|
226 if ($0 ~ /^date: [0-9][ \/0-9:]*;/) { |
527 | 227 time = substr($3, 1, length($3)-1) |
228 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
|
229 printf "%s %s %s %s %c", filename, $2, time, author, 13 |
527 | 230 next |
231 } | |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
232 if ($0 ~ /^(-----------*|===========*)$/) { print ""; next } |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
233 printf "%s%c", $0, 13 |
527 | 234 } |
235 ' | | |
236 | |
237 # Now each line is of the form | |
238 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG | |
239 # where \r stands for a carriage return, | |
240 # 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
|
241 # Sort the log entries, first by date+time (in reverse order), |
527 | 242 # 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
|
243 sort +1 -3r +3 +0 | |
527 | 244 |
245 # Finally, reformat the sorted log entries. | |
246 awk ' | |
247 BEGIN { | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
248 # 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
|
249 # 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
|
250 CR=" " # <-- There is a single CR between the " chars here. |
527 | 251 |
252 # Initialize the fullname associative array. | |
253 '"$initialize_fullname"' | |
254 | |
534 | 255 # Initialize indent string. |
256 indent_string = "" | |
257 i = '"$indent"' | |
258 if (0 < '"$tabwidth"') | |
259 for (; '"$tabwidth"' <= i; i -= '"$tabwidth"') | |
260 indent_string = indent_string "\t" | |
261 while (1 <= i--) | |
262 indent_string = indent_string " " | |
263 | |
527 | 264 # Set up date conversion tables. |
265 # RCS uses a nice, clean, sortable format, | |
266 # but ChangeLog wants the traditional, ugly ctime format. | |
267 | |
268 # January 1, 0 AD (Gregorian) was Saturday = 6 | |
269 EPOCH_WEEKDAY = 6 | |
270 # Of course, there was no 0 AD, but the algorithm works anyway. | |
271 | |
272 w[0]="Sun"; w[1]="Mon"; w[2]="Tue"; w[3]="Wed" | |
273 w[4]="Thu"; w[5]="Fri"; w[6]="Sat" | |
274 | |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
275 '"$month_data"' |
527 | 276 } |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
277 |
527 | 278 { |
2220
66371f0b8aff
Some awks don't understand "\r". Code around this.
Paul Eggert <eggert@twinsun.com>
parents:
1800
diff
changeset
|
279 newlog = substr($0, 1 + index($0, CR)) |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
280 |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
281 # Ignore log entries prefixed by "#". |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
282 if (newlog ~ /^#/) { next } |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
283 |
527 | 284 if (Log != newlog || date != $2 || author != $4) { |
594 | 285 |
527 | 286 # The previous log and this log differ. |
594 | 287 |
288 # Print the old log. | |
527 | 289 if (date != "") '"$printlogline"' |
290 | |
594 | 291 # Logs that begin with "{clumpname} " should be grouped together, |
292 # and the clumpname should be removed. | |
293 # Extract the new clumpname from the log header, | |
294 # and use it to decide whether to output a blank line. | |
295 newclumpname = "" | |
296 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
|
297 if (date == "") sep = "" |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
298 if (newlog ~ /^{[^ }]*}[ ]/) { |
594 | 299 i = index(newlog, "}") |
300 newclumpname = substr(newlog, 1, i) | |
301 while (substr(newlog, i+1) ~ /^[ ]/) i++ | |
302 newlog = substr(newlog, i+1) | |
303 if (clumpname == newclumpname) sep = "" | |
304 } | |
305 printf sep | |
306 clumpname = newclumpname | |
307 | |
527 | 308 # Get ready for the next log. |
309 Log = newlog | |
534 | 310 if (files != "") |
311 for (i in filesknown) | |
312 filesknown[i] = 0 | |
527 | 313 files = "" |
314 } | |
315 if (date != $2 || author != $4) { | |
316 # The previous date+author and this date+author differ. | |
317 # Print the new one. | |
318 date = $2 | |
319 author = $4 | |
320 | |
321 # Convert nice RCS date like "1992/01/03 00:03:44" | |
322 # into ugly ctime date like "Fri Jan 3 00:03:44 1992". | |
323 # Calculate day of week from Gregorian calendar. | |
324 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
|
325 year = substr($2, 1, i-1) + 0 |
527 | 326 monthday = substr($2, i+1) |
327 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
|
328 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
|
329 day = substr(monthday, i+1) + 0 |
527 | 330 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
|
331 if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1 |
527 | 332 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 |
333 | |
534 | 334 # Print "date fullname (email address)" if the fullname is known; |
335 # print "date author" otherwise. | |
527 | 336 # Get the fullname from the associative array. |
337 # The email address is just author@thishostname. | |
534 | 338 printf "%s %s %2d %s %d ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year |
339 if (fullname[author]) | |
340 printf "%s (%s@%s)\n\n", fullname[author], author, "'"$hostname"'" | |
341 else | |
342 printf "%s\n\n", author | |
527 | 343 } |
534 | 344 if (! filesknown[$1]) { |
345 filesknown[$1] = 1 | |
594 | 346 if (files == "") files = " " $1 |
347 else files = files ", " $1 | |
534 | 348 } |
527 | 349 } |
350 END { | |
351 # Print the last log. | |
594 | 352 if (date != "") { |
353 '"$printlogline"' | |
354 printf "\n" | |
355 } | |
527 | 356 } |
357 ' && | |
358 | |
359 | |
360 # Exit successfully. | |
361 | |
362 exec rm -f $rlogout |