Добавлена проверка параметров вызова файл или просто строка
This commit is contained in:
parent
e7c1cbbbe1
commit
5c605d6907
19
tkregexp.tcl
19
tkregexp.tcl
|
@ -1084,14 +1084,16 @@ if {$argc > 1} {
|
|||
puts "Usage: $argv0 <sampleFile>"
|
||||
} elseif {$argc == 1} {
|
||||
set filename [lindex $argv 0]
|
||||
set file [open $filename]
|
||||
set data [read $file [file size $filename]]
|
||||
close $file
|
||||
|
||||
# memorize location
|
||||
set regexp::data(v:dir) [file dirname $filename]
|
||||
set regexp::data(v:file) [file tail $filename]
|
||||
|
||||
if [file exists $filename] {
|
||||
set file [open $filename]
|
||||
set data [read $file [file size $filename]]
|
||||
close $file
|
||||
# memorize location
|
||||
set regexp::data(v:dir) [file dirname $filename]
|
||||
set regexp::data(v:file) [file tail $filename]
|
||||
} else {
|
||||
set data [lindex $argv 0]
|
||||
}
|
||||
regexp::sample:set $data
|
||||
unset data
|
||||
}
|
||||
|
@ -1366,4 +1368,3 @@ proc make-regexp::make-regexp {words} {
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user