File: tit2def.perl

package info (click to toggle)
chdrv 1.0.13-0.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,204 kB
  • ctags: 1,069
  • sloc: ansic: 8,972; perl: 412; asm: 234; makefile: 195; sh: 36
file content (78 lines) | stat: -rwxr-xr-x 1,142 bytes parent folder | download
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
#!/usr/bin/perl
# -*- perl -*-

$stage = 1;			       
while(<>)			
{				
    if (/^#/){
	next;
    }
    if ($stage == 2)
    {
	chop;
	/[ \t]*([^ \t]*)[ \t]*([^ \t]*)/;
	$dd = "";
	for($i=0;$i<length($1);$i++)
	{
	    if (substr($1,$i,1) eq '\\')
	    {
		$dd .= sprintf("%c",oct(substr($1,$i+1,3)));
		$i+=3;
	    }
	    else
	    {
		$dd .= substr($1,$i,1);
	    }
	}
	for($i=0;$i < length($2);$i+=2)
	{
	    if ($i +1 >= length($2))
	    {
		last;
	    }
	    $tt = substr($2,$[+$i,2);
	    	
	    print "$dd $tt\n";
	}
	next;	
    }
	
    if ( /^PROMPT:[ \t]*[^ \t]*::([^ \t]*)::/){
	$tt = substr($1,length($1)-2,2);
	print "MARK [$tt]\n";
	print "bell\n";
	print "%%\n";
    }
    if (/^KEYPROMPT\(([^)]*)\):[ \t]*([^ \n\t]*)/) {
	$tt = $1;
	if (substr($tt,0,1) eq '\\') 
	{
	    $ccc = oct(substr($tt,1));
	    $ccc = sprintf("%c",$ccc);
	}
	else
	{
	    $ccc = $tt;
	}			
	print "$ccc $2\n";
    }
    if (/BEGINDICTIONARY/)
    {
	$stage = 2;
	print "%%\n";
    }
}
	
print STDERR "This script is still in testing,you should check the result\n";
print STDERR "file and make some wrong in it.\n";