]> code.delx.au - gnu-emacs/blobdiff - lib-src/rcs2log
* configure: Start with a blank line; this keeps some old CSH's
[gnu-emacs] / lib-src / rcs2log
index 22b2157e6ad122185b87621279e3c60c5374b556..2a0ae19e7e1586a43a34266e5b12a7fb21066b60 100755 (executable)
@@ -2,12 +2,15 @@
 
 # RCS to ChangeLog generator
 
-#      $Id: rcs2clog,v 1.3 1992/02/05 17:25:10 eggert Exp eggert $
+#      $Id: rcs2log,v 1.2 1992/09/27 01:55:21 roland Exp $
 
 # Generate a change log prefix from RCS/* and the existing ChangeLog (if any).
 # Output the new prefix to standard output.
 # You can edit this prefix by hand, and then prepend it to ChangeLog.
 
+# Ignore log entries that start with `#'.
+# Clump together log entries that start with `{topic} ',
+# where `topic' contains neither white space nor `}'.
 
 # Parse options.
 
@@ -32,15 +35,23 @@ done
 
 # Log into $rlogout the revisions checked in since the first ChangeLog entry.
 
-datearg=-d'>1970'
+date=1970
 if test -s ChangeLog
 then
-       e='s/^\(...\) \(...\) \(..\) \(..:..:..\) \(....\) .*/\1 \2 \3 \4 \5/p; 1q'
-       date=`sed -n "$e" <ChangeLog` || exit
-       case $date in
-       ?*) datearg="-d>$date"
+       # Add 1 to seconds to avoid duplicating most recent log.
+       # It's a good thing `rlog' doesn't mind a time ending in `:60'.
+       e='
+               /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{
+                       printf "%s%02d %s\n", substr($0,1,17), substr($0,18,2)+1, $5
+                       exit
+               }
+       '
+       d=`awk "$e" <ChangeLog` || exit
+       case $d in
+       ?*) date=$d
        esac
 fi
+datearg="-d>$date"
 
 rlogout=/tmp/chg$$
 trap exit 1 2 13 15
@@ -58,34 +69,49 @@ rlog "$datearg" "$@" >$rlogout || exit
 # Warning: foreign authors (i.e. not known in the passwd file) are mishandled;
 # you have to fix the resulting output by hand.
 
+initialize_fullname=
 authors=`
        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 |
        sort -u
 `
+case $authors in
+?*)
+       initialize_author=
+       for author in $authors
+       do
+               initialize_author="$initialize_author
+                       author[\"$author\"] = 1
+               "
+       done
+
+       awkscript='
+               BEGIN {
+                       alphabet = "abcdefghijklmnopqrstuvwxyz"
+                       ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                       '"$initialize_author"'
+               }
+               {
+                       if (author[$1]) {
+                               fullname = $5
+                               abbr = index(fullname, "&")
+                               if (abbr) {
+                                       a = substr($1, 1, 1)
+                                       A = a
+                                       i = index(alphabet, a)
+                                       if (i) A = substr(ALPHABET, i, 1)
+                                       fullname = substr(fullname, 1, abbr-1) A substr($1, 2) substr(fullname, abbr+1)
+                               }
+                               printf "fullname[\"%s\"] = \"%s\"\n", $1, fullname
+                               author[$1] = 0
+                       }
+               }
+       '
 
-initialize_fullname=
-for author in $authors
-do
-       fullname=`
-               (grep "^$author:" /etc/passwd || ypmatch "$author" passwd) |
-               sed -n 's/^[^:]*:[^:]*:[^:]*:[^:]*:\([^,:]*\).*$/\1/;p;q'
+       initialize_fullname=`
+               (cat /etc/passwd; ypmatch $authors passwd) 2>/dev/null |
+               awk -F: "$awkscript"
        `
-       case $fullname in
-       *\&*)
-               User=`
-                       expr " $author" : ' \(.\)' |
-                       tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
-               ``
-                       expr " $author" : ' .\(.*\)'
-               `
-               fullname=`echo "$fullname" | sed "s:&:$User:"`
-       esac
-       case $fullname in
-       ?*)
-               initialize_fullname="$initialize_fullname
-                       fullname[\"$author\"] = \"$fullname\""
-       esac
-done
+esac
 
 
 # Function to print a single log line.
@@ -142,8 +168,8 @@ awk <$rlogout '
                        printf "%s %s %s %s \r", filename, $2, time, author
                        next
                }
-               if ($0 ~ /^(-----------*|===========*)/) { print ""; next }
-               { printf "%s\r", $0 }
+               if ($0 ~ /^(-----------*|===========*)$/) { print ""; next }
+               printf "%s\r", $0
        }
 ' |
 
@@ -151,9 +177,9 @@ awk <$rlogout '
 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG
 #      where \r stands for a carriage return,
 #      and each line of the log is terminated by \r instead of \n.
-# Sort the log entries, first by date (in reverse order),
+# Sort the log entries, first by date+time (in reverse order),
 # then by author, then by log entry, and finally by file name (just in case).
-sort +1 -2r +3 +0 |
+sort +1 -3r +3 +0 |
 
 # Finally, reformat the sorted log entries.
 awk '
@@ -193,8 +219,13 @@ awk '
                mo[8]=243; mo[9]=273; mo[10]=304; mo[11]=334
                mo[12]=365
        }
+
        {
                newlog = substr($0, 1 + index($0, "\r"))
+
+               # Ignore log entries prefixed by "#".
+               if (newlog ~ /^#/) { next }
+
                if (Log != newlog || date != $2 || author != $4) {
 
                        # The previous log and this log differ.
@@ -208,7 +239,8 @@ awk '
                        # and use it to decide whether to output a blank line.
                        newclumpname = ""
                        sep = "\n"
-                       if (newlog ~ /^{[^       }]+}[   ]/) {
+                       if (date == "") sep = ""
+                       if (newlog ~ /^{[^       }]*}[   ]/) {
                                i = index(newlog, "}")
                                newclumpname = substr(newlog, 1, i)
                                while (substr(newlog, i+1) ~ /^[         ]/) i++
@@ -235,13 +267,13 @@ awk '
                        # into ugly ctime date like "Fri Jan  3 00:03:44 1992".
                        # Calculate day of week from Gregorian calendar.
                        i = index($2, "/")
-                       year = substr($2, 1, i-1)
+                       year = substr($2, 1, i-1) + 0
                        monthday = substr($2, i+1)
                        i = index(monthday, "/")
-                       month = substr(monthday, 1, i-1)
-                       day = substr(monthday, i+1)
+                       month = substr(monthday, 1, i-1) + 0
+                       day = substr(monthday, i+1) + 0
                        leap = 0
-                       if (2 <= month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1
+                       if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1
                        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
 
                        # Print "date  fullname  (email address)" if the fullname is known;