Mercurial > emacs
comparison lib-src/rcs2log @ 4783:7c75802f5a8b
Add -h, -n, -r options.
By default, look for *,v files as well as RCS/*,v files.
Use $TMPDIR (default /tmp) instead of /tmp.
author | Paul Eggert <eggert@twinsun.com> |
---|---|
date | Fri, 24 Sep 1993 01:03:32 +0000 |
parents | 0f5dd4938af9 |
children | 5b4f9564bfaf |
comparison
equal
deleted
inserted
replaced
4782:73203b90eb26 | 4783:7c75802f5a8b |
---|---|
1 #!/bin/sh | 1 #!/bin/sh |
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 |
9 # Ignore log entries that start with `#'. | 9 # Ignore log entries that start with `#'. |
10 # Clump together log entries that start with `{topic} ', | 10 # Clump together log entries that start with `{topic} ', |
11 # where `topic' contains neither white space nor `}'. | 11 # where `topic' contains neither white space nor `}'. |
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 |
19 # This program is free software; you can redistribute it and/or modify | 19 # This program is free software; you can redistribute it and/or modify |
20 # it under the terms of the GNU General Public License as published by | 20 # it under the terms of the GNU General Public License as published by |
34 ' | 34 ' |
35 | 35 |
36 # Parse options. | 36 # Parse options. |
37 | 37 |
38 # defaults | 38 # defaults |
39 : ${TMPDIR=/tmp} | |
40 hostname= # name of local host (if empty, will deduce it later) | |
39 indent=8 # indent of log line | 41 indent=8 # indent of log line |
42 initialize_fullname= # awk assignments to set up fullname array | |
43 initialize_mailaddr= # awk assignments to set up mailaddr array | |
40 length=79 # suggested max width of log line | 44 length=79 # suggested max width of log line |
45 logins= # login names for people we know fullnames and mailaddresses of | |
46 loginsout= # temporary file holding sorted logins | |
47 rlog_options= # options to pass to rlog | |
41 tabwidth=8 # width of horizontal tab | 48 tabwidth=8 # width of horizontal tab |
42 | 49 |
43 while : | 50 while : |
44 do | 51 do |
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 ...] |
71 Options: | |
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 |
53 shift; shift | 77 shift; shift |
54 done | 78 done |
118 | 142 |
119 # With no arguments, examine all files under the RCS directory. | 143 # With no arguments, examine all files under the RCS directory. |
120 case $# in | 144 case $# in |
121 0) | 145 0) |
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 |
133 esac | 157 esac |
134 oldIFS=$IFS | 158 oldIFS=$IFS |
135 IFS=$nl | 159 IFS=$nl |
136 set $files | 160 set $files |
137 IFS=$oldIFS | 161 IFS=$oldIFS |
138 esac | 162 esac |
139 | 163 |
140 rlogout=/tmp/chg$$ | 164 rlogout=$TMPDIR/rcs2log$$r |
141 trap exit 1 2 13 15 | 165 trap exit 1 2 13 15 |
142 trap 'rm -f $rlogout; exit 1' 0 | 166 trap "rm -f $loginsout $rlogout; exit 1" 0 |
143 | 167 |
144 rlog "$datearg" "$@" >$rlogout || exit | 168 rlog "$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 |
148 # to awk code that initializes the `fullname' awk associative array. | 172 # to awk code that initializes the `fullname' awk associative array. |
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 |
152 initialize_fullname= | 176 case $loginsout in |
177 ?*) sort -u -o $loginsout <<EOF || exit | |
178 $logins | |
179 EOF | |
180 esac | |
153 authors=` | 181 authors=` |
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 ` |
157 case $authors in | 188 case $authors in |
158 ?*) | 189 ?*) |
159 initialize_author= | 190 initialize_author= |
160 for author in $authors | 191 for author in $authors |
161 do | 192 do |
162 initialize_author="$initialize_author | 193 initialize_author="$initialize_author |
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" |
170 ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | 200 ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
171 '"$initialize_author"' | 201 '"$initialize_author"' |
198 ' | 228 ' |
199 | 229 |
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 |
204 esac | 234 esac |
205 | 235 |
206 | 236 |
207 # Function to print a single log line. | 237 # Function to print a single log line. |
208 # We don't use awk functions, to stay compatible with old awk versions. | 238 # We don't use awk functions, to stay compatible with old awk versions. |
233 sep = indent_string | 263 sep = indent_string |
234 Log = substr(Log, i+1) | 264 Log = substr(Log, i+1) |
235 } | 265 } |
236 }' | 266 }' |
237 | 267 |
238 hostname=`( | 268 case $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 } | |
276 esac | |
244 | 277 |
245 | 278 |
246 # Process the rlog output, generating ChangeLog style entries. | 279 # Process the rlog output, generating ChangeLog style entries. |
247 | 280 |
248 # First, reformat the rlog output so that each line contains one log entry. | 281 # First, reformat the rlog output so that each line contains one log entry. |
277 # Some awks do not understand "\r" or "\013", so we have to | 310 # Some awks do not understand "\r" or "\013", so we have to |
278 # put a carriage return directly in the file. | 311 # put a carriage return directly in the file. |
279 CR=" | 312 CR=" |
280 " # <-- There is a single CR between the " chars here. | 313 " # <-- There is a single CR between the " chars here. |
281 | 314 |
282 # Initialize the fullname associative array. | 315 # Initialize the fullname and mailaddr associative arrays. |
283 '"$initialize_fullname"' | 316 '"$initialize_fullname"' |
317 '"$initialize_mailaddr"' | |
284 | 318 |
285 # Initialize indent string. | 319 # Initialize indent string. |
286 indent_string = "" | 320 indent_string = "" |
287 i = '"$indent"' | 321 i = '"$indent"' |
288 if (0 < '"$tabwidth"') | 322 if (0 < '"$tabwidth"') |
359 day = substr(monthday, i+1) + 0 | 393 day = substr(monthday, i+1) + 0 |
360 leap = 0 | 394 leap = 0 |
361 if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1 | 395 if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1 |
362 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 | 396 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 |
363 | 397 |
364 # Print "date fullname (email address)" if the fullname is known; | 398 # Print "date fullname (email address)". |
365 # print "date author" otherwise. | 399 # Get fullname and email address from associative arrays; |
366 # Get the fullname from the associative array. | 400 # default to author and author@hostname if not in arrays. |
367 # The email address is just author@thishostname. | |
368 printf "%s %s %2d %s %d ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year | |
369 if (fullname[author]) | 401 if (fullname[author]) |
370 printf "%s (%s@%s)\n\n", fullname[author], author, "'"$hostname"'" | 402 auth = fullname[author] |
371 else | 403 else |
372 printf "%s\n\n", author | 404 auth = author |
405 printf "%s %s %2d %s %d %s ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year, auth | |
406 if (mailaddr[author]) | |
407 printf "(%s)\n\n", mailaddr[author] | |
408 else | |
409 printf "(%s@%s)\n\n", author, "'"$hostname"'" | |
373 } | 410 } |
374 if (! filesknown[$1]) { | 411 if (! filesknown[$1]) { |
375 filesknown[$1] = 1 | 412 filesknown[$1] = 1 |
376 if (files == "") files = " " $1 | 413 if (files == "") files = " " $1 |
377 else files = files ", " $1 | 414 else files = files ", " $1 |
387 ' && | 424 ' && |
388 | 425 |
389 | 426 |
390 # Exit successfully. | 427 # Exit successfully. |
391 | 428 |
392 exec rm -f $rlogout | 429 exec rm -f $loginsout $rlogout |