Commit 64ce04c6 authored by Scott Hess's avatar Scott Hess

[sql] Fix CRLF in some SQLite source code.

Sometimes CRLF sneak into SQLite's code, and then causes patch errors
when landing in Chromium.  Add an import step for cleaning this up and
clean things up.

None of these files are in the Chromium build.  They just gum up the
works.

BUG=340757
TBR=michaeln@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/880533004

Cr-Commit-Position: refs/heads/master@{#314033}
parent 9c3e3380
...@@ -141,6 +141,12 @@ unzip sqlite-src-${VERSION}.zip ...@@ -141,6 +141,12 @@ unzip sqlite-src-${VERSION}.zip
rm sqlite-src-${VERSION}.zip rm sqlite-src-${VERSION}.zip
# -f includes ignored files, of which there are a couple. # -f includes ignored files, of which there are a couple.
git add -f sqlite-src-${VERSION}/ git add -f sqlite-src-${VERSION}/
# Sometimes DOS line endings sneak into the source code. This command works on
# OSX and Linux and fixes those files, but double-check the results before
# committing:
egrep --exclude="*.eps" --exclude="*.ico" --exclude="*.jpg" \
--exclude="*.gif" --exclude="*.tiff" -URl '\r' . | \
LANG=C xargs sed -i~ -e $'s/\r$//'
git commit -m "Begin import of sqlite-src-${VERSION}" sqlite-src-${VERSION} git commit -m "Begin import of sqlite-src-${VERSION}" sqlite-src-${VERSION}
rm -rf src rm -rf src
cp -a sqlite-src-${VERSION} src cp -a sqlite-src-${VERSION} src
......
...@@ -149,13 +149,13 @@ static void test_destructor_count( ...@@ -149,13 +149,13 @@ static void test_destructor_count(
** arguments. It returns the text value returned by the sqlite3_errmsg16() ** arguments. It returns the text value returned by the sqlite3_errmsg16()
** API function. ** API function.
*/ */
#ifndef SQLITE_OMIT_BUILTIN_TEST #ifndef SQLITE_OMIT_BUILTIN_TEST
void sqlite3BeginBenignMalloc(void); void sqlite3BeginBenignMalloc(void);
void sqlite3EndBenignMalloc(void); void sqlite3EndBenignMalloc(void);
#else #else
#define sqlite3BeginBenignMalloc() #define sqlite3BeginBenignMalloc()
#define sqlite3EndBenignMalloc() #define sqlite3EndBenignMalloc()
#endif #endif
static void test_agg_errmsg16_step(sqlite3_context *a, int b,sqlite3_value **c){ static void test_agg_errmsg16_step(sqlite3_context *a, int b,sqlite3_value **c){
} }
static void test_agg_errmsg16_final(sqlite3_context *ctx){ static void test_agg_errmsg16_final(sqlite3_context *ctx){
......
# 2010 Sept 29 # 2010 Sept 29
# #
# The author disclaims copyright to this source code. In place of # The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing: # a legal notice, here is a blessing:
# #
# May you do good and not evil. # May you do good and not evil.
# May you find forgiveness for yourself and forgive others. # May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give. # May you share freely, never taking more than you give.
# #
#*********************************************************************** #***********************************************************************
# This file implements regression tests for SQLite library. The focus of # This file implements regression tests for SQLite library. The focus of
# this file is testing the SQLite routines used for converting between the # this file is testing the SQLite routines used for converting between the
# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
# UTF-16be). # UTF-16be).
# #
# $Id: enc4.test,v 1.0 2010/09/29 08:29:32 shaneh Exp $ # $Id: enc4.test,v 1.0 2010/09/29 08:29:32 shaneh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
# If UTF16 support is disabled, ignore the tests in this file # If UTF16 support is disabled, ignore the tests in this file
# #
ifcapable {!utf16} { ifcapable {!utf16} {
finish_test finish_test
return return
} }
db close db close
# The three unicode encodings understood by SQLite. # The three unicode encodings understood by SQLite.
set encodings [list UTF-8 UTF-16le UTF-16be] set encodings [list UTF-8 UTF-16le UTF-16be]
# initial value to use in SELECT # initial value to use in SELECT
set inits [list 1 1.0 1. 1e0] set inits [list 1 1.0 1. 1e0]
# vals # vals
set vals [list\ set vals [list\
"922337203685477580792233720368547758079223372036854775807"\ "922337203685477580792233720368547758079223372036854775807"\
"100000000000000000000000000000000000000000000000000000000"\ "100000000000000000000000000000000000000000000000000000000"\
"1.0000000000000000000000000000000000000000000000000000000"\ "1.0000000000000000000000000000000000000000000000000000000"\
] ]
set i 1 set i 1
foreach enc $encodings { foreach enc $encodings {
file delete -force test.db file delete -force test.db
sqlite3 db test.db sqlite3 db test.db
db eval "PRAGMA encoding = \"$enc\"" db eval "PRAGMA encoding = \"$enc\""
do_test enc4-$i.1 { do_test enc4-$i.1 {
db eval {PRAGMA encoding} db eval {PRAGMA encoding}
} $enc } $enc
set j 1 set j 1
foreach init $inits { foreach init $inits {
do_test enc4-$i.$j.2 { do_test enc4-$i.$j.2 {
set S [sqlite3_prepare_v2 db "SELECT $init+?" -1 dummy] set S [sqlite3_prepare_v2 db "SELECT $init+?" -1 dummy]
sqlite3_expired $S sqlite3_expired $S
} {0} } {0}
set k 1 set k 1
foreach val $vals { foreach val $vals {
for {set x 1} {$x<18} {incr x} { for {set x 1} {$x<18} {incr x} {
set part [expr $init + [string range $val 0 [expr $x-1]]] set part [expr $init + [string range $val 0 [expr $x-1]]]
regsub {e\+0} $part {e+} part regsub {e\+0} $part {e+} part
regsub {^1e} $part {1.0e} part regsub {^1e} $part {1.0e} part
do_test enc4-$i.$j.$k.3.$x { do_test enc4-$i.$j.$k.3.$x {
sqlite3_reset $S sqlite3_reset $S
sqlite3_bind_text $S 1 $val $x sqlite3_bind_text $S 1 $val $x
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} [list $part] } [list $part]
do_test enc4-$i.$j.$k.4.$x { do_test enc4-$i.$j.$k.4.$x {
sqlite3_reset $S sqlite3_reset $S
sqlite3_bind_text16 $S 1 [encoding convertto unicode $val] [expr $x*2] sqlite3_bind_text16 $S 1 [encoding convertto unicode $val] [expr $x*2]
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} [list $part] } [list $part]
} }
incr k incr k
} }
do_test enc4-$i.$j.5 { do_test enc4-$i.$j.5 {
sqlite3_finalize $S sqlite3_finalize $S
} {SQLITE_OK} } {SQLITE_OK}
incr j incr j
} }
db close db close
incr i incr i
} }
file delete -force test.db file delete -force test.db
sqlite3 db test.db sqlite3 db test.db
do_test enc4-4.1 { do_test enc4-4.1 {
db eval "select 1+1." db eval "select 1+1."
} {2.0} } {2.0}
do_test enc4-4.2.1 { do_test enc4-4.2.1 {
set S [sqlite3_prepare_v2 db "SELECT 1+1." -1 dummy] set S [sqlite3_prepare_v2 db "SELECT 1+1." -1 dummy]
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} {2.0} } {2.0}
do_test enc4-4.2.2 { do_test enc4-4.2.2 {
sqlite3_finalize $S sqlite3_finalize $S
} {SQLITE_OK} } {SQLITE_OK}
do_test enc4-4.3.1 { do_test enc4-4.3.1 {
set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy] set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
sqlite3_bind_text $S 1 "1." 2 sqlite3_bind_text $S 1 "1." 2
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} {2.0} } {2.0}
do_test enc4-4.3.2 { do_test enc4-4.3.2 {
sqlite3_finalize $S sqlite3_finalize $S
} {SQLITE_OK} } {SQLITE_OK}
do_test enc4-4.4.1 { do_test enc4-4.4.1 {
set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy] set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
sqlite3_bind_text $S 1 "1.0" 2 sqlite3_bind_text $S 1 "1.0" 2
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} {2.0} } {2.0}
do_test enc4-4.4.2 { do_test enc4-4.4.2 {
sqlite3_finalize $S sqlite3_finalize $S
} {SQLITE_OK} } {SQLITE_OK}
db close db close
finish_test finish_test
...@@ -432,10 +432,10 @@ foreach {DO_MALLOC_TEST enc} { ...@@ -432,10 +432,10 @@ foreach {DO_MALLOC_TEST enc} {
{2 2 1 3 3 3 6 3 0 0 0 2 3 2} {2 2 1 3 3 3 6 3 0 0 0 2 3 2}
}] }]
# EVIDENCE-OF: R-40630-02268 If used within a SELECT that uses the # EVIDENCE-OF: R-40630-02268 If used within a SELECT that uses the
# "query by rowid" or "linear scan" strategies, then the snippet and # "query by rowid" or "linear scan" strategies, then the snippet and
# offsets both return an empty string, and the matchinfo function # offsets both return an empty string, and the matchinfo function
# returns a blob value zero bytes in size. # returns a blob value zero bytes in size.
# #
set r 1000000 ;# A rowid that exists in table ft set r 1000000 ;# A rowid that exists in table ft
do_select_test $T.10.0 { SELECT rowid FROM ft WHERE rowid = $r } $r do_select_test $T.10.0 { SELECT rowid FROM ft WHERE rowid = $r } $r
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
# The following tests use hex_to_utf16be() and hex_to_utf16le() which # The following tests use hex_to_utf16be() and hex_to_utf16le() which
# which are only available if SQLite is built with UTF16 support. # which are only available if SQLite is built with UTF16 support.
ifcapable {!utf16} { ifcapable {!utf16} {
finish_test finish_test
return return
......
...@@ -114,40 +114,40 @@ proc dump_jrnl_page {jrnl_pgno} { ...@@ -114,40 +114,40 @@ proc dump_jrnl_page {jrnl_pgno} {
set db_pgno [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset] 4]] set db_pgno [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset] 4]]
set chksum [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset+4+$db_pgsz] 4]] set chksum [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset+4+$db_pgsz] 4]]
set nonce [calc_nonce $jrnl_pgno] set nonce [calc_nonce $jrnl_pgno]
puts [ format {jrnl_pg_offset: %08x (%d) jrnl_pgno: %d db_pgno: %d} \ puts [ format {jrnl_pg_offset: %08x (%d) jrnl_pgno: %d db_pgno: %d} \
$jrnl_pg_offset $jrnl_pg_offset \ $jrnl_pg_offset $jrnl_pg_offset \
$jrnl_pgno $db_pgno] $jrnl_pgno $db_pgno]
puts [ format {nonce: %08x chksum: %08x} \ puts [ format {nonce: %08x chksum: %08x} \
$nonce $chksum] $nonce $chksum]
# now hex dump the data # now hex dump the data
# This is derived from the Tcler's WIKI # This is derived from the Tcler's WIKI
set fid [open $jrnl_name r] set fid [open $jrnl_name r]
fconfigure $fid -translation binary -encoding binary fconfigure $fid -translation binary -encoding binary
seek $fid [expr $jrnl_pg_offset+4] seek $fid [expr $jrnl_pg_offset+4]
set data [read $fid $db_pgsz] set data [read $fid $db_pgsz]
close $fid close $fid
for {set addr 0} {$addr<$db_pgsz} {set addr [expr $addr+16]} { for {set addr 0} {$addr<$db_pgsz} {set addr [expr $addr+16]} {
# get 16 bytes of data # get 16 bytes of data
set s [string range $data $addr [expr $addr+16]] set s [string range $data $addr [expr $addr+16]]
# Convert the data to hex and to characters. # Convert the data to hex and to characters.
binary scan $s H*@0a* hex ascii binary scan $s H*@0a* hex ascii
# Replace non-printing characters in the data. # Replace non-printing characters in the data.
regsub -all -- {[^[:graph:] ]} $ascii {.} ascii regsub -all -- {[^[:graph:] ]} $ascii {.} ascii
# Split the 16 bytes into two 8-byte chunks # Split the 16 bytes into two 8-byte chunks
regexp -- {(.{16})(.{0,16})} $hex -> hex1 hex2 regexp -- {(.{16})(.{0,16})} $hex -> hex1 hex2
# Convert the hex to pairs of hex digits # Convert the hex to pairs of hex digits
regsub -all -- {..} $hex1 {& } hex1 regsub -all -- {..} $hex1 {& } hex1
regsub -all -- {..} $hex2 {& } hex2 regsub -all -- {..} $hex2 {& } hex2
# Print the hex and ascii data # Print the hex and ascii data
puts [ format {%08x %-24s %-24s %-16s} \ puts [ format {%08x %-24s %-24s %-16s} \
$addr $hex1 $hex2 $ascii ] $addr $hex1 $hex2 $ascii ]
} }
} }
# Setup for the tests. Make a backup copy of the files. # Setup for the tests. Make a backup copy of the files.
......
...@@ -149,13 +149,13 @@ static void test_destructor_count( ...@@ -149,13 +149,13 @@ static void test_destructor_count(
** arguments. It returns the text value returned by the sqlite3_errmsg16() ** arguments. It returns the text value returned by the sqlite3_errmsg16()
** API function. ** API function.
*/ */
#ifndef SQLITE_OMIT_BUILTIN_TEST #ifndef SQLITE_OMIT_BUILTIN_TEST
void sqlite3BeginBenignMalloc(void); void sqlite3BeginBenignMalloc(void);
void sqlite3EndBenignMalloc(void); void sqlite3EndBenignMalloc(void);
#else #else
#define sqlite3BeginBenignMalloc() #define sqlite3BeginBenignMalloc()
#define sqlite3EndBenignMalloc() #define sqlite3EndBenignMalloc()
#endif #endif
static void test_agg_errmsg16_step(sqlite3_context *a, int b,sqlite3_value **c){ static void test_agg_errmsg16_step(sqlite3_context *a, int b,sqlite3_value **c){
} }
static void test_agg_errmsg16_final(sqlite3_context *ctx){ static void test_agg_errmsg16_final(sqlite3_context *ctx){
......
# 2010 Sept 29 # 2010 Sept 29
# #
# The author disclaims copyright to this source code. In place of # The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing: # a legal notice, here is a blessing:
# #
# May you do good and not evil. # May you do good and not evil.
# May you find forgiveness for yourself and forgive others. # May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give. # May you share freely, never taking more than you give.
# #
#*********************************************************************** #***********************************************************************
# This file implements regression tests for SQLite library. The focus of # This file implements regression tests for SQLite library. The focus of
# this file is testing the SQLite routines used for converting between the # this file is testing the SQLite routines used for converting between the
# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
# UTF-16be). # UTF-16be).
# #
# $Id: enc4.test,v 1.0 2010/09/29 08:29:32 shaneh Exp $ # $Id: enc4.test,v 1.0 2010/09/29 08:29:32 shaneh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
# If UTF16 support is disabled, ignore the tests in this file # If UTF16 support is disabled, ignore the tests in this file
# #
ifcapable {!utf16} { ifcapable {!utf16} {
finish_test finish_test
return return
} }
db close db close
# The three unicode encodings understood by SQLite. # The three unicode encodings understood by SQLite.
set encodings [list UTF-8 UTF-16le UTF-16be] set encodings [list UTF-8 UTF-16le UTF-16be]
# initial value to use in SELECT # initial value to use in SELECT
set inits [list 1 1.0 1. 1e0] set inits [list 1 1.0 1. 1e0]
# vals # vals
set vals [list\ set vals [list\
"922337203685477580792233720368547758079223372036854775807"\ "922337203685477580792233720368547758079223372036854775807"\
"100000000000000000000000000000000000000000000000000000000"\ "100000000000000000000000000000000000000000000000000000000"\
"1.0000000000000000000000000000000000000000000000000000000"\ "1.0000000000000000000000000000000000000000000000000000000"\
] ]
set i 1 set i 1
foreach enc $encodings { foreach enc $encodings {
file delete -force test.db file delete -force test.db
sqlite3 db test.db sqlite3 db test.db
db eval "PRAGMA encoding = \"$enc\"" db eval "PRAGMA encoding = \"$enc\""
do_test enc4-$i.1 { do_test enc4-$i.1 {
db eval {PRAGMA encoding} db eval {PRAGMA encoding}
} $enc } $enc
set j 1 set j 1
foreach init $inits { foreach init $inits {
do_test enc4-$i.$j.2 { do_test enc4-$i.$j.2 {
set S [sqlite3_prepare_v2 db "SELECT $init+?" -1 dummy] set S [sqlite3_prepare_v2 db "SELECT $init+?" -1 dummy]
sqlite3_expired $S sqlite3_expired $S
} {0} } {0}
set k 1 set k 1
foreach val $vals { foreach val $vals {
for {set x 1} {$x<18} {incr x} { for {set x 1} {$x<18} {incr x} {
set part [expr $init + [string range $val 0 [expr $x-1]]] set part [expr $init + [string range $val 0 [expr $x-1]]]
regsub {e\+0} $part {e+} part regsub {e\+0} $part {e+} part
regsub {^1e} $part {1.0e} part regsub {^1e} $part {1.0e} part
do_test enc4-$i.$j.$k.3.$x { do_test enc4-$i.$j.$k.3.$x {
sqlite3_reset $S sqlite3_reset $S
sqlite3_bind_text $S 1 $val $x sqlite3_bind_text $S 1 $val $x
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} [list $part] } [list $part]
do_test enc4-$i.$j.$k.4.$x { do_test enc4-$i.$j.$k.4.$x {
sqlite3_reset $S sqlite3_reset $S
sqlite3_bind_text16 $S 1 [encoding convertto unicode $val] [expr $x*2] sqlite3_bind_text16 $S 1 [encoding convertto unicode $val] [expr $x*2]
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} [list $part] } [list $part]
} }
incr k incr k
} }
do_test enc4-$i.$j.5 { do_test enc4-$i.$j.5 {
sqlite3_finalize $S sqlite3_finalize $S
} {SQLITE_OK} } {SQLITE_OK}
incr j incr j
} }
db close db close
incr i incr i
} }
file delete -force test.db file delete -force test.db
sqlite3 db test.db sqlite3 db test.db
do_test enc4-4.1 { do_test enc4-4.1 {
db eval "select 1+1." db eval "select 1+1."
} {2.0} } {2.0}
do_test enc4-4.2.1 { do_test enc4-4.2.1 {
set S [sqlite3_prepare_v2 db "SELECT 1+1." -1 dummy] set S [sqlite3_prepare_v2 db "SELECT 1+1." -1 dummy]
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} {2.0} } {2.0}
do_test enc4-4.2.2 { do_test enc4-4.2.2 {
sqlite3_finalize $S sqlite3_finalize $S
} {SQLITE_OK} } {SQLITE_OK}
do_test enc4-4.3.1 { do_test enc4-4.3.1 {
set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy] set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
sqlite3_bind_text $S 1 "1." 2 sqlite3_bind_text $S 1 "1." 2
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} {2.0} } {2.0}
do_test enc4-4.3.2 { do_test enc4-4.3.2 {
sqlite3_finalize $S sqlite3_finalize $S
} {SQLITE_OK} } {SQLITE_OK}
do_test enc4-4.4.1 { do_test enc4-4.4.1 {
set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy] set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
sqlite3_bind_text $S 1 "1.0" 2 sqlite3_bind_text $S 1 "1.0" 2
sqlite3_step $S sqlite3_step $S
sqlite3_column_text $S 0 sqlite3_column_text $S 0
} {2.0} } {2.0}
do_test enc4-4.4.2 { do_test enc4-4.4.2 {
sqlite3_finalize $S sqlite3_finalize $S
} {SQLITE_OK} } {SQLITE_OK}
db close db close
finish_test finish_test
...@@ -432,10 +432,10 @@ foreach {DO_MALLOC_TEST enc} { ...@@ -432,10 +432,10 @@ foreach {DO_MALLOC_TEST enc} {
{2 2 1 3 3 3 6 3 0 0 0 2 3 2} {2 2 1 3 3 3 6 3 0 0 0 2 3 2}
}] }]
# EVIDENCE-OF: R-40630-02268 If used within a SELECT that uses the # EVIDENCE-OF: R-40630-02268 If used within a SELECT that uses the
# "query by rowid" or "linear scan" strategies, then the snippet and # "query by rowid" or "linear scan" strategies, then the snippet and
# offsets both return an empty string, and the matchinfo function # offsets both return an empty string, and the matchinfo function
# returns a blob value zero bytes in size. # returns a blob value zero bytes in size.
# #
set r 1000000 ;# A rowid that exists in table ft set r 1000000 ;# A rowid that exists in table ft
do_select_test $T.10.0 { SELECT rowid FROM ft WHERE rowid = $r } $r do_select_test $T.10.0 { SELECT rowid FROM ft WHERE rowid = $r } $r
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
# The following tests use hex_to_utf16be() and hex_to_utf16le() which # The following tests use hex_to_utf16be() and hex_to_utf16le() which
# which are only available if SQLite is built with UTF16 support. # which are only available if SQLite is built with UTF16 support.
ifcapable {!utf16} { ifcapable {!utf16} {
finish_test finish_test
return return
......
...@@ -114,40 +114,40 @@ proc dump_jrnl_page {jrnl_pgno} { ...@@ -114,40 +114,40 @@ proc dump_jrnl_page {jrnl_pgno} {
set db_pgno [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset] 4]] set db_pgno [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset] 4]]
set chksum [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset+4+$db_pgsz] 4]] set chksum [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset+4+$db_pgsz] 4]]
set nonce [calc_nonce $jrnl_pgno] set nonce [calc_nonce $jrnl_pgno]
puts [ format {jrnl_pg_offset: %08x (%d) jrnl_pgno: %d db_pgno: %d} \ puts [ format {jrnl_pg_offset: %08x (%d) jrnl_pgno: %d db_pgno: %d} \
$jrnl_pg_offset $jrnl_pg_offset \ $jrnl_pg_offset $jrnl_pg_offset \
$jrnl_pgno $db_pgno] $jrnl_pgno $db_pgno]
puts [ format {nonce: %08x chksum: %08x} \ puts [ format {nonce: %08x chksum: %08x} \
$nonce $chksum] $nonce $chksum]
# now hex dump the data # now hex dump the data
# This is derived from the Tcler's WIKI # This is derived from the Tcler's WIKI
set fid [open $jrnl_name r] set fid [open $jrnl_name r]
fconfigure $fid -translation binary -encoding binary fconfigure $fid -translation binary -encoding binary
seek $fid [expr $jrnl_pg_offset+4] seek $fid [expr $jrnl_pg_offset+4]
set data [read $fid $db_pgsz] set data [read $fid $db_pgsz]
close $fid close $fid
for {set addr 0} {$addr<$db_pgsz} {set addr [expr $addr+16]} { for {set addr 0} {$addr<$db_pgsz} {set addr [expr $addr+16]} {
# get 16 bytes of data # get 16 bytes of data
set s [string range $data $addr [expr $addr+16]] set s [string range $data $addr [expr $addr+16]]
# Convert the data to hex and to characters. # Convert the data to hex and to characters.
binary scan $s H*@0a* hex ascii binary scan $s H*@0a* hex ascii
# Replace non-printing characters in the data. # Replace non-printing characters in the data.
regsub -all -- {[^[:graph:] ]} $ascii {.} ascii regsub -all -- {[^[:graph:] ]} $ascii {.} ascii
# Split the 16 bytes into two 8-byte chunks # Split the 16 bytes into two 8-byte chunks
regexp -- {(.{16})(.{0,16})} $hex -> hex1 hex2 regexp -- {(.{16})(.{0,16})} $hex -> hex1 hex2
# Convert the hex to pairs of hex digits # Convert the hex to pairs of hex digits
regsub -all -- {..} $hex1 {& } hex1 regsub -all -- {..} $hex1 {& } hex1
regsub -all -- {..} $hex2 {& } hex2 regsub -all -- {..} $hex2 {& } hex2
# Print the hex and ascii data # Print the hex and ascii data
puts [ format {%08x %-24s %-24s %-16s} \ puts [ format {%08x %-24s %-24s %-16s} \
$addr $hex1 $hex2 $ascii ] $addr $hex1 $hex2 $ascii ]
} }
} }
# Setup for the tests. Make a backup copy of the files. # Setup for the tests. Make a backup copy of the files.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment