aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
Diffstat (limited to 'lib-src')
-rwxr-xr-xlib-src/rcs2log95
1 files changed, 66 insertions, 29 deletions
diff --git a/lib-src/rcs2log b/lib-src/rcs2log
index 4f3f56d10e7..1ea628afb03 100755
--- a/lib-src/rcs2log
+++ b/lib-src/rcs2log
@@ -2,7 +2,7 @@
2 2
3# RCS to ChangeLog generator 3# RCS to ChangeLog generator
4 4
5# Generate a change log prefix from RCS/* and the existing ChangeLog (if any). 5# Generate a change log prefix from RCS files and the ChangeLog (if any).
6# Output the new prefix to standard output. 6# Output the new prefix to standard output.
7# You can edit this prefix by hand, and then prepend it to ChangeLog. 7# You can edit this prefix by hand, and then prepend it to ChangeLog.
8 8
@@ -12,7 +12,7 @@
12 12
13# Author: Paul Eggert <eggert@twinsun.com> 13# Author: Paul Eggert <eggert@twinsun.com>
14 14
15# $Id: rcs2log,v 1.13 1993/08/09 22:06:00 eggert Exp eggert $ 15# $Id: rcs2log,v 1.13.1.1 1993/09/24 00:54:33 eggert Exp $
16 16
17# Copyright 1992, 1993 Free Software Foundation, Inc. 17# Copyright 1992, 1993 Free Software Foundation, Inc.
18 18
@@ -36,17 +36,41 @@ nl='
36# Parse options. 36# Parse options.
37 37
38# defaults 38# defaults
39: ${TMPDIR=/tmp}
40hostname= # name of local host (if empty, will deduce it later)
39indent=8 # indent of log line 41indent=8 # indent of log line
42initialize_fullname= # awk assignments to set up fullname array
43initialize_mailaddr= # awk assignments to set up mailaddr array
40length=79 # suggested max width of log line 44length=79 # suggested max width of log line
45logins= # login names for people we know fullnames and mailaddresses of
46loginsout= # temporary file holding sorted logins
47rlog_options= # options to pass to rlog
41tabwidth=8 # width of horizontal tab 48tabwidth=8 # width of horizontal tab
42 49
43while : 50while :
44do 51do
45 case $1 in 52 case $1 in
46 -i) indent=${2?};; 53 -i) indent=${2?};;
54 -h) hostname=${2?};;
47 -l) length=${2?};; 55 -l) length=${2?};;
56 -n) logins=$logins$nl${2?}
57 loginsout=$TMPDIR/rcs2log$$l
58 case $2${3?}${4?} in
59 *\"* | *\\* | *"$nl"*)
60 echo >&2 "$0: -n '$2' '$3' '$4': special characters not allowed"
61 exit 1
62 esac
63 initialize_fullname="$initialize_fullname
64 fullname[\"$2\"] = \"$3\""
65 initialize_mailaddr="$initialize_mailaddr
66 mailaddr[\"$2\"] = \"$4\""
67 shift; shift;;
68 -r) rlog_options=$rlog_options$nl${2?};;
48 -t) tabwidth=${2?};; 69 -t) tabwidth=${2?};;
49 -*) echo >&2 "$0: usage: $0 [-i indent] [-l length] [-t tabwidth] [file ...]" 70 -*) echo >&2 "$0: usage: $0 [options] [file ...]
71Options:
72 [-h hostname] [-i indent] [-l length] [-n login fullname mailaddr]...
73 [-r rlog_option]... [-t tabwidth]"
50 exit 1;; 74 exit 1;;
51 *) break 75 *) break
52 esac 76 esac
@@ -120,13 +144,13 @@ datearg="-d>$date"
120case $# in 144case $# in
1210) 1450)
122 files= 146 files=
123 for file in RCS/.* RCS/* 147 for file in RCS/.* RCS/* .*,v *,v
124 do 148 do
125 case $file in 149 case $file in
126 RCS/. | RCS/..) ;; 150 RCS/. | RCS/..) continue;;
127 RCS/.\* | RCS/\*) test -f "$file" && files=$files$nl$file;; 151 RCS/.\* | RCS/\* | .\*,v | \*,v) test -f "$file" || continue
128 *) files=$files$nl$file
129 esac 152 esac
153 files=$files$nl$file
130 done 154 done
131 case $files in 155 case $files in
132 '') exit 0 156 '') exit 0
@@ -137,11 +161,11 @@ case $# in
137 IFS=$oldIFS 161 IFS=$oldIFS
138esac 162esac
139 163
140rlogout=/tmp/chg$$ 164rlogout=$TMPDIR/rcs2log$$r
141trap exit 1 2 13 15 165trap exit 1 2 13 15
142trap 'rm -f $rlogout; exit 1' 0 166trap "rm -f $loginsout $rlogout; exit 1" 0
143 167
144rlog "$datearg" "$@" >$rlogout || exit 168rlog "$datearg" $rlog_options "$@" >$rlogout || exit
145 169
146 170
147# Get the full name of each author the logs mention, and set initialize_fullname 171# Get the full name of each author the logs mention, and set initialize_fullname
@@ -149,10 +173,17 @@ rlog "$datearg" "$@" >$rlogout || exit
149# Warning: foreign authors (i.e. not known in the passwd file) are mishandled; 173# Warning: foreign authors (i.e. not known in the passwd file) are mishandled;
150# you have to fix the resulting output by hand. 174# you have to fix the resulting output by hand.
151 175
152initialize_fullname= 176case $loginsout in
177?*) sort -u -o $loginsout <<EOF || exit
178$logins
179EOF
180esac
153authors=` 181authors=`
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 | 182 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 183 case $loginsout in
184 '') sort -u;;
185 ?*) sort -u | comm -23 - $loginsout
186 esac
156` 187`
157case $authors in 188case $authors in
158?*) 189?*)
@@ -163,7 +194,6 @@ case $authors in
163 author[\"$author\"] = 1 194 author[\"$author\"] = 1
164 " 195 "
165 done 196 done
166
167 awkscript=' 197 awkscript='
168 BEGIN { 198 BEGIN {
169 alphabet = "abcdefghijklmnopqrstuvwxyz" 199 alphabet = "abcdefghijklmnopqrstuvwxyz"
@@ -200,7 +230,7 @@ case $authors in
200 initialize_fullname=` 230 initialize_fullname=`
201 (cat /etc/passwd; ypmatch $authors passwd) 2>/dev/null | 231 (cat /etc/passwd; ypmatch $authors passwd) 2>/dev/null |
202 awk -F: "$awkscript" 232 awk -F: "$awkscript"
203 ` 233 `$initialize_fullname
204esac 234esac
205 235
206 236
@@ -235,12 +265,15 @@ printlogline='{
235 } 265 }
236}' 266}'
237 267
238hostname=`( 268case $hostname in
239 hostname || cat /etc/whoami || uuname -l || uname -n 269'')
240) 2>/dev/null` || { 270 hostname=`(
241 echo >&2 "$0: cannot deduce hostname" 271 hostname || uname -n || uuname -l || cat /etc/whoami
242 exit 1 272 ) 2>/dev/null` || {
243} 273 echo >&2 "$0: cannot deduce hostname"
274 exit 1
275 }
276esac
244 277
245 278
246# Process the rlog output, generating ChangeLog style entries. 279# Process the rlog output, generating ChangeLog style entries.
@@ -278,8 +311,9 @@ awk '
278 # put a carriage return directly in the file. 311 # put a carriage return directly in the file.
279 CR=" " # <-- There is a single CR between the " chars here. 312 CR=" " # <-- There is a single CR between the " chars here.
280 313
281 # Initialize the fullname associative array. 314 # Initialize the fullname and mailaddr associative arrays.
282 '"$initialize_fullname"' 315 '"$initialize_fullname"'
316 '"$initialize_mailaddr"'
283 317
284 # Initialize indent string. 318 # Initialize indent string.
285 indent_string = "" 319 indent_string = ""
@@ -360,15 +394,18 @@ awk '
360 if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1 394 if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1
361 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 395 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
362 396
363 # Print "date fullname (email address)" if the fullname is known; 397 # Print "date fullname (email address)".
364 # print "date author" otherwise. 398 # Get fullname and email address from associative arrays;
365 # Get the fullname from the associative array. 399 # default to author and author@hostname if not in arrays.
366 # The email address is just author@thishostname.
367 printf "%s %s %2d %s %d ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year
368 if (fullname[author]) 400 if (fullname[author])
369 printf "%s (%s@%s)\n\n", fullname[author], author, "'"$hostname"'" 401 auth = fullname[author]
402 else
403 auth = author
404 printf "%s %s %2d %s %d %s ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year, auth
405 if (mailaddr[author])
406 printf "(%s)\n\n", mailaddr[author]
370 else 407 else
371 printf "%s\n\n", author 408 printf "(%s@%s)\n\n", author, "'"$hostname"'"
372 } 409 }
373 if (! filesknown[$1]) { 410 if (! filesknown[$1]) {
374 filesknown[$1] = 1 411 filesknown[$1] = 1
@@ -388,4 +425,4 @@ awk '
388 425
389# Exit successfully. 426# Exit successfully.
390 427
391exec rm -f $rlogout 428exec rm -f $loginsout $rlogout