comparison lib-src/rcs2log @ 534:6f7abc0e1f10

Add -i, -l, -t.
author Paul Eggert <eggert@twinsun.com>
date Wed, 05 Feb 1992 04:31:18 +0000
parents 703fd28f892d
children 4b75abb93479
comparison
equal deleted inserted replaced
533:31e638e8fe93 534:6f7abc0e1f10
1 #!/bin/sh 1 #!/bin/sh
2 2
3 # RCS to ChangeLog generator 3 # RCS to ChangeLog generator
4 4
5 # $Id$ 5 # $Id: rcs2clog,v 1.2 1992/02/05 04:29:40 eggert Exp $
6 6
7 # Generate a change log prefix from RCS/* and the existing ChangeLog (if any). 7 # Generate a change log prefix from RCS/* and the existing ChangeLog (if any).
8 # Output the new prefix to standard output. 8 # Output the new prefix to standard output.
9 # You can edit this prefix by hand, and then prepend it to ChangeLog. 9 # You can edit this prefix by hand, and then prepend it to ChangeLog.
10
11
12 # Parse options.
13
14 # defaults
15 indent=8 # indent of log line
16 length=79 # suggested max width of log line
17 tabwidth=8 # width of horizontal tab
18
19 while :
20 do
21 case $1 in
22 -i) indent=${2?};;
23 -l) length=${2?};;
24 -t) tabwidth=${2?};;
25 -*) echo >&2 "$0: usage: $0 [-i indent] [-l length] [-t tabwidth] [file ...]"
26 exit 1;;
27 *) break
28 esac
29 shift; shift
30 done
10 31
11 32
12 # Log into $rlogout the revisions checked in since the first ChangeLog entry. 33 # Log into $rlogout the revisions checked in since the first ChangeLog entry.
13 34
14 datearg=-d'>1970' 35 datearg=-d'>1970'
21 42
22 rlogout=/tmp/chg$$ 43 rlogout=/tmp/chg$$
23 trap exit 1 2 13 15 44 trap exit 1 2 13 15
24 trap 'rm -f $rlogout; exit 1' 0 45 trap 'rm -f $rlogout; exit 1' 0
25 46
26 rlog "$datearg" RCS/* >$rlogout || exit 47 case $# in
48 0) set RCS/*
49 esac
50
51 rlog "$datearg" "$@" >$rlogout || exit
27 52
28 53
29 # Get the full name of each author the logs mention, and set initialize_fullname 54 # Get the full name of each author the logs mention, and set initialize_fullname
30 # to awk code that initializes the `fullname' awk associative array. 55 # to awk code that initializes the `fullname' awk associative array.
31 # Warning: foreign authors (i.e. not known in the passwd file) are mishandled; 56 # Warning: foreign authors (i.e. not known in the passwd file) are mishandled;
51 `` 76 ``
52 expr " $author" : ' .\(.*\)' 77 expr " $author" : ' .\(.*\)'
53 ` 78 `
54 fullname=`echo "$fullname" | sed "s:&:$User:"` 79 fullname=`echo "$fullname" | sed "s:&:$User:"`
55 esac 80 esac
56 initialize_fullname="$initialize_fullname 81 case $fullname in
57 fullname[\"$author\"] = \"$fullname\"" 82 ?*)
83 initialize_fullname="$initialize_fullname
84 fullname[\"$author\"] = \"$fullname\""
85 esac
58 done 86 done
59 87
60 88
61 # Function to print a single log line. 89 # Function to print a single log line.
62 # We don't use awk functions, to stay compatible with old awk versions. 90 # We don't use awk functions, to stay compatible with old awk versions.
63 # `Log' is the log message (with \n replaced by \r). 91 # `Log' is the log message (with \n replaced by \r).
64 # `files' contains the affected files (each preceded by a space). 92 # `files' contains the affected files (each preceded by a space).
65 LINE_LENGTH=79 # suggested max width of log line
66 LOG_INDENT='\t' # what to indent each log entry with
67 LOG_INDENT_LENGTH=8 # print length of "LOG_INDENT"
68 printlogline='{ 93 printlogline='{
69 94
70 # Following the GNU coding standards, rewrite 95 # Following the GNU coding standards, rewrite
71 # * file: (function): comment 96 # * file: (function): comment
72 # to 97 # to
77 Log = substr(Log, i+3) 102 Log = substr(Log, i+3)
78 } 103 }
79 104
80 # If "label: comment" is too long, break the line after the ":". 105 # If "label: comment" is too long, break the line after the ":".
81 sep = " " 106 sep = " "
82 if ('"$LINE_LENGTH"' <= '"$LOG_INDENT_LENGTH"' + 1 + length(files) + index(Log, "\r")) sep = "\n'"$LOG_INDENT"'" 107 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, "\r")) sep = "\n" indent_string
83 108
84 # Print the label. 109 # Print the label.
85 printf "'"$LOG_INDENT"'*%s:", files 110 printf "%s*%s:", indent_string, files
86 111
87 # Print each line of the log, transliterating \r to \n. 112 # Print each line of the log, transliterating \r to \n.
88 while ((i = index(Log, "\r")) != 0) { 113 while ((i = index(Log, "\r")) != 0) {
89 printf "%s%s\n", sep, substr(Log, 1, i-1) 114 printf "%s%s\n", sep, substr(Log, 1, i-1)
90 sep = "'"$LOG_INDENT"'" 115 sep = indent_string
91 Log = substr(Log, i+1) 116 Log = substr(Log, i+1)
92 } 117 }
93 118
94 printf "\n" 119 printf "\n"
95 }' 120 }'
135 BEGIN { 160 BEGIN {
136 161
137 # Initialize the fullname associative array. 162 # Initialize the fullname associative array.
138 '"$initialize_fullname"' 163 '"$initialize_fullname"'
139 164
165 # Initialize indent string.
166 indent_string = ""
167 i = '"$indent"'
168 if (0 < '"$tabwidth"')
169 for (; '"$tabwidth"' <= i; i -= '"$tabwidth"')
170 indent_string = indent_string "\t"
171 while (1 <= i--)
172 indent_string = indent_string " "
173
140 # Set up date conversion tables. 174 # Set up date conversion tables.
141 # RCS uses a nice, clean, sortable format, 175 # RCS uses a nice, clean, sortable format,
142 # but ChangeLog wants the traditional, ugly ctime format. 176 # but ChangeLog wants the traditional, ugly ctime format.
143 177
144 # January 1, 0 AD (Gregorian) was Saturday = 6 178 # January 1, 0 AD (Gregorian) was Saturday = 6
166 # Print the old one. 200 # Print the old one.
167 if (date != "") '"$printlogline"' 201 if (date != "") '"$printlogline"'
168 202
169 # Get ready for the next log. 203 # Get ready for the next log.
170 Log = newlog 204 Log = newlog
205 if (files != "")
206 for (i in filesknown)
207 filesknown[i] = 0
171 files = "" 208 files = ""
172 } 209 }
173 if (date != $2 || author != $4) { 210 if (date != $2 || author != $4) {
174 # The previous date+author and this date+author differ. 211 # The previous date+author and this date+author differ.
175 # Print the new one. 212 # Print the new one.
187 day = substr(monthday, i+1) 224 day = substr(monthday, i+1)
188 leap = 0 225 leap = 0
189 if (2 <= month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1 226 if (2 <= month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1
190 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 227 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
191 228
192 # Print "date fullname (email address)". 229 # Print "date fullname (email address)" if the fullname is known;
230 # print "date author" otherwise.
193 # Get the fullname from the associative array. 231 # Get the fullname from the associative array.
194 # The email address is just author@thishostname. 232 # The email address is just author@thishostname.
195 printf "%s %s %2d %s %d %s (%s@%s)\n\n", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year, fullname[author], author, "'"$hostname"'" 233 printf "%s %s %2d %s %d ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year
196 } 234 if (fullname[author])
197 files = files " " $1 235 printf "%s (%s@%s)\n\n", fullname[author], author, "'"$hostname"'"
236 else
237 printf "%s\n\n", author
238 }
239 if (! filesknown[$1]) {
240 filesknown[$1] = 1
241 files = files " " $1
242 }
198 } 243 }
199 END { 244 END {
200 # Print the last log. 245 # Print the last log.
201 if (date != "") '"$printlogline"' 246 if (date != "") '"$printlogline"'
202 } 247 }