File: mkkeytables

package info (click to toggle)
dosemu 1.4.0+svn.1999-2
  • links: PTS
  • area: contrib
  • in suites: squeeze
  • size: 15,552 kB
  • ctags: 22,600
  • sloc: ansic: 136,915; asm: 4,107; sh: 1,606; perl: 1,411; makefile: 974; tcl: 599; awk: 404; yacc: 300; lex: 157
file content (43 lines) | stat: -rwxr-xr-x 778 bytes parent folder | download | duplicates (10)
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
#! /usr/bin/perl

$fprefix = "./etc/keymap/";
$infile = $fprefix . "all.tmp";

`./bin/dos -I 'keytable dump "$infile"'`;

open(FIN, "<$infile") || die "Can't open $file";

$file ="$fprefix${filecount}.txt";
$open = 0;

while (<FIN>) {
  $line = $_;
  $linecount++;
  if ( $line =~ /^keytable (\S+)/) {
    $ktable = $1;
    $file = "$fprefix$ktable";
    # new packet, first close the old one
    if ($open) {
      close(FOUT);
      $open = 0;
    }
    if ($ktable ne "keyb-user") {
      open(FOUT, ">$file");
      $open = 1;
      print FOUT "\#keytable ${ktable}\n";
      print FOUT "keytable keyb-user {\n";
    }
  }
  else {
    if ($open) {
      if ( $line =~ /^}/ ) {$open = 0;}
      print FOUT $line;
    }
  }
}

if ($open) {
  close(FOUT);
}
`rm -f $infile`;