File: removetoken.tcl

package info (click to toggle)
scid 1%3A4.3.0.cvs20120311-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 24,232 kB
  • sloc: tcl: 135,238; cpp: 47,810; ansic: 5,339; sh: 2,882; python: 278; makefile: 105; perl: 86
file content (65 lines) | stat: -rwxr-xr-x 1,379 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/tclsh
###
### removetoken.tcl
###

# (C) Pascal Georges 2007
#
# Will remove a line containing the token in argument

array set encodings {
  czech iso8859-2
  deutsch iso8859-1
  francais iso8859-1
  hungary iso8859-2
  italian iso8859-1
  nederlan iso8859-1
  norsk iso8859-1
  polish iso8859-2
  portbr iso8859-1
  russian iso8859-5
  serbian iso8859-2
  spanish iso8859-1
  swedish iso8859-1
  catalan iso8859-1
  suomi iso8859-1
  greek utf-8
}

set languages {czech deutsch francais hungary italian nederlan norsk polish
  portbr spanish swedish serbian russian catalan suomi greek
}

################################################################################
proc remove {langfile enc token} {
  # Read the language file
  
  set f [open $langfile.tcl r]
  fconfigure $f -encoding $enc
  set data [read $f]
  close $f
  set langData [split $data "\n"]
  
  set fnew [open $langfile.tcl.new w]
  fconfigure $fnew -encoding $enc
  
  foreach line $langData {
    set fields [split $line]
    set command [lindex $fields 0]
    set lang [lindex $fields 1]
    set name [lindex $fields 2]
    if {$name != $token} {
      puts $fnew $line
    }
  }
  close $fnew
}
################################################################################

set token $argv

foreach language $languages {
  remove $language $encodings($language) $token
}

# end of file