2000-02-10 Francesco Potorti` <pot@gnu.org>
[bpt/emacs.git] / lib-src / rcs2log
CommitLineData
d5ad1373 1#! /bin/sh
b86e8615
PE
2
3# RCS to ChangeLog generator
4
77851e9c
PE
5# Generate a change log prefix from RCS files (perhaps in the CVS repository)
6# and the ChangeLog (if any).
b86e8615
PE
7# Output the new prefix to standard output.
8# You can edit this prefix by hand, and then prepend it to ChangeLog.
9
19ed208b
PE
10# Ignore log entries that start with `#'.
11# Clump together log entries that start with `{topic} ',
12# where `topic' contains neither white space nor `}'.
b86e8615 13
77851e9c
PE
14Help='The default FILEs are the files registered under the working directory.
15Options:
16
17 -c CHANGELOG Output a change log prefix to CHANGELOG (default ChangeLog).
18 -h HOSTNAME Use HOSTNAME in change log entries (default current host).
19 -i INDENT Indent change log lines by INDENT spaces (default 8).
20 -l LENGTH Try to limit log lines to LENGTH characters (default 79).
21 -R If no FILEs are given and RCS is used, recurse through working directory.
22 -r OPTION Pass OPTION to subsidiary log command.
23 -t TABWIDTH Tab stops are every TABWIDTH characters (default 8).
24 -u "LOGIN<tab>FULLNAME<tab>MAILADDR" Assume LOGIN has FULLNAME and MAILADDR.
25 -v Append RCS revision to file names in log lines.
26 --help Output help.
27 --version Output version number.
28
f868e34c 29Report bugs to <bug-gnu-emacs@gnu.org>.'
0b67eabf 30
f868e34c 31Id='$Id: rcs2log,v 1.44 1998/08/12 14:22:14 eggert Exp eggert $'
0b67eabf 32
a11a197b 33# Copyright 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
0b67eabf
PE
34
35# This program is free software; you can redistribute it and/or modify
36# it under the terms of the GNU General Public License as published by
37# the Free Software Foundation; either version 2, or (at your option)
38# any later version.
7b8b6c7a 39#
0b67eabf
PE
40# This program is distributed in the hope that it will be useful,
41# but WITHOUT ANY WARRANTY; without even the implied warranty of
42# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43# GNU General Public License for more details.
7b8b6c7a 44#
0b67eabf 45# You should have received a copy of the GNU General Public License
942bbf2b 46# along with this program; see the file COPYING. If not, write to the
1fb87c77
KH
47# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
48# Boston, MA 02111-1307, USA.
0b67eabf 49
f868e34c 50Copyright='Copyright 1998 Free Software Foundation, Inc.
77851e9c
PE
51This program comes with NO WARRANTY, to the extent permitted by law.
52You may redistribute copies of this program
53under the terms of the GNU General Public License.
54For more information about these matters, see the files named COPYING.
55Author: Paul Eggert <eggert@twinsun.com>'
56
44ef8c25 57tab=' '
148d61aa
RS
58nl='
59'
0b67eabf 60
4ca2c4b4
PE
61# Parse options.
62
63# defaults
44ef8c25 64: ${AWK=awk}
31ce77fa 65: ${TMPDIR=/tmp}
7b8b6c7a
EN
66changelog=ChangeLog # change log file name
67datearg= # rlog date option
31ce77fa 68hostname= # name of local host (if empty, will deduce it later)
4ca2c4b4
PE
69indent=8 # indent of log line
70length=79 # suggested max width of log line
64736f55 71logins= # login names for people we know fullnames and mailaddrs of
44ef8c25 72loginFullnameMailaddrs= # login<tab>fullname<tab>mailaddr triplets
7b8b6c7a 73logTZ= # time zone for log dates (if empty, use local time)
44ef8c25 74recursive= # t if we want recursive rlog
7b8b6c7a 75revision= # t if we want revision numbers
31ce77fa 76rlog_options= # options to pass to rlog
4ca2c4b4
PE
77tabwidth=8 # width of horizontal tab
78
79while :
80do
81 case $1 in
7b8b6c7a 82 -c) changelog=${2?}; shift;;
44ef8c25
PE
83 -i) indent=${2?}; shift;;
84 -h) hostname=${2?}; shift;;
85 -l) length=${2?}; shift;;
86 -[nu]) # -n is obsolescent; it is replaced by -u.
87 case $1 in
88 -n) case ${2?}${3?}${4?} in
89 *"$tab"* | *"$nl"*)
90 echo >&2 "$0: -n '$2' '$3' '$4': tabs, newlines not allowed"
91 exit 1
92 esac
d74a9f24
PE
93 case $loginFullnameMailaddrs in
94 '') loginFullnameMailaddrs=$2$tab$3$tab$4;;
95 ?*) loginFullnameMailaddrs=$loginFullnameMailaddrs$nl$2$tab$3$tab$4
96 esac
44ef8c25
PE
97 shift; shift; shift;;
98 -u)
0a4e59d9 99 # If $2 is not tab-separated, use colon for separator.
44ef8c25
PE
100 case ${2?} in
101 *"$nl"*)
102 echo >&2 "$0: -u '$2': newlines not allowed"
103 exit 1;;
0a4e59d9
PE
104 *"$tab"*)
105 t=$tab;;
106 *)
107 t=:
108 esac
109 case $2 in
110 *"$t"*"$t"*"$t"*)
44ef8c25
PE
111 echo >&2 "$0: -u '$2': too many fields"
112 exit 1;;
0a4e59d9 113 *"$t"*"$t"*)
44ef8c25
PE
114 ;;
115 *)
116 echo >&2 "$0: -u '$2': not enough fields"
117 exit 1
118 esac
d74a9f24
PE
119 case $loginFullnameMailaddrs in
120 '') loginFullnameMailaddrs=$2;;
121 ?*) loginFullnameMailaddrs=$loginFullnameMailaddrs$nl$2
122 esac
44ef8c25 123 shift
31ce77fa 124 esac
d74a9f24
PE
125 case $logins in
126 '') logins=$login;;
127 ?*) logins=$logins$nl$login
128 esac
44ef8c25 129 ;;
d74a9f24
PE
130 -r)
131 case $rlog_options in
132 '') rlog_options=${2?};;
133 ?*) rlog_options=$rlog_options$nl${2?}
134 esac
135 shift;;
44ef8c25
PE
136 -R) recursive=t;;
137 -t) tabwidth=${2?}; shift;;
7b8b6c7a 138 -v) revision=t;;
77851e9c
PE
139 --version)
140 set $Id
141 rcs2logVersion=$3
142 echo >&2 "rcs2log (GNU Emacs) $rcs2logVersion$nl$Copyright"
143 exit 0;;
144 -*) echo >&2 "Usage: $0 [OPTION]... [FILE ...]$nl$Help"
145 case $1 in
146 --help) exit 0;;
147 *) exit 1
148 esac;;
4ca2c4b4
PE
149 *) break
150 esac
44ef8c25 151 shift
4ca2c4b4
PE
152done
153
f9155ea0
PE
154month_data='
155 m[0]="Jan"; m[1]="Feb"; m[2]="Mar"
156 m[3]="Apr"; m[4]="May"; m[5]="Jun"
157 m[6]="Jul"; m[7]="Aug"; m[8]="Sep"
158 m[9]="Oct"; m[10]="Nov"; m[11]="Dec"
f9155ea0
PE
159'
160
4ca2c4b4 161
64736f55 162# Put rlog output into $rlogout.
b86e8615 163
64736f55
PE
164# If no rlog options are given,
165# log the revisions checked in since the first ChangeLog entry.
7b8b6c7a
EN
166# Since ChangeLog is only by date, some of these revisions may be duplicates of
167# what's already in ChangeLog; it's the user's responsibility to remove them.
64736f55
PE
168case $rlog_options in
169'')
7b8b6c7a 170 if test -s "$changelog"
64736f55 171 then
64736f55 172 e='
7b8b6c7a
EN
173 /^[0-9]+-[0-9][0-9]-[0-9][0-9]/{
174 # ISO 8601 date
175 print $1
176 exit
177 }
64736f55 178 /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{
7b8b6c7a 179 # old-fashioned date and time (Emacs 19.31 and earlier)
64736f55
PE
180 '"$month_data"'
181 year = $5
182 for (i=0; i<=11; i++) if (m[i] == $2) break
183 dd = $3
7b8b6c7a 184 printf "%d-%02d-%02d\n", year, i+1, dd
64736f55 185 exit
f9155ea0 186 }
64736f55 187 '
7b8b6c7a 188 d=`$AWK "$e" <"$changelog"` || exit
64736f55 189 case $d in
6fbe22d8 190 ?*) datearg="-d>$d"
64736f55
PE
191 esac
192 fi
64736f55 193esac
b86e8615 194
7b8b6c7a
EN
195# Use TZ specified by ChangeLog local variable, if any.
196if test -s "$changelog"
197then
198 extractTZ='
199 /^.*change-log-time-zone-rule['"$tab"' ]*:['"$tab"' ]*"\([^"]*\)".*/{
200 s//\1/; p; q
201 }
202 /^.*change-log-time-zone-rule['"$tab"' ]*:['"$tab"' ]*t.*/{
203 s//UTC0/; p; q
204 }
205 '
206 logTZ=`tail "$changelog" | sed -n "$extractTZ"`
207 case $logTZ in
208 ?*) TZ=$logTZ; export TZ
209 esac
210fi
211
64736f55
PE
212# If CVS is in use, examine its repository, not the normal RCS files.
213if test ! -f CVS/Repository
214then
215 rlog=rlog
216 repository=
217else
77851e9c 218 rlog='cvs -q log'
64736f55 219 repository=`sed 1q <CVS/Repository` || exit
c49b2b75 220 test ! -f CVS/Root || CVSROOT=`cat <CVS/Root` || exit
fdb3286e 221 case $CVSROOT in
c49b2b75
PE
222 *:/*)
223 # remote repository
224 ;;
225 *)
226 # local repository
227 case $repository in
228 /*) ;;
fdb3286e 229 *) repository=${CVSROOT?}/$repository
c49b2b75
PE
230 esac
231 if test ! -d "$repository"
232 then
233 echo >&2 "$0: $repository: bad repository (see CVS/Repository)"
234 exit 1
235 fi
64736f55 236 esac
64736f55 237fi
7a833f0b 238
f41c4842
PE
239# Use $rlog's -zLT option, if $rlog supports it.
240case `$rlog -zLT 2>&1` in
30fc6c65 241*' option'*) ;;
d74a9f24
PE
242*)
243 case $rlog_options in
244 '') rlog_options=-zLT;;
245 ?*) rlog_options=-zLT$nl$rlog_options
246 esac
f41c4842
PE
247esac
248
148d61aa
RS
249# With no arguments, examine all files under the RCS directory.
250case $# in
2510)
7a833f0b
PE
252 case $repository in
253 '')
7a833f0b
PE
254 oldIFS=$IFS
255 IFS=$nl
44ef8c25
PE
256 case $recursive in
257 t)
258 RCSdirs=`find . -name RCS -type d -print`
259 filesFromRCSfiles='s|,v$||; s|/RCS/|/|; s|^\./||'
260 files=`
261 {
262 case $RCSdirs in
8fd92790
PE
263 ?*) find $RCSdirs \
264 -type f \
265 ! -name '*_' \
266 ! -name ',*,' \
267 ! -name '.*_' \
268 ! -name .rcsfreeze.log \
269 ! -name .rcsfreeze.ver \
270 -print
44ef8c25
PE
271 esac
272 find . -name '*,v' -print
273 } |
274 sort -u |
275 sed "$filesFromRCSfiles"
276 `;;
277 *)
278 files=
279 for file in RCS/.* RCS/* .*,v *,v
280 do
281 case $file in
8fd92790
PE
282 RCS/. | RCS/.. | RCS/,*, | RCS/*_) continue;;
283 RCS/.rcsfreeze.log | RCS/.rcsfreeze.ver) continue;;
b8ffe570
PE
284 RCS/.\* | RCS/\* | .\*,v | \*,v) test -f "$file" || continue;;
285 RCS/*,v | RCS/.*,v) ;;
286 RCS/* | RCS/.*) test -f "$file" || continue
44ef8c25 287 esac
d74a9f24
PE
288 case $files in
289 '') files=$file;;
290 ?*) files=$files$nl$file
291 esac
44ef8c25
PE
292 done
293 case $files in
294 '') exit 0
295 esac
296 esac
297 set x $files
298 shift
7a833f0b 299 IFS=$oldIFS
148d61aa 300 esac
148d61aa
RS
301esac
302
44ef8c25 303llogout=$TMPDIR/rcs2log$$l
31ce77fa 304rlogout=$TMPDIR/rcs2log$$r
b86e8615 305trap exit 1 2 13 15
44ef8c25 306trap "rm -f $llogout $rlogout; exit 1" 0
b86e8615 307
7b8b6c7a
EN
308case $datearg in
309?*) $rlog $rlog_options "$datearg" ${1+"$@"} >$rlogout;;
310'') $rlog $rlog_options ${1+"$@"} >$rlogout
64736f55 311esac || exit
b86e8615
PE
312
313
314# Get the full name of each author the logs mention, and set initialize_fullname
315# to awk code that initializes the `fullname' awk associative array.
316# Warning: foreign authors (i.e. not known in the passwd file) are mishandled;
317# you have to fix the resulting output by hand.
318
44ef8c25
PE
319initialize_fullname=
320initialize_mailaddr=
321
322case $loginFullnameMailaddrs in
323?*)
324 case $loginFullnameMailaddrs in
325 *\"* | *\\*)
326 sed 's/["\\]/\\&/g' >$llogout <<EOF || exit
327$loginFullnameMailaddrs
328EOF
329 loginFullnameMailaddrs=`cat $llogout`
330 esac
331
332 oldIFS=$IFS
333 IFS=$nl
334 for loginFullnameMailaddr in $loginFullnameMailaddrs
335 do
0a4e59d9
PE
336 case $loginFullnameMailaddr in
337 *"$tab"*) IFS=$tab;;
338 *) IFS=:
339 esac
44ef8c25
PE
340 set x $loginFullnameMailaddr
341 login=$2
342 fullname=$3
343 mailaddr=$4
344 initialize_fullname="$initialize_fullname
345 fullname[\"$login\"] = \"$fullname\""
346 initialize_mailaddr="$initialize_mailaddr
347 mailaddr[\"$login\"] = \"$mailaddr\""
348 done
349 IFS=$oldIFS
350esac
351
352case $llogout in
353?*) sort -u -o $llogout <<EOF || exit
31ce77fa
PE
354$logins
355EOF
356esac
44ef8c25 357output_authors='/^date: / {
a8a818c0 358 if ($2 ~ /^[0-9]*[-\/][0-9][0-9][-\/][0-9][0-9]$/ && $3 ~ /^[0-9][0-9]:[0-9][0-9]:[0-9][0-9][-+0-9:]*;$/ && $4 == "author:" && $5 ~ /^[^;]*;$/) {
44ef8c25
PE
359 print substr($5, 1, length($5)-1)
360 }
361}'
b86e8615 362authors=`
44ef8c25
PE
363 $AWK "$output_authors" <$rlogout |
364 case $llogout in
31ce77fa 365 '') sort -u;;
44ef8c25 366 ?*) sort -u | comm -23 - $llogout
31ce77fa 367 esac
b86e8615 368`
2af06121
PE
369case $authors in
370?*)
44ef8c25
PE
371 cat >$llogout <<EOF || exit
372$authors
373EOF
374 initialize_author_script='s/["\\]/\\&/g; s/.*/author[\"&\"] = 1/'
375 initialize_author=`sed -e "$initialize_author_script" <$llogout`
2af06121
PE
376 awkscript='
377 BEGIN {
378 alphabet = "abcdefghijklmnopqrstuvwxyz"
379 ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
380 '"$initialize_author"'
381 }
382 {
383 if (author[$1]) {
384 fullname = $5
194bf419
PE
385 if (fullname ~ /[0-9]+-[^(]*\([0-9]+\)$/) {
386 # Remove the junk from fullnames like "0000-Admin(0000)".
387 fullname = substr(fullname, index(fullname, "-") + 1)
388 fullname = substr(fullname, 1, index(fullname, "(") - 1)
389 }
390 if (fullname ~ /,[^ ]/) {
391 # Some sites put comma-separated junk after the fullname.
392 # Remove it, but leave "Bill Gates, Jr" alone.
393 fullname = substr(fullname, 1, index(fullname, ",") - 1)
394 }
2af06121
PE
395 abbr = index(fullname, "&")
396 if (abbr) {
397 a = substr($1, 1, 1)
398 A = a
399 i = index(alphabet, a)
400 if (i) A = substr(ALPHABET, i, 1)
401 fullname = substr(fullname, 1, abbr-1) A substr($1, 2) substr(fullname, abbr+1)
402 }
44ef8c25
PE
403
404 # Quote quotes and backslashes properly in full names.
405 # Do not use gsub; traditional awk lacks it.
406 quoted = ""
407 rest = fullname
408 for (;;) {
409 p = index(rest, "\\")
410 q = index(rest, "\"")
411 if (p) {
412 if (q && q<p) p = q
413 } else {
414 if (!q) break
415 p = q
416 }
417 quoted = quoted substr(rest, 1, p-1) "\\" substr(rest, p, 1)
418 rest = substr(rest, p+1)
419 }
420
421 printf "fullname[\"%s\"] = \"%s%s\"\n", $1, quoted, rest
2af06121
PE
422 author[$1] = 0
423 }
424 }
425 '
b86e8615 426
2af06121 427 initialize_fullname=`
c4c65c33
PE
428 {
429 (getent passwd $authors) ||
430 (
431 cat /etc/passwd
432 for author in $authors
433 do NIS_PATH= nismatch $author passwd.org_dir
434 done
435 ypmatch $authors passwd
436 )
437 } 2>/dev/null |
44ef8c25 438 $AWK -F: "$awkscript"
31ce77fa 439 `$initialize_fullname
2af06121 440esac
b86e8615
PE
441
442
443# Function to print a single log line.
444# We don't use awk functions, to stay compatible with old awk versions.
d74a9f24 445# `Log' is the log message (with \n replaced by \001).
b19075d1 446# `files' contains the affected files.
b86e8615
PE
447printlogline='{
448
449 # Following the GNU coding standards, rewrite
450 # * file: (function): comment
451 # to
452 # * file (function): comment
453 if (Log ~ /^\([^)]*\): /) {
454 i = index(Log, ")")
455 files = files " " substr(Log, 1, i)
456 Log = substr(Log, i+3)
457 }
458
459 # If "label: comment" is too long, break the line after the ":".
460 sep = " "
d74a9f24 461 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, SOH)) sep = "\n" indent_string
b86e8615
PE
462
463 # Print the label.
4ca2c4b4 464 printf "%s*%s:", indent_string, files
b86e8615 465
d74a9f24
PE
466 # Print each line of the log, transliterating \001 to \n.
467 while ((i = index(Log, SOH)) != 0) {
1f19b52b 468 logline = substr(Log, 1, i-1)
44ef8c25 469 if (logline ~ /[^'"$tab"' ]/) {
1f19b52b
PE
470 printf "%s%s\n", sep, logline
471 } else {
472 print ""
473 }
4ca2c4b4 474 sep = indent_string
b86e8615
PE
475 Log = substr(Log, i+1)
476 }
b86e8615
PE
477}'
478
7b8b6c7a
EN
479# Pattern to match the `revision' line of rlog output.
480rlog_revision_pattern='^revision [0-9]+\.[0-9]+(\.[0-9]+\.[0-9]+)*(['"$tab"' ]+locked by: [^'"$tab"' $,.0-9:;@]*[^'"$tab"' $,:;@][^'"$tab"' $,.0-9:;@]*;)?['"$tab"' ]*$'
481
31ce77fa
PE
482case $hostname in
483'')
484 hostname=`(
485 hostname || uname -n || uuname -l || cat /etc/whoami
486 ) 2>/dev/null` || {
487 echo >&2 "$0: cannot deduce hostname"
488 exit 1
489 }
e852d58d
PE
490
491 case $hostname in
492 *.*) ;;
493 *)
494 domainname=`(domainname) 2>/dev/null` &&
495 case $domainname in
496 *.*) hostname=$hostname.$domainname
497 esac
498 esac
31ce77fa 499esac
b86e8615
PE
500
501
502# Process the rlog output, generating ChangeLog style entries.
503
504# First, reformat the rlog output so that each line contains one log entry.
d74a9f24 505# Transliterate \n to \001 so that multiline entries fit on a single line.
b86e8615 506# Discard irrelevant rlog output.
44ef8c25
PE
507$AWK <$rlogout '
508 BEGIN { repository = "'"$repository"'" }
509 /^RCS file:/ {
510 if (repository != "") {
511 filename = $3
512 if (substr(filename, 1, length(repository) + 1) == repository "/") {
513 filename = substr(filename, length(repository) + 2)
514 }
515 if (filename ~ /,v$/) {
516 filename = substr(filename, 1, length(filename) - 2)
517 }
7e02c4dd
PE
518 if (filename ~ /(^|\/)Attic\/[^\/]*$/) {
519 i = length(filename)
520 while (substr(filename, i, 1) != "/") i--
521 filename = substr(filename, 1, i - 6) substr(filename, i + 1)
522 }
44ef8c25 523 }
7b8b6c7a 524 rev = "?"
44ef8c25
PE
525 }
526 /^Working file:/ { if (repository == "") filename = $3 }
7b8b6c7a 527 /'"$rlog_revision_pattern"'/, /^(-----------*|===========*)$/ {
7e46d459
PE
528 line = $0
529 if (line ~ /'"$rlog_revision_pattern"'/) {
7b8b6c7a
EN
530 rev = $2
531 next
532 }
7e46d459 533 if (line ~ /^date: [0-9][- +\/0-9:]*;/) {
7a833f0b 534 date = $2
7b8b6c7a
EN
535 if (date ~ /\//) {
536 # This is a traditional RCS format date YYYY/MM/DD.
537 # Replace "/"s with "-"s to get ISO format.
7a833f0b 538 newdate = ""
7b8b6c7a
EN
539 while ((i = index(date, "/")) != 0) {
540 newdate = newdate substr(date, 1, i-1) "-"
7a833f0b
PE
541 date = substr(date, i+1)
542 }
543 date = newdate date
544 }
7b8b6c7a 545 time = substr($3, 1, length($3) - 1)
b86e8615 546 author = substr($5, 1, length($5)-1)
d74a9f24 547 printf "%s %s %s %s %s %c", filename, rev, date, time, author, 1
7b8b6c7a 548 rev = "?"
b86e8615
PE
549 next
550 }
7e46d459
PE
551 if (line ~ /^branches: /) { next }
552 if (line ~ /^(-----------*|===========*)$/) { print ""; next }
553 if (line == "Initial revision" || line ~ /^file .+ was initially added on branch .+\.$/) {
554 line = "New file."
555 }
556 printf "%s%c", line, 1
b86e8615
PE
557 }
558' |
559
560# Now each line is of the form
d74a9f24
PE
561# FILENAME REVISION YYYY-MM-DD HH:MM:SS[+-TIMEZONE] AUTHOR \001LOG
562# where \001 stands for a carriage return,
563# and each line of the log is terminated by \001 instead of \n.
2af06121 564# Sort the log entries, first by date+time (in reverse order),
7b8b6c7a
EN
565# then by author, then by log entry, and finally by file name and revision
566# (just in case).
567sort +2 -4r +4 +0 |
b86e8615
PE
568
569# Finally, reformat the sorted log entries.
44ef8c25 570$AWK '
b86e8615 571 BEGIN {
7b8b6c7a
EN
572 logTZ = "'"$logTZ"'"
573 revision = "'"$revision"'"
574
d74a9f24
PE
575 # Some awk variants do not understand "\001", so we have to
576 # put the char directly in the file.
577 SOH="\ 1" # <-- There is a single SOH (octal code 001) here.
b86e8615 578
31ce77fa 579 # Initialize the fullname and mailaddr associative arrays.
b86e8615 580 '"$initialize_fullname"'
31ce77fa 581 '"$initialize_mailaddr"'
b86e8615 582
4ca2c4b4
PE
583 # Initialize indent string.
584 indent_string = ""
585 i = '"$indent"'
586 if (0 < '"$tabwidth"')
587 for (; '"$tabwidth"' <= i; i -= '"$tabwidth"')
588 indent_string = indent_string "\t"
589 while (1 <= i--)
590 indent_string = indent_string " "
b86e8615 591 }
19ed208b 592
b86e8615 593 {
d74a9f24 594 newlog = substr($0, 1 + index($0, SOH))
19ed208b
PE
595
596 # Ignore log entries prefixed by "#".
597 if (newlog ~ /^#/) { next }
598
7b8b6c7a 599 if (Log != newlog || date != $3 || author != $5) {
b19075d1 600
b86e8615 601 # The previous log and this log differ.
b19075d1
PE
602
603 # Print the old log.
b86e8615
PE
604 if (date != "") '"$printlogline"'
605
b19075d1
PE
606 # Logs that begin with "{clumpname} " should be grouped together,
607 # and the clumpname should be removed.
608 # Extract the new clumpname from the log header,
609 # and use it to decide whether to output a blank line.
610 newclumpname = ""
611 sep = "\n"
23a227f7 612 if (date == "") sep = ""
44ef8c25 613 if (newlog ~ /^\{[^'"$tab"' }]*}['"$tab"' ]/) {
b19075d1
PE
614 i = index(newlog, "}")
615 newclumpname = substr(newlog, 1, i)
44ef8c25 616 while (substr(newlog, i+1) ~ /^['"$tab"' ]/) i++
b19075d1
PE
617 newlog = substr(newlog, i+1)
618 if (clumpname == newclumpname) sep = ""
619 }
620 printf sep
621 clumpname = newclumpname
622
b86e8615
PE
623 # Get ready for the next log.
624 Log = newlog
4ca2c4b4
PE
625 if (files != "")
626 for (i in filesknown)
627 filesknown[i] = 0
b86e8615
PE
628 files = ""
629 }
7b8b6c7a 630 if (date != $3 || author != $5) {
b86e8615
PE
631 # The previous date+author and this date+author differ.
632 # Print the new one.
7b8b6c7a
EN
633 date = $3
634 time = $4
635 author = $5
636
637 zone = ""
638 if (logTZ && ((i = index(time, "-")) || (i = index(time, "+"))))
639 zone = " " substr(time, i)
640
641 # Print "date[ timezone] fullname <email address>".
31ce77fa
PE
642 # Get fullname and email address from associative arrays;
643 # default to author and author@hostname if not in arrays.
4ca2c4b4 644 if (fullname[author])
31ce77fa
PE
645 auth = fullname[author]
646 else
647 auth = author
7b8b6c7a 648 printf "%s%s %s ", date, zone, auth
31ce77fa 649 if (mailaddr[author])
9fa6ed8f 650 printf "<%s>\n\n", mailaddr[author]
4ca2c4b4 651 else
9fa6ed8f 652 printf "<%s@%s>\n\n", author, "'"$hostname"'"
4ca2c4b4
PE
653 }
654 if (! filesknown[$1]) {
655 filesknown[$1] = 1
b19075d1
PE
656 if (files == "") files = " " $1
657 else files = files ", " $1
7b8b6c7a 658 if (revision && $2 != "?") files = files " " $2
b86e8615 659 }
b86e8615
PE
660 }
661 END {
662 # Print the last log.
b19075d1
PE
663 if (date != "") {
664 '"$printlogline"'
665 printf "\n"
666 }
b86e8615
PE
667 }
668' &&
669
670
671# Exit successfully.
672
44ef8c25 673exec rm -f $llogout $rlogout
7b8b6c7a
EN
674
675# Local Variables:
676# tab-width:4
677# End: