Mercurial > emacs
comparison lib-src/rcs2log @ 17741:0c832661d9b4
(loginFullnameMailaddrs, logins, rlog_options, files): Don't prepend $nl
since this causes some shells to generate the empty string when IFS is $nl.
(printlogline): Use SOH (octal code 1), not CR, since some PC-based shells
mishandle CR.
author | Paul Eggert <eggert@twinsun.com> |
---|---|
date | Sun, 11 May 1997 20:02:32 +0000 |
parents | edebe056f7bc |
children | c113f8bd706c |
comparison
equal
deleted
inserted
replaced
17740:edebe056f7bc | 17741:0c832661d9b4 |
---|---|
26 --help Output help. | 26 --help Output help. |
27 --version Output version number. | 27 --version Output version number. |
28 | 28 |
29 Report bugs to <bug-gnu-emacs@prep.ai.mit.edu>.' | 29 Report bugs to <bug-gnu-emacs@prep.ai.mit.edu>.' |
30 | 30 |
31 Id='$Id: rcs2log,v 1.38 1997/03/23 18:46:03 eggert Exp eggert $' | 31 Id='$Id: rcs2log,v 1.39 1997/05/11 18:43:55 eggert Exp eggert $' |
32 | 32 |
33 # Copyright 1992, 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. | 33 # Copyright 1992, 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. |
34 | 34 |
35 # This program is free software; you can redistribute it and/or modify | 35 # This program is free software; you can redistribute it and/or modify |
36 # it under the terms of the GNU General Public License as published by | 36 # it under the terms of the GNU General Public License as published by |
88 -n) case ${2?}${3?}${4?} in | 88 -n) case ${2?}${3?}${4?} in |
89 *"$tab"* | *"$nl"*) | 89 *"$tab"* | *"$nl"*) |
90 echo >&2 "$0: -n '$2' '$3' '$4': tabs, newlines not allowed" | 90 echo >&2 "$0: -n '$2' '$3' '$4': tabs, newlines not allowed" |
91 exit 1 | 91 exit 1 |
92 esac | 92 esac |
93 loginFullnameMailaddrs=$loginFullnameMailaddrs$nl$2$tab$3$tab$4 | 93 case $loginFullnameMailaddrs in |
94 '') loginFullnameMailaddrs=$2$tab$3$tab$4;; | |
95 ?*) loginFullnameMailaddrs=$loginFullnameMailaddrs$nl$2$tab$3$tab$4 | |
96 esac | |
94 shift; shift; shift;; | 97 shift; shift; shift;; |
95 -u) | 98 -u) |
96 # If $2 is not tab-separated, use colon for separator. | 99 # If $2 is not tab-separated, use colon for separator. |
97 case ${2?} in | 100 case ${2?} in |
98 *"$nl"*) | 101 *"$nl"*) |
111 ;; | 114 ;; |
112 *) | 115 *) |
113 echo >&2 "$0: -u '$2': not enough fields" | 116 echo >&2 "$0: -u '$2': not enough fields" |
114 exit 1 | 117 exit 1 |
115 esac | 118 esac |
116 loginFullnameMailaddrs=$loginFullnameMailaddrs$nl$2 | 119 case $loginFullnameMailaddrs in |
120 '') loginFullnameMailaddrs=$2;; | |
121 ?*) loginFullnameMailaddrs=$loginFullnameMailaddrs$nl$2 | |
122 esac | |
117 shift | 123 shift |
118 esac | 124 esac |
119 logins=$logins$nl$login | 125 case $logins in |
126 '') logins=$login;; | |
127 ?*) logins=$logins$nl$login | |
128 esac | |
120 ;; | 129 ;; |
121 -r) rlog_options=$rlog_options$nl${2?}; shift;; | 130 -r) |
131 case $rlog_options in | |
132 '') rlog_options=${2?};; | |
133 ?*) rlog_options=$rlog_options$nl${2?} | |
134 esac | |
135 shift;; | |
122 -R) recursive=t;; | 136 -R) recursive=t;; |
123 -t) tabwidth=${2?}; shift;; | 137 -t) tabwidth=${2?}; shift;; |
124 -v) revision=t;; | 138 -v) revision=t;; |
125 --version) | 139 --version) |
126 set $Id | 140 set $Id |
223 fi | 237 fi |
224 | 238 |
225 # Use $rlog's -zLT option, if $rlog supports it. | 239 # Use $rlog's -zLT option, if $rlog supports it. |
226 case `$rlog -zLT 2>&1` in | 240 case `$rlog -zLT 2>&1` in |
227 *' option'*) ;; | 241 *' option'*) ;; |
228 *) rlog_options=-zLT$nl$rlog_options | 242 *) |
243 case $rlog_options in | |
244 '') rlog_options=-zLT;; | |
245 ?*) rlog_options=-zLT$nl$rlog_options | |
246 esac | |
229 esac | 247 esac |
230 | 248 |
231 # With no arguments, examine all files under the RCS directory. | 249 # With no arguments, examine all files under the RCS directory. |
232 case $# in | 250 case $# in |
233 0) | 251 0) |
263 case $file in | 281 case $file in |
264 RCS/. | RCS/.. | RCS/,*, | RCS/*_) continue;; | 282 RCS/. | RCS/.. | RCS/,*, | RCS/*_) continue;; |
265 RCS/.rcsfreeze.log | RCS/.rcsfreeze.ver) continue;; | 283 RCS/.rcsfreeze.log | RCS/.rcsfreeze.ver) continue;; |
266 RCS/.\* | RCS/\* | .\*,v | \*,v) test -f "$file" || continue | 284 RCS/.\* | RCS/\* | .\*,v | \*,v) test -f "$file" || continue |
267 esac | 285 esac |
268 files=$files$nl$file | 286 case $files in |
287 '') files=$file;; | |
288 ?*) files=$files$nl$file | |
289 esac | |
269 done | 290 done |
270 case $files in | 291 case $files in |
271 '') exit 0 | 292 '') exit 0 |
272 esac | 293 esac |
273 esac | 294 esac |
414 esac | 435 esac |
415 | 436 |
416 | 437 |
417 # Function to print a single log line. | 438 # Function to print a single log line. |
418 # We don't use awk functions, to stay compatible with old awk versions. | 439 # We don't use awk functions, to stay compatible with old awk versions. |
419 # `Log' is the log message (with \n replaced by \r). | 440 # `Log' is the log message (with \n replaced by \001). |
420 # `files' contains the affected files. | 441 # `files' contains the affected files. |
421 printlogline='{ | 442 printlogline='{ |
422 | 443 |
423 # Following the GNU coding standards, rewrite | 444 # Following the GNU coding standards, rewrite |
424 # * file: (function): comment | 445 # * file: (function): comment |
430 Log = substr(Log, i+3) | 451 Log = substr(Log, i+3) |
431 } | 452 } |
432 | 453 |
433 # If "label: comment" is too long, break the line after the ":". | 454 # If "label: comment" is too long, break the line after the ":". |
434 sep = " " | 455 sep = " " |
435 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, CR)) sep = "\n" indent_string | 456 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, SOH)) sep = "\n" indent_string |
436 | 457 |
437 # Print the label. | 458 # Print the label. |
438 printf "%s*%s:", indent_string, files | 459 printf "%s*%s:", indent_string, files |
439 | 460 |
440 # Print each line of the log, transliterating \r to \n. | 461 # Print each line of the log, transliterating \001 to \n. |
441 while ((i = index(Log, CR)) != 0) { | 462 while ((i = index(Log, SOH)) != 0) { |
442 logline = substr(Log, 1, i-1) | 463 logline = substr(Log, 1, i-1) |
443 if (logline ~ /[^'"$tab"' ]/) { | 464 if (logline ~ /[^'"$tab"' ]/) { |
444 printf "%s%s\n", sep, logline | 465 printf "%s%s\n", sep, logline |
445 } else { | 466 } else { |
446 print "" | 467 print "" |
474 | 495 |
475 | 496 |
476 # Process the rlog output, generating ChangeLog style entries. | 497 # Process the rlog output, generating ChangeLog style entries. |
477 | 498 |
478 # First, reformat the rlog output so that each line contains one log entry. | 499 # First, reformat the rlog output so that each line contains one log entry. |
479 # Transliterate \n to \r so that multiline entries fit on a single line. | 500 # Transliterate \n to \001 so that multiline entries fit on a single line. |
480 # Discard irrelevant rlog output. | 501 # Discard irrelevant rlog output. |
481 $AWK <$rlogout ' | 502 $AWK <$rlogout ' |
482 BEGIN { repository = "'"$repository"'" } | 503 BEGIN { repository = "'"$repository"'" } |
483 /^RCS file:/ { | 504 /^RCS file:/ { |
484 if (repository != "") { | 505 if (repository != "") { |
515 } | 536 } |
516 date = newdate date | 537 date = newdate date |
517 } | 538 } |
518 time = substr($3, 1, length($3) - 1) | 539 time = substr($3, 1, length($3) - 1) |
519 author = substr($5, 1, length($5)-1) | 540 author = substr($5, 1, length($5)-1) |
520 printf "%s %s %s %s %s %c", filename, rev, date, time, author, 13 | 541 printf "%s %s %s %s %s %c", filename, rev, date, time, author, 1 |
521 rev = "?" | 542 rev = "?" |
522 next | 543 next |
523 } | 544 } |
524 if ($0 ~ /^branches: /) { next } | 545 if ($0 ~ /^branches: /) { next } |
525 if ($0 ~ /^(-----------*|===========*)$/) { print ""; next } | 546 if ($0 ~ /^(-----------*|===========*)$/) { print ""; next } |
526 if ($0 == "Initial revision" || $0 ~ /^file .+ was initially added on branch .+\.$/) { | 547 if ($0 == "Initial revision" || $0 ~ /^file .+ was initially added on branch .+\.$/) { |
527 $0 = "New file." | 548 $0 = "New file." |
528 } | 549 } |
529 printf "%s%c", $0, 13 | 550 printf "%s%c", $0, 1 |
530 } | 551 } |
531 ' | | 552 ' | |
532 | 553 |
533 # Now each line is of the form | 554 # Now each line is of the form |
534 # FILENAME REVISION YYYY-MM-DD HH:MM:SS[+-TIMEZONE] AUTHOR \rLOG | 555 # FILENAME REVISION YYYY-MM-DD HH:MM:SS[+-TIMEZONE] AUTHOR \001LOG |
535 # where \r stands for a carriage return, | 556 # where \001 stands for a carriage return, |
536 # and each line of the log is terminated by \r instead of \n. | 557 # and each line of the log is terminated by \001 instead of \n. |
537 # Sort the log entries, first by date+time (in reverse order), | 558 # Sort the log entries, first by date+time (in reverse order), |
538 # then by author, then by log entry, and finally by file name and revision | 559 # then by author, then by log entry, and finally by file name and revision |
539 # (just in case). | 560 # (just in case). |
540 sort +2 -4r +4 +0 | | 561 sort +2 -4r +4 +0 | |
541 | 562 |
543 $AWK ' | 564 $AWK ' |
544 BEGIN { | 565 BEGIN { |
545 logTZ = "'"$logTZ"'" | 566 logTZ = "'"$logTZ"'" |
546 revision = "'"$revision"'" | 567 revision = "'"$revision"'" |
547 | 568 |
548 # Some awk variants do not understand "\r" or "\015", so we have to | 569 # Some awk variants do not understand "\001", so we have to |
549 # put a carriage return directly in the file. | 570 # put the char directly in the file. |
550 CR=" | 571 SOH="" # <-- There is a single SOH (octal code 001) here. |
551 " # <-- There is a single CR between the " chars here. | |
552 | 572 |
553 # Initialize the fullname and mailaddr associative arrays. | 573 # Initialize the fullname and mailaddr associative arrays. |
554 '"$initialize_fullname"' | 574 '"$initialize_fullname"' |
555 '"$initialize_mailaddr"' | 575 '"$initialize_mailaddr"' |
556 | 576 |
563 while (1 <= i--) | 583 while (1 <= i--) |
564 indent_string = indent_string " " | 584 indent_string = indent_string " " |
565 } | 585 } |
566 | 586 |
567 { | 587 { |
568 newlog = substr($0, 1 + index($0, CR)) | 588 newlog = substr($0, 1 + index($0, SOH)) |
569 | 589 |
570 # Ignore log entries prefixed by "#". | 590 # Ignore log entries prefixed by "#". |
571 if (newlog ~ /^#/) { next } | 591 if (newlog ~ /^#/) { next } |
572 | 592 |
573 if (Log != newlog || date != $3 || author != $5) { | 593 if (Log != newlog || date != $3 || author != $5) { |