emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 r117129: Fix rcs2log problems with CVS.


From: Paul Eggert
Subject: [Emacs-diffs] emacs-24 r117129: Fix rcs2log problems with CVS.
Date: Tue, 20 May 2014 07:59:33 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117129
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: emacs-24
timestamp: Tue 2014-05-20 00:59:28 -0700
message:
  Fix rcs2log problems with CVS.
  
  Problem reported by Glenn Morris in
  <http://lists.gnu.org/archive/html/emacs-devel/2014-05/msg00277.html>.
  Plus, fix some security and filename quoting problems.
  * rcs2log (logdir): Prefer mktemp if available.
  (logdir, llogdir): Work even if TMPDIR begins with '-' or has spaces.
  (output_authors, main awk script): Parse more-recent CVS output format.
modified:
  lib-src/ChangeLog              changelog-20091113204419-o5vbwnq5f7feedwu-1608
  lib-src/rcs2log                rcs2log-20091113204419-o5vbwnq5f7feedwu-455
=== modified file 'lib-src/ChangeLog'
--- a/lib-src/ChangeLog 2014-05-06 16:16:57 +0000
+++ b/lib-src/ChangeLog 2014-05-20 07:59:28 +0000
@@ -1,3 +1,13 @@
+2014-05-20  Paul Eggert  <address@hidden>
+
+       Fix rcs2log problems with CVS.
+       Problem reported by Glenn Morris in
+       <http://lists.gnu.org/archive/html/emacs-devel/2014-05/msg00277.html>.
+       Plus, fix some security and filename quoting problems.
+       * rcs2log (logdir): Prefer mktemp if available.
+       (logdir, llogdir): Work even if TMPDIR begins with '-' or has spaces.
+       (output_authors, main awk script): Parse more-recent CVS output format.
+
 2014-05-03  Paul Eggert  <address@hidden>
 
        Handle systems without WCONTINUED consistently.  (Bug#15110, 17339)

=== modified file 'lib-src/rcs2log'
--- a/lib-src/rcs2log   2014-01-01 08:31:29 +0000
+++ b/lib-src/rcs2log   2014-05-20 07:59:28 +0000
@@ -205,11 +205,19 @@
        m[9]="Oct"; m[10]="Nov"; m[11]="Dec"
 '
 
-logdir=$TMPDIR/rcs2log$$
+if type mktemp >/dev/null 2>&1; then
+       logdir=`mktemp -d`
+else
+       logdir=$TMPDIR/rcs2log$$
+       (umask 077 && mkdir "$logdir")
+fi || exit
+case $logdir in
+-*) logdir=./$logdir;;
+esac
+trap exit 1 2 13 15
+trap "rm -fr \"$logdir\" 2>/dev/null" 0
+
 llogout=$logdir/l
-trap exit 1 2 13 15
-trap "rm -fr $logdir 2>/dev/null" 0
-(umask 077 && exec mkdir $logdir) || exit
 
 # If no rlog-format log file is given, generate one into $rlogfile.
 case $rlogfile in
@@ -417,10 +425,10 @@
 ?*)
        case $loginFullnameMailaddrs in
        *\"* | *\\*)
-               sed 's/["\\]/\\&/g' >$llogout <<EOF || exit
+               sed 's/["\\]/\\&/g' >"$llogout" <<EOF || exit
 $loginFullnameMailaddrs
 EOF
-               loginFullnameMailaddrs=`cat $llogout`;;
+               loginFullnameMailaddrs=`cat "$llogout"`;;
        esac
 
        oldIFS=$IFS
@@ -442,29 +450,33 @@
 
 case $logins in
 ?*)
-       sort -u -o $llogout <<EOF
+       sort -u -o "$llogout" <<EOF
 $logins
 EOF
        ;;
 '')
        : ;;
-esac >$llogout || exit
+esac >"$llogout" || exit
 
 output_authors='/^date: / {
-       if ($2 ~ /^[0-9]*[-\/][0-9][0-9][-\/][0-9][0-9]$/ && $3 ~ 
/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9][-+0-9:]*;$/ && $4 == "author:" && $5 ~ 
/^[^;]*;$/) {
-               print substr($5, 1, length($5)-1)
+       cvsformat = $5 == "author:"
+       if ($2 ~ /^[0-9]*[-\/][0-9][0-9][-\/][0-9][0-9]$/ && (cvsformat ? $3 ~ 
/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/ && $4 ~ /^[-+][0-9:]*;$/ : $3 ~ 
/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9][-+0-9:]*;$/)) {
+               author = $(5 + cvsformat)
+               if ($(4 + cvsformat) == "author:" && author ~ /^[^;]*;$/) {
+                       print substr(author, 1, length(author)-1)
+               }
        }
 }'
 authors=`
-       $AWK "$output_authors" <"$rlogfile" | sort -u | comm -23 - $llogout
+       $AWK "$output_authors" <"$rlogfile" | sort -u | comm -23 - "$llogout"
 `
 case $authors in
 ?*)
-       cat >$llogout <<EOF || exit
+       cat >"$llogout" <<EOF || exit
 $authors
 EOF
        initialize_author_script='s/["\\]/\\&/g; s/.*/author[\"&\"] = 1/'
-       initialize_author=`sed -e "$initialize_author_script" <$llogout`
+       initialize_author=`sed -e "$initialize_author_script" <"$llogout"`
        awkscript='
                BEGIN {
                        alphabet = "abcdefghijklmnopqrstuvwxyz"
@@ -644,8 +656,23 @@
                                }
                                date = newdate date
                        }
-                       time = substr($3, 1, length($3) - 1)
-                       author = substr($5, 1, length($5)-1)
+                       time = ""
+                       for (i = 3; i <= NF; i++) {
+                               time = time $i
+                               if (time ~ /;$/) {
+                                       time = substr(time, 1, length(time) - 1)
+                                       break
+                               }
+                       }
+                       i++
+                       if ($i == "author:") {
+                               author = $(i + 1)
+                               if (author ~ /;$/) {
+                                       author = substr(author, 1, 
length(author) - 1)
+                               }
+                       } else {
+                               author = ""
+                       }
                        printf "%s%s%s%s%s%s%s%s%s%s", filename, SOH, rev, SOH, 
date, SOH, time, SOH, author, SOH
                        rev = "?"
                        next
@@ -769,7 +796,7 @@
 
 # Exit successfully.
 
-exec rm -fr $logdir
+exec rm -fr "$logdir"
 
 # Local Variables:
 # tab-width:4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]