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
|
#!/usr/bin/env tclsh
#
# This program sorts taglog_help files by Id field, allowing the taghelp
# routine to binary search them
#
# Copyright John Lines (john+taglog@paladyn.org) January 2002
#
# This program is released under the terms of the GNU Public Licence
#
# Version 0.0.2 sorts in a case insensitive manner
#
set version 0.0.2
global auto_path
# tag.tcl should be in a real library directory or in the script dir
set scriptdir [file dirname [info script]]
lappend auto_path $scriptdir
package require tag
proc sorthelp { fn } {
#
# file copy $fn $fn.unsorted
set helpentries [tag readfile $fn]
#set sortentries [tag sort $helpentries Id -ascii ]
set sortentries [tag sort $helpentries Id -dictionary ]
#
# The header should be entry 0 (becuase it does not have an Id field and
# null sorts before everything else
#
# Put a Sorted-date header entry in there.
set header [lindex $sortentries 0]
#tag setorreplace header Sorted-date [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"]
tag setorreplace header Sorted-date [clock format [clock scan "next 10 seconds"] -format "%Y-%m-%d %H:%M:%S"]
tag setorreplace header Sort-key Id
set sortentries [lreplace $sortentries 0 0 $header]
tag writefile $fn $sortentries
}
global argv
# only take one argument for now
set fn [lindex $argv 0]
sorthelp $fn
|