annotate lib-src/rcs2log @ 535:4b75abb93479

Don't munge $* when getting date from ChangeLog.
author Paul Eggert <eggert@twinsun.com>
date Wed, 05 Feb 1992 17:25:10 +0000
parents 6f7abc0e1f10
children efa0c124c178
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
1 #!/bin/sh
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
2
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
3 # RCS to ChangeLog generator
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
4
535
4b75abb93479 Don't munge $* when getting date from ChangeLog.
Paul Eggert <eggert@twinsun.com>
parents: 534
diff changeset
5 # $Id: rcs2clog,v 1.2 1992/02/05 04:31:18 eggert Exp eggert $
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
6
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
7 # Generate a change log prefix from RCS/* and the existing ChangeLog (if any).
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
8 # Output the new prefix to standard output.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
9 # You can edit this prefix by hand, and then prepend it to ChangeLog.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
10
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
11
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
12 # Parse options.
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
13
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
14 # defaults
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
15 indent=8 # indent of log line
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
16 length=79 # suggested max width of log line
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
17 tabwidth=8 # width of horizontal tab
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
18
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
19 while :
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
20 do
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
21 case $1 in
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
22 -i) indent=${2?};;
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
23 -l) length=${2?};;
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
24 -t) tabwidth=${2?};;
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
25 -*) echo >&2 "$0: usage: $0 [-i indent] [-l length] [-t tabwidth] [file ...]"
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
26 exit 1;;
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
27 *) break
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
28 esac
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
29 shift; shift
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
30 done
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
31
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
32
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
33 # Log into $rlogout the revisions checked in since the first ChangeLog entry.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
34
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
35 datearg=-d'>1970'
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
36 if test -s ChangeLog
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
37 then
535
4b75abb93479 Don't munge $* when getting date from ChangeLog.
Paul Eggert <eggert@twinsun.com>
parents: 534
diff changeset
38 e='s/^\(...\) \(...\) \(..\) \(..:..:..\) \(....\) .*/\1 \2 \3 \4 \5/p; 1q'
4b75abb93479 Don't munge $* when getting date from ChangeLog.
Paul Eggert <eggert@twinsun.com>
parents: 534
diff changeset
39 date=`sed -n "$e" <ChangeLog` || exit
4b75abb93479 Don't munge $* when getting date from ChangeLog.
Paul Eggert <eggert@twinsun.com>
parents: 534
diff changeset
40 case $date in
4b75abb93479 Don't munge $* when getting date from ChangeLog.
Paul Eggert <eggert@twinsun.com>
parents: 534
diff changeset
41 ?*) datearg="-d>$date"
4b75abb93479 Don't munge $* when getting date from ChangeLog.
Paul Eggert <eggert@twinsun.com>
parents: 534
diff changeset
42 esac
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
43 fi
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
44
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
45 rlogout=/tmp/chg$$
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
46 trap exit 1 2 13 15
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
47 trap 'rm -f $rlogout; exit 1' 0
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
48
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
49 case $# in
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
50 0) set RCS/*
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
51 esac
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
52
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
53 rlog "$datearg" "$@" >$rlogout || exit
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
54
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
55
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
56 # Get the full name of each author the logs mention, and set initialize_fullname
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
57 # to awk code that initializes the `fullname' awk associative array.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
58 # Warning: foreign authors (i.e. not known in the passwd file) are mishandled;
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
59 # you have to fix the resulting output by hand.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
60
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
61 authors=`
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
62 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 |
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
63 sort -u
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
64 `
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
65
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
66 initialize_fullname=
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
67 for author in $authors
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
68 do
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
69 fullname=`
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
70 (grep "^$author:" /etc/passwd || ypmatch "$author" passwd) |
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
71 sed -n 's/^[^:]*:[^:]*:[^:]*:[^:]*:\([^,:]*\).*$/\1/;p;q'
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
72 `
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
73 case $fullname in
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
74 *\&*)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
75 User=`
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
76 expr " $author" : ' \(.\)' |
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
77 tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
78 ``
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
79 expr " $author" : ' .\(.*\)'
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
80 `
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
81 fullname=`echo "$fullname" | sed "s:&:$User:"`
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
82 esac
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
83 case $fullname in
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
84 ?*)
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
85 initialize_fullname="$initialize_fullname
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
86 fullname[\"$author\"] = \"$fullname\""
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
87 esac
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
88 done
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
89
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
90
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
91 # Function to print a single log line.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
92 # We don't use awk functions, to stay compatible with old awk versions.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
93 # `Log' is the log message (with \n replaced by \r).
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
94 # `files' contains the affected files (each preceded by a space).
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
95 printlogline='{
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
96
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
97 # Following the GNU coding standards, rewrite
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
98 # * file: (function): comment
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
99 # to
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
100 # * file (function): comment
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
101 if (Log ~ /^\([^)]*\): /) {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
102 i = index(Log, ")")
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
103 files = files " " substr(Log, 1, i)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
104 Log = substr(Log, i+3)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
105 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
106
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
107 # If "label: comment" is too long, break the line after the ":".
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
108 sep = " "
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
109 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, "\r")) sep = "\n" indent_string
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
110
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
111 # Print the label.
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
112 printf "%s*%s:", indent_string, files
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
113
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
114 # Print each line of the log, transliterating \r to \n.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
115 while ((i = index(Log, "\r")) != 0) {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
116 printf "%s%s\n", sep, substr(Log, 1, i-1)
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
117 sep = indent_string
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
118 Log = substr(Log, i+1)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
119 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
120
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
121 printf "\n"
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
122 }'
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
123
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
124 hostname=`(
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
125 hostname || cat /etc/whoami || uuname -l || uname -n
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
126 ) 2>/dev/null` || {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
127 echo >&2 "$0: cannot deduce hostname"
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
128 exit 1
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
129 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
130
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
131
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
132 # Process the rlog output, generating ChangeLog style entries.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
133
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
134 # First, reformat the rlog output so that each line contains one log entry.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
135 # Transliterate \n to \r so that multiline entries fit on a single line.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
136 # Discard irrelevant rlog output.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
137 awk <$rlogout '
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
138 /^Working file:/ { filename = $3 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
139 /^date: /, /^(-----------*|===========*)$/ {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
140 if ($0 ~ /^branches: /) { next }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
141 if ($0 ~ /^date: [0-9][ /0-9:]*;/) {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
142 time = substr($3, 1, length($3)-1)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
143 author = substr($5, 1, length($5)-1)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
144 printf "%s %s %s %s \r", filename, $2, time, author
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
145 next
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
146 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
147 if ($0 ~ /^(-----------*|===========*)/) { print ""; next }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
148 { printf "%s\r", $0 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
149 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
150 ' |
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
151
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
152 # Now each line is of the form
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
153 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
154 # where \r stands for a carriage return,
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
155 # and each line of the log is terminated by \r instead of \n.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
156 # Sort the log entries, first by date (in reverse order),
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
157 # then by author, then by log entry, and finally by file name (just in case).
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
158 sort +1 -2r +3 +0 |
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
159
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
160 # Finally, reformat the sorted log entries.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
161 awk '
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
162 BEGIN {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
163
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
164 # Initialize the fullname associative array.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
165 '"$initialize_fullname"'
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
166
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
167 # Initialize indent string.
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
168 indent_string = ""
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
169 i = '"$indent"'
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
170 if (0 < '"$tabwidth"')
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
171 for (; '"$tabwidth"' <= i; i -= '"$tabwidth"')
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
172 indent_string = indent_string "\t"
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
173 while (1 <= i--)
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
174 indent_string = indent_string " "
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
175
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
176 # Set up date conversion tables.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
177 # RCS uses a nice, clean, sortable format,
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
178 # but ChangeLog wants the traditional, ugly ctime format.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
179
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
180 # January 1, 0 AD (Gregorian) was Saturday = 6
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
181 EPOCH_WEEKDAY = 6
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
182 # Of course, there was no 0 AD, but the algorithm works anyway.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
183
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
184 w[0]="Sun"; w[1]="Mon"; w[2]="Tue"; w[3]="Wed"
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
185 w[4]="Thu"; w[5]="Fri"; w[6]="Sat"
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
186
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
187 m[0]="Jan"; m[1]="Feb"; m[2]="Mar"
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
188 m[3]="Apr"; m[4]="May"; m[5]="Jun"
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
189 m[6]="Jul"; m[7]="Aug"; m[8]="Sep"
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
190 m[9]="Oct"; m[10]="Nov"; m[11]="Dec"
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
191
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
192 # days in non-leap year thus far, indexed by month (0-12)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
193 mo[0]=0; mo[1]=31; mo[2]=59; mo[3]=90
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
194 mo[4]=120; mo[5]=151; mo[6]=181; mo[7]=212
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
195 mo[8]=243; mo[9]=273; mo[10]=304; mo[11]=334
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
196 mo[12]=365
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
197 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
198 {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
199 newlog = substr($0, 1 + index($0, "\r"))
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
200 if (Log != newlog || date != $2 || author != $4) {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
201 # The previous log and this log differ.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
202 # Print the old one.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
203 if (date != "") '"$printlogline"'
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
204
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
205 # Get ready for the next log.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
206 Log = newlog
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
207 if (files != "")
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
208 for (i in filesknown)
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
209 filesknown[i] = 0
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
210 files = ""
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
211 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
212 if (date != $2 || author != $4) {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
213 # The previous date+author and this date+author differ.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
214 # Print the new one.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
215 date = $2
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
216 author = $4
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
217
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
218 # Convert nice RCS date like "1992/01/03 00:03:44"
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
219 # into ugly ctime date like "Fri Jan 3 00:03:44 1992".
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
220 # Calculate day of week from Gregorian calendar.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
221 i = index($2, "/")
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
222 year = substr($2, 1, i-1)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
223 monthday = substr($2, i+1)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
224 i = index(monthday, "/")
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
225 month = substr(monthday, 1, i-1)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
226 day = substr(monthday, i+1)
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
227 leap = 0
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
228 if (2 <= month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
229 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
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
230
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
231 # Print "date fullname (email address)" if the fullname is known;
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
232 # print "date author" otherwise.
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
233 # Get the fullname from the associative array.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
234 # The email address is just author@thishostname.
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
235 printf "%s %s %2d %s %d ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
236 if (fullname[author])
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
237 printf "%s (%s@%s)\n\n", fullname[author], author, "'"$hostname"'"
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
238 else
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
239 printf "%s\n\n", author
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
240 }
534
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
241 if (! filesknown[$1]) {
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
242 filesknown[$1] = 1
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
243 files = files " " $1
6f7abc0e1f10 Add -i, -l, -t.
Paul Eggert <eggert@twinsun.com>
parents: 527
diff changeset
244 }
527
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
245 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
246 END {
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
247 # Print the last log.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
248 if (date != "") '"$printlogline"'
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
249 }
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
250 ' &&
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
251
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
252
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
253 # Exit successfully.
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
254
703fd28f892d Initial revision
Paul Eggert <eggert@twinsun.com>
parents:
diff changeset
255 exec rm -f $rlogout