File: tcltrim

package info (click to toggle)
tix 8.4.3-4
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 8,448 kB
  • ctags: 6,844
  • sloc: ansic: 28,077; tcl: 22,774; python: 7,577; makefile: 332; cs: 253; sh: 185; perl: 128
file content (24 lines) | stat: -rw-r--r-- 387 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/local/bin/tclsh

foreach source $argv {
    set target [file rootname $source].tt

    set src [open $source RDONLY]
    set tgt [open $target {RDWR CREAT TRUNC}]

    while {[eof $src] == 0} {
	set line [string trim [gets $src]]

	if {$line == ""} {
	    continue
	}
	if {[string index $line 0] == "#"} {
	    continue
	}
	puts $tgt $line
    }

    close $src
    close $tgt
}