From: Ian Jackson Date: Wed, 3 Jun 2009 16:59:24 +0000 (+0100) Subject: show-thing database interaction improved X-Git-Tag: 1.9.2~192^2~2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=commitdiff_plain;h=7715bdc10f8ea8a0b26715bddb3fb5b973f0d404;ds=sidebyside show-thing database interaction improved --- diff --git a/pctb/show-thing.tcl b/pctb/show-thing.tcl index 4537e6a..1c55fcd 100755 --- a/pctb/show-thing.tcl +++ b/pctb/show-thing.tcl @@ -1,4 +1,10 @@ -#!/usr/bin/tk +#!/usr/bin/wish + +# usage: +# run show-thing without args +# then on stdin write +# one line which is a Tcl list for foolist +# the xpm in the format expected proc manyset {list args} { foreach val $list var $args { @@ -287,11 +293,10 @@ proc read_database {} { global database set f [open database r] while {[gets $f l] >= 0} { - if {![regexp {^(\w+) (\d+) ([0-9a-f]{2}+)$} $l \ + if {![regexp {^(\w+) (\d+) ((?:[0-9a-f]{2})+)$} $l \ dummy context strl strh]} { error "bad syntax" } - binary scan $strw h* strh if {[string length $strh] != $strl*2} { error "$strh $strl" } gets $f l; set width [format %d $l] set bm $context @@ -300,6 +305,7 @@ proc read_database {} { } set database($bm) $strh } + close $f } proc write_database {} { @@ -314,9 +320,12 @@ proc write_database {} { foreach x [lrange $bm 1 end] { append o "$x\n" } lappend ol $o } + set f [open database.new w] foreach o [lsort $ol] { - puts -nonewline $o + puts -nonewline $f $o } + close $f + file rename -force database.new database } proc update_database/DEFINE {c0 c1 strh} { diff --git a/pctb/stuff/text.xpm b/pctb/text.xpm similarity index 100% rename from pctb/stuff/text.xpm rename to pctb/text.xpm