/usr/share/t-code/mkcertain.pl is in t-code-common 2:2.3.1-6.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | #!/usr/bin/perl
use Term::Cap;
use Term::Complete;
sub goto_line {
my $n = shift;
$term->Tgoto('cm', 7, $n, STDOUT);
}
sub display_line {
my $n = shift;
my $path = $FILES[$n]->{name};
$path = $1 if ($path =~ /(.*)\.dat/);
$path .= " " x (5 - (length $path));
my $state_name = $STATE_NAMES[$FILES[$n]->{state}];
$term->Tgoto('cm', 0, $n, STDOUT);
print "$path [$state_name] $FILES[$n]->{letters}\n";
goto_line $n;
}
sub restore_term {
goto_line $line_max+6;
system("stty -cbreak echo");
}
sub signal_handler {
restore_term;
exit 1;
}
@STATE_NAMES = qw/¡ß ¢¤ ¡ý/;
# unless (-e "./combime" || -e "./reduce") {
# print STDERR "You haven't compiled the tools yet. Wait a sec.\n";
# system("make combine");
# system("make reduce");
# }
$term = Tgetent Term::Cap {OSPEED => 9600};
bless $term, Term::Cap;
$term->Tputs('cl', 1, STDOUT);
$n = 0;
for (sort { substr($a,1) <=> substr($b,1); } <t*.dat>) {
$FILES[$n] = {};
$FILES[$n]->{name} = $_;
my @ALL_LETTERS;
open(IN, $_) || die "$_ : $!";
while (<IN>) {
push @ALL_LETTERS, split;
}
my $letters;
for (0..15) {
$letters .= "," if ($_ != 0);
$letters .= $ALL_LETTERS[$_ * $#ALL_LETTERS / 15];
}
$FILES[$n]->{letters} = $letters;
$n++;
}
if (open(STATE, ".state")) {
while (<STATE>) {
die ".state : $. : ??\n" unless (/^(t\d+.dat)\s*(\d)$/);
#print "$1 : $2\n";
for (0..$n-1) {
$FILES[$_]->{state} = $2 if ($FILES[$_]->{name} eq $1);
}
}
close STATE;
}
#exit 1;
select STDIN; $| = 1; select STDOUT; $| = 1;
system("stty cbreak -echo");
for (0..$n-1) {
display_line $_;
}
$term->Tgoto('cm', 0, $n+2, STDOUT);
print 'n : ²¼¡¤p : ¾å, " " : ÀÚ´¹, e : ½ªÎ», q : ÃæÃÇ', "\n";
print '¡ý : ³Î¼Â¤Ë³Ð¤¨¤¿Ê¸»ú·²', "\n";
print '¢¤ : °ìÉô³Ð¤¨¤¿Ê¸»ú·²', "\n";
print '¡ß : Á´¤¯³Ð¤¨¤Æ¤¤¤Ê¤¤Ê¸»ú·²', "\n";
$line_max = $n;
$line = 0;
goto_line $line;
$SIG{INT} = $SIG{QUIT} = $SIG{TERM} = 'signal_handler';
for (;;) {
$ch = getc STDIN;
if ($ch eq 'n') {
if ($line < $line_max-1) {
goto_line ++$line;
} else {
print "\007";
}
} elsif ($ch eq 'p') {
if ($line > 0) {
goto_line --$line;
} else {
print "\007";
}
} elsif ($ch eq ' ') {
my $state = $FILES[$line]->{state};
$state = ($state + 1) % ($#STATE_NAMES + 1);
$FILES[$line]->{state} = $state;
display_line $line;
} elsif ($ch eq 'q') {
goto_line $line_max;
print 'ËÜÅö¤ËÃæÃǤ·¤Þ¤¹¤«(y/n)?';
$ch = getc STDIN;
if ($ch eq 'y' || $ch eq 'Y') {
restore_term;
exit 1; # for make
}
} elsif ($ch eq 'e') {
last;
}
}
restore_term;
open OUT, ">.state";
for (0 .. $line_max-1) {
print OUT "$FILES[$_]->{name} $FILES[$_]->{state}\n";
}
close OUT;
for (0 .. $line_max-1) {
if ($FILES[$_]->{state} == 1) {
$uncertain .= "$FILES[$_]->{name} ";
} elsif ($FILES[$_]->{state} == 2) {
$certain .= "$FILES[$_]->{name} ";
}
}
print("cat /dev/null $uncertain >uncertain\n");
system("cat /dev/null $uncertain >uncertain");
print("cat /dev/null $certain >certain\n");
system("cat /dev/null $certain >certain");
#system("make");
exit 0;
|