Mercurial > emacs
comparison lib-src/rcs2log @ 640:36e7f4e402bd
Call ypmatch at most once.
author | Paul Eggert <eggert@twinsun.com> |
---|---|
date | Mon, 11 May 1992 19:59:33 +0000 |
parents | dce8cdbac0ea |
children | 8abf83cc14b1 |
comparison
equal
deleted
inserted
replaced
639:96378799b3f7 | 640:36e7f4e402bd |
---|---|
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # RCS to ChangeLog generator | 3 # RCS to ChangeLog generator |
4 | 4 |
5 # $Id: rcs2log,v 1.5 1992/04/01 08:57:55 eggert Exp eggert $ | 5 # $Id: rcs2log,v 1.6 1992/05/08 21:45:00 eggert Exp eggert $ |
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 | 10 |
67 # Get the full name of each author the logs mention, and set initialize_fullname | 67 # Get the full name of each author the logs mention, and set initialize_fullname |
68 # to awk code that initializes the `fullname' awk associative array. | 68 # to awk code that initializes the `fullname' awk associative array. |
69 # Warning: foreign authors (i.e. not known in the passwd file) are mishandled; | 69 # Warning: foreign authors (i.e. not known in the passwd file) are mishandled; |
70 # you have to fix the resulting output by hand. | 70 # you have to fix the resulting output by hand. |
71 | 71 |
72 initialize_fullname= | |
72 authors=` | 73 authors=` |
73 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 | | 74 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 | |
74 sort -u | 75 sort -u |
75 ` | 76 ` |
76 | 77 case $authors in |
77 initialize_fullname= | 78 ?*) |
78 for author in $authors | 79 initialize_author= |
79 do | 80 for author in $authors |
80 fullname=` | 81 do |
81 (grep "^$author:" /etc/passwd || ypmatch "$author" passwd) | | 82 initialize_author="$initialize_author |
82 sed -n 's/^[^:]*:[^:]*:[^:]*:[^:]*:\([^,:]*\).*$/\1/;p;q' | 83 author[\"$author\"] = 1 |
84 " | |
85 done | |
86 | |
87 awkscript=' | |
88 BEGIN { | |
89 alphabet = "abcdefghijklmnopqrstuvwxyz" | |
90 ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
91 '"$initialize_author"' | |
92 } | |
93 { | |
94 if (author[$1]) { | |
95 fullname = $5 | |
96 abbr = index(fullname, "&") | |
97 if (abbr) { | |
98 a = substr($1, 1, 1) | |
99 A = a | |
100 i = index(alphabet, a) | |
101 if (i) A = substr(ALPHABET, i, 1) | |
102 fullname = substr(fullname, 1, abbr-1) A substr($1, 2) substr(fullname, abbr+1) | |
103 } | |
104 printf "fullname[\"%s\"] = \"%s\"\n", $1, fullname | |
105 author[$1] = 0 | |
106 } | |
107 } | |
108 ' | |
109 | |
110 initialize_fullname=` | |
111 (cat /etc/passwd; ypmatch $authors passwd) 2>/dev/null | | |
112 awk -F: "$awkscript" | |
83 ` | 113 ` |
84 case $fullname in | 114 esac |
85 *\&*) | |
86 User=` | |
87 expr " $author" : ' \(.\)' | | |
88 tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | |
89 `` | |
90 expr " $author" : ' .\(.*\)' | |
91 ` | |
92 fullname=`echo "$fullname" | sed "s:&:$User:"` | |
93 esac | |
94 case $fullname in | |
95 ?*) | |
96 initialize_fullname="$initialize_fullname | |
97 fullname[\"$author\"] = \"$fullname\"" | |
98 esac | |
99 done | |
100 | 115 |
101 | 116 |
102 # Function to print a single log line. | 117 # Function to print a single log line. |
103 # We don't use awk functions, to stay compatible with old awk versions. | 118 # We don't use awk functions, to stay compatible with old awk versions. |
104 # `Log' is the log message (with \n replaced by \r). | 119 # `Log' is the log message (with \n replaced by \r). |
160 | 175 |
161 # Now each line is of the form | 176 # Now each line is of the form |
162 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG | 177 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG |
163 # where \r stands for a carriage return, | 178 # where \r stands for a carriage return, |
164 # and each line of the log is terminated by \r instead of \n. | 179 # and each line of the log is terminated by \r instead of \n. |
165 # Sort the log entries, first by date (in reverse order), | 180 # Sort the log entries, first by date+time (in reverse order), |
166 # then by author, then by log entry, and finally by file name (just in case). | 181 # then by author, then by log entry, and finally by file name (just in case). |
167 sort +1 -3r +3 +0 | | 182 sort +1 -3r +3 +0 | |
168 | 183 |
169 # Finally, reformat the sorted log entries. | 184 # Finally, reformat the sorted log entries. |
170 awk ' | 185 awk ' |