comparison lib-src/=rcs2log @ 2220:66371f0b8aff

Some awks don't understand "\r". Code around this. Unfortunately this requires putting a carriage return in the source code. Don't assume that rlog will tolerate times like `10:10:60'; RCS 5.7 won't allow this.
author Paul Eggert <eggert@twinsun.com>
date Tue, 16 Mar 1993 22:49:00 +0000
parents 05cb79ebdb23
children 0e6a6d065a94
comparison
equal deleted inserted replaced
2219:a729b16f7427 2220:66371f0b8aff
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.8 1992/09/27 01:55:21 roland Exp eggert $ 15 # $Id: rcs2log,v 1.9 1993/01/15 05:33:29 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
49 *) break 49 *) break
50 esac 50 esac
51 shift; shift 51 shift; shift
52 done 52 done
53 53
54 month_data='
55 m[0]="Jan"; m[1]="Feb"; m[2]="Mar"
56 m[3]="Apr"; m[4]="May"; m[5]="Jun"
57 m[6]="Jul"; m[7]="Aug"; m[8]="Sep"
58 m[9]="Oct"; m[10]="Nov"; m[11]="Dec"
59
60 # days in non-leap year thus far, indexed by month (0-12)
61 mo[0]=0; mo[1]=31; mo[2]=59; mo[3]=90
62 mo[4]=120; mo[5]=151; mo[6]=181; mo[7]=212
63 mo[8]=243; mo[9]=273; mo[10]=304; mo[11]=334
64 mo[12]=365
65 '
66
54 67
55 # Log into $rlogout the revisions checked in since the first ChangeLog entry. 68 # Log into $rlogout the revisions checked in since the first ChangeLog entry.
56 69
57 date=1970 70 date=1970
58 if test -s ChangeLog 71 if test -s ChangeLog
59 then 72 then
60 # Add 1 to seconds to avoid duplicating most recent log. 73 # Add 1 to seconds to avoid duplicating most recent log.
61 # It's a good thing `rlog' doesn't mind a time ending in `:60'.
62 e=' 74 e='
63 /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{ 75 /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{
64 printf "%s%02d %s\n", substr($0,1,17), substr($0,18,2)+1, $5 76 '"$month_data"'
77 year = $5
78 for (i=0; i<=11; i++) if (m[i] == $2) break
79 dd = $3
80 hh = substr($0,12,2)
81 mm = substr($0,15,2)
82 ss = substr($0,18,2)
83 ss++
84 if (ss == 60) {
85 ss = 0
86 mm++
87 if (mm == 60) {
88 mm = 0
89 hh++
90 if (hh == 24) {
91 hh = 0
92 dd++
93 monthdays = mo[i+1] - mo[i]
94 if (i == 1 && year%4 == 0 && (year%100 != 0 || year%400 == 0)) monthdays++
95 if (dd == monthdays + 1) {
96 dd = 1
97 i++
98 if (i == 12) {
99 i = 0
100 year++
101 }
102 }
103 }
104 }
105 }
106 printf "%d/%02d/%02d %02d:%02d:%02d\n", year, i+1, dd, hh, mm, ss
65 exit 107 exit
66 } 108 }
67 ' 109 '
68 d=`awk "$e" <ChangeLog` || exit 110 d=`awk "$e" <ChangeLog` || exit
69 case $d in 111 case $d in
149 Log = substr(Log, i+3) 191 Log = substr(Log, i+3)
150 } 192 }
151 193
152 # If "label: comment" is too long, break the line after the ":". 194 # If "label: comment" is too long, break the line after the ":".
153 sep = " " 195 sep = " "
154 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, "\r")) sep = "\n" indent_string 196 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, CR)) sep = "\n" indent_string
155 197
156 # Print the label. 198 # Print the label.
157 printf "%s*%s:", indent_string, files 199 printf "%s*%s:", indent_string, files
158 200
159 # Print each line of the log, transliterating \r to \n. 201 # Print each line of the log, transliterating \r to \n.
160 while ((i = index(Log, "\r")) != 0) { 202 while ((i = index(Log, CR)) != 0) {
161 printf "%s%s\n", sep, substr(Log, 1, i-1) 203 printf "%s%s\n", sep, substr(Log, 1, i-1)
162 sep = indent_string 204 sep = indent_string
163 Log = substr(Log, i+1) 205 Log = substr(Log, i+1)
164 } 206 }
165 }' 207 }'
182 /^date: /, /^(-----------*|===========*)$/ { 224 /^date: /, /^(-----------*|===========*)$/ {
183 if ($0 ~ /^branches: /) { next } 225 if ($0 ~ /^branches: /) { next }
184 if ($0 ~ /^date: [0-9][ /0-9:]*;/) { 226 if ($0 ~ /^date: [0-9][ /0-9:]*;/) {
185 time = substr($3, 1, length($3)-1) 227 time = substr($3, 1, length($3)-1)
186 author = substr($5, 1, length($5)-1) 228 author = substr($5, 1, length($5)-1)
187 printf "%s %s %s %s \r", filename, $2, time, author 229 printf "%s %s %s %s %c", filename, $2, time, author, 13
188 next 230 next
189 } 231 }
190 if ($0 ~ /^(-----------*|===========*)$/) { print ""; next } 232 if ($0 ~ /^(-----------*|===========*)$/) { print ""; next }
191 printf "%s\r", $0 233 printf "%s%c", $0, 13
192 } 234 }
193 ' | 235 ' |
194 236
195 # Now each line is of the form 237 # Now each line is of the form
196 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG 238 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG
201 sort +1 -3r +3 +0 | 243 sort +1 -3r +3 +0 |
202 244
203 # Finally, reformat the sorted log entries. 245 # Finally, reformat the sorted log entries.
204 awk ' 246 awk '
205 BEGIN { 247 BEGIN {
248 # Some awks do not understand "\r" or "\013", so we have to
249 # put a carriage return directly in the file.
250 CR="
251 " # <-- There is a single CR between the " chars here.
206 252
207 # Initialize the fullname associative array. 253 # Initialize the fullname associative array.
208 '"$initialize_fullname"' 254 '"$initialize_fullname"'
209 255
210 # Initialize indent string. 256 # Initialize indent string.
225 # Of course, there was no 0 AD, but the algorithm works anyway. 271 # Of course, there was no 0 AD, but the algorithm works anyway.
226 272
227 w[0]="Sun"; w[1]="Mon"; w[2]="Tue"; w[3]="Wed" 273 w[0]="Sun"; w[1]="Mon"; w[2]="Tue"; w[3]="Wed"
228 w[4]="Thu"; w[5]="Fri"; w[6]="Sat" 274 w[4]="Thu"; w[5]="Fri"; w[6]="Sat"
229 275
230 m[0]="Jan"; m[1]="Feb"; m[2]="Mar" 276 '"$month_data"'
231 m[3]="Apr"; m[4]="May"; m[5]="Jun"
232 m[6]="Jul"; m[7]="Aug"; m[8]="Sep"
233 m[9]="Oct"; m[10]="Nov"; m[11]="Dec"
234
235 # days in non-leap year thus far, indexed by month (0-12)
236 mo[0]=0; mo[1]=31; mo[2]=59; mo[3]=90
237 mo[4]=120; mo[5]=151; mo[6]=181; mo[7]=212
238 mo[8]=243; mo[9]=273; mo[10]=304; mo[11]=334
239 mo[12]=365
240 } 277 }
241 278
242 { 279 {
243 newlog = substr($0, 1 + index($0, "\r")) 280 newlog = substr($0, 1 + index($0, CR))
244 281
245 # Ignore log entries prefixed by "#". 282 # Ignore log entries prefixed by "#".
246 if (newlog ~ /^#/) { next } 283 if (newlog ~ /^#/) { next }
247 284
248 if (Log != newlog || date != $2 || author != $4) { 285 if (Log != newlog || date != $2 || author != $4) {