interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

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#
8if {[llength $argv]!=1} {
9 puts stderr "Usage: tclsh [info script] FILENAME"
10 exit 1
11}
12set FILENAME [lindex $argv 0]
13set fd [open $FILENAME rb]
14set newtext {}
15set ctr 0
16set entryPending 0
17set nocaps 0
18while {![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}
49close $fd
50set fd [open $FILENAME wb]
51puts -nonewline $fd $newtext
52close $fd