Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/tool/renumber-win-thunk.tcl # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / tool / renumber-win-thunk.tcl` 52 lines ยท 1535 bytes Raw Blame History 1 # Run this TCL script to renumber the entries in the 2 # aSyscall[] thunk of the src/os_win.c file. There should 3 # be one argument which is the filename of the src/os_win.c 4 # file. Ex: 5 # 6 # tclsh tool/renumber-win-thunk.tcl src/os_win.c 7 # 8 if {[llength $argv]!=1} { 9 puts stderr "Usage: tclsh [info script] FILENAME" 10 exit 1 11 } 12 set FILENAME [lindex $argv 0] 13 set fd [open $FILENAME rb] 14 set newtext {} 15 set ctr 0 16 set entryPending 0 17 set nocaps 0 18 while {![eof $fd]} { 19 set line [gets $fd] 20 if {$line eq "" && [eof $fd]} break 21 if {[regexp {^#define os([A-Z][_a-zA-Z0-9]+) } $line all nm]} { 22 if {$nm eq "Getenv"} {set nocaps 1} 23 if {$nocaps} {set nm [string tolower $nm]} 24 set syscall_name($ctr) $nm 25 set syscall_idx($nm) $ctr 26 set entryPending 1 27 } 28 if {$entryPending && [regexp {aSyscall\[(\d+)\]\.pCurrent} $line all n]} { 29 regsub {aSyscall\[\d+\]\.pCurrent} $line "aSyscall\[$ctr\].pCurrent" line 30 if {$n!=$ctr} {puts "$n -> $ctr"} 31 incr ctr 32 set entryPending 0 33 } 34 if {[regexp {ArraySize\(aSyscall\)==\d+} $line]} { 35 regsub {ArraySize\(aSyscall\)==\d+} $line "ArraySize(aSyscall)==$ctr" line 36 append newtext $line\n 37 for {set i 0} {$i<$ctr} {incr i 8} { 38 set nm $syscall_name($i) 39 append newtext \ 40 " assert( strcmp(aSyscall\[$i\].zName,\"$nm\")==0 );\n" 41 } 42 continue; 43 } 44 if {[regexp {^ assert\( strcmp\(aSyscall\[(\d+)\].zName,} $line n]} { 45 continue 46 } 47 append newtext $line\n 48 } 49 close $fd 50 set fd [open $FILENAME wb] 51 puts -nonewline $fd $newtext 52 close $fd