rcsを使う(その5)

TVアニメ『ストライク・ザ・ブラッド』ティザーPV

アニメ『ストライク・ザ・ブラッド』(2013)

キャラが好きです。監視役の少女(雪菜)からは、変態ですね、と言われてますが、主人公(古城)の性格はすごくまとも。吸血鬼なのに血を吸わないでいたこととか、夏休みの補習頑張ってるところとか。古城と雪菜だけが無垢に感じます。キャラはみんな可愛いのですが、みんな同じ顔に見えてしまうのが難点です。

続きです。
現在のmy-rcsコマンドのlog表示です。

takk@deb9:~/tmp$ perl my-rcs.pl test.c
----------------------------
revision 1.1
date	2018.09.12.11.49.34;	author takk;	state Exp;
Initial revision
----------------------------
revision 1.2
date	2018.09.12.11.58.02;	author takk;	state Exp;
2nd Check in
----------------------------
revision 1.3
date	2018.09.13.11.00.44;	author takk;	state Exp;
TEST
=============================================================================
takk@deb9:~/tmp$ 

本家rcsのlog表示です。

takk@deb9:~/tmp$ rcs log test.c

RCS file: RCS/test.c,v
Working file: test.c
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;	selected revisions: 3
description:
TEST
----------------------------
revision 1.3
date: 2018/09/13 11:00:44;  author: takk;  state: Exp;  lines: +3 -1
TEST
----------------------------
revision 1.2
date: 2018/09/12 11:58:02;  author: takk;  state: Exp;  lines: +2 -0
2nd Check in
----------------------------
revision 1.1
date: 2018/09/12 11:49:34;  author: takk;  state: Exp;
Initial revision
=============================================================================
takk@deb9:~/tmp$ 

レビジョンの表示順序が逆なので、対応してみます。
sortの行を修正します。
修正前。

takk@deb9:~/tmp$ cat -n my-rcs.pl | sed -ne '41p'
    41	@all = sort keys %hist;
takk@deb9:~/tmp$ 

修正後。

takk@deb9:~/tmp$ cat -n my-rcs.pl | sed -ne '41p'
    41	@all = sort {$b <=> $a} keys %hist;
takk@deb9:~/tmp$ 

逆になったか確認。

takk@deb9:~/tmp$ perl my-rcs.pl test.c
----------------------------
revision 1.3
date	2018.09.13.11.00.44;	author takk;	state Exp;
TEST
----------------------------
revision 1.2
date	2018.09.12.11.58.02;	author takk;	state Exp;
2nd Check in
----------------------------
revision 1.1
date	2018.09.12.11.49.34;	author takk;	state Exp;
Initial revision
=============================================================================
takk@deb9:~/tmp$

続きて、log表示のヘッダ部分。各タイトルの表示だけです。

takk@deb9:~/tmp$ cat -n my-rcs.pl | sed -ne "41,55p"
    41	@all = sort {$b <=> $a} keys %hist;
    42	print <<EOL;
    43	
    44	RCS file: 
    45	Working file:
    46	head:
    47	branch:
    48	locks:
    49	access list:
    50	symbolic names:
    51	keyword substitution:
    52	total revisions: selected revisions:
    53	description:
    54	
    55	EOL
takk@deb9:~/tmp$ 

修正後のmy-rcsの結果です。

takk@deb9:~/tmp$ perl my-rcs.pl test.c

RCS file: 
Working file:
head:
branch:
locks:
access list:
symbolic names:
keyword substitution:
total revisions: selected revisions:
description:

----------------------------
revision 1.3
date	2018.09.13.11.00.44;	author takk;	state Exp;
TEST
----------------------------
revision 1.2
date	2018.09.12.11.58.02;	author takk;	state Exp;
2nd Check in
----------------------------
revision 1.1
date	2018.09.12.11.49.34;	author takk;	state Exp;
Initial revision
=============================================================================
takk@deb9:~/tmp$ 

例によって全ソース。

takk@deb9:~/tmp$ cat -n my-rcs.pl
     1	open(IN,"<RCS/$ARGV[0],v");
     2	while(<IN>){
     3		chomp;
     4		if(/^head\t(\d+\.\d+);/){
     5			$head = $1;
     6			next;
     7		}
     8		if(/^(\d+\.\d+)$/){
     9			$rev = $1;
    10			next;
    11		}
    12		if(/^(date\t\d\d\d\d\..*)$/){
    13			$date = $1;
    14			$hist{$rev} .= ":SEP:" . $date;
    15			next;
    16		}
    17		if(/^log$/){
    18			$sts = "log-start";	
    19			next;
    20		}
    21		if($sts eq "log-start"){
    22			if(/^\@/){
    23				s/^\@//;	
    24				$hist{$rev} .= ":SEP:" . $_;
    25				$sts = "log";	
    26			}
    27			next;
    28		}
    29		if($sts eq "log"){
    30			if(/\@$/){
    31				s/\@$//;	
    32				$hist{$rev} .= $_ . ":SEP:";
    33				$sts = "";	
    34				next;
    35			}
    36			$hist{$rev} .= $_;
    37		}
    38	}
    39	close(IN);
    40	
    41	@all = sort {$b <=> $a} keys %hist;
    42	print <<EOL;
    43	
    44	RCS file: 
    45	Working file:
    46	head:
    47	branch:
    48	locks:
    49	access list:
    50	symbolic names:
    51	keyword substitution:
    52	total revisions: selected revisions:
    53	description:
    54	
    55	EOL
    56	foreach(@all){
    57		my $rev = $_;
    58		my $line = $hist{$rev};
    59		my ($tmp,$date,$log) = split /:SEP:/,$line;
    60	
    61		print "----------------------------\n";
    62	
    63		print"revision $rev\n";
    64		print"$date\n";
    65		print"$log\n";
    66	}
    67	print"=============================================================================\n";
    68	
    69	
takk@deb9:~/tmp$ 

コメント

タイトルとURLをコピーしました