Commit MetaInfo

Revisionef834345c6bdeef6f4501358237736658fb51493 (tree)
Zeit2019-12-12 04:23:01
AutorSHIRAKATA Kentaro <argrath@ub32...>
CommiterSHIRAKATA Kentaro

Log Message

add 1line

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/1line/diff.pl
@@ -0,0 +1,25 @@
1+#! /usr/bin/perl -i.bak
2+while(<>){
3+ if($_ eq "/*JP\n"){
4+ my($s1, $s2, $s3);
5+ $s1 = <>;
6+ $s2 = <>;
7+ $s3 = <>;
8+ if($s2 eq "*/\n"){
9+ print $s1;
10+ open FF, ">>../../1line/$ARGV.txt";
11+ print FF $s1;
12+ print FF $s3;
13+ close FF;
14+ } else {
15+ print "/*JP\n";
16+ print $s1;
17+ print $s2;
18+ print $s3;
19+ }
20+ } else {
21+ print $_;
22+ }
23+}
24+
25+
--- /dev/null
+++ b/1line/merge.sh
@@ -0,0 +1,5 @@
1+#! /bin/sh
2+for i in `echo *.c`; do
3+ perl ../../tool/1line/patch.pl $i
4+ mv $i.new $i
5+done
--- /dev/null
+++ b/1line/patch.pl
@@ -0,0 +1,46 @@
1+#! /usr/bin/perl
2+print STDERR "$ARGV\n";
3+open F, $ARGV;
4+my (@file) = <>;
5+my (@file2) = @file;
6+close F;
7+for($i = 0; $i < $#file; $i++){
8+$file2[$i] =~ s/^[\t ]+//;
9+}
10+open FI, "<../../1line/$ARGV.txt";
11+while(!eof(FI)){
12+ my ($i);
13+ my ($in, $in2, $out);
14+ my ($f) = 0;
15+ $in = <FI>;
16+ $out = <FI>;
17+ $in2 = $in;
18+ $in2 =~ s/^[\t ]+//;
19+ for($i = 0; $i < $#file; $i++){
20+ if($file[$i] eq "#if 0 /*JP*/\n"){
21+ $f = 1;
22+ next;
23+ }
24+ if($file[$i] =~ /endif/){
25+ $f = 0;
26+ next;
27+ }
28+
29+ if($f == 1){
30+ next;
31+ }
32+
33+ if($in2 eq $file2[$i]){
34+ $file[$i] = "/*JP\n$in*/\n$out";
35+ $file2[$i] = '';
36+ last;
37+ }
38+ }
39+ if($i == $#file){
40+ print "$ARGV:\n" . $in . $out;
41+ }
42+}
43+close FI;
44+open FO, ">$ARGV.new";
45+print FO @file;
46+close FO;
--- /dev/null
+++ b/1line/split.sh
@@ -0,0 +1,7 @@
1+#! /bin/sh
2+rm -rf ../../1line
3+mkdir ../../1line
4+for i in `echo *.c`; do
5+ perl ../../tool/1line/diff.pl $i
6+done
7+rm *.bak
Show on old repository browser