52 lines
1.0 KiB
Plaintext
52 lines
1.0 KiB
Plaintext
$OpenBSD: patch-src_test-util_c,v 1.1 2005/12/21 07:58:32 jolan Exp $
|
|
--- src/test-util.c.orig Wed Dec 21 01:51:05 2005
|
|
+++ src/test-util.c Wed Dec 21 01:53:15 2005
|
|
@@ -0,0 +1,47 @@
|
|
+#include <inttypes.h>
|
|
+#include <assert.h>
|
|
+#include "test-util.h"
|
|
+
|
|
+/*
|
|
+** Translate a single byte of Hex into an integer.
|
|
+*/
|
|
+static int hexToInt(int h){
|
|
+ if( h>='0' && h<='9' ){
|
|
+ return h - '0';
|
|
+ }else if( h>='a' && h<='f' ){
|
|
+ return h - 'a' + 10;
|
|
+ }else if( h>='A' && h<='F' ){
|
|
+ return h - 'A' + 10;
|
|
+ }else{
|
|
+ return 0;
|
|
+ }
|
|
+}
|
|
+
|
|
+#if defined(SQLITE_TEST)
|
|
+/*
|
|
+** Convert text generated by the "%p" conversion format back into
|
|
+** a pointer.
|
|
+*/
|
|
+void *sqliteTextToPtr(const char *z){
|
|
+ void *p;
|
|
+ uint64_t v;
|
|
+ uint32_t v2;
|
|
+ if( z[0]=='0' && z[1]=='x' ){
|
|
+ z += 2;
|
|
+ }
|
|
+ v = 0;
|
|
+ while( *z ){
|
|
+ v = (v<<4) + hexToInt(*z);
|
|
+ z++;
|
|
+ }
|
|
+ if( sizeof(p)==sizeof(v) ){
|
|
+ p = *(void**)&v;
|
|
+ }else{
|
|
+ assert( sizeof(p)==sizeof(v2) );
|
|
+ v2 = (uint32_t)v;
|
|
+ p = *(void**)&v2;
|
|
+ }
|
|
+ return p;
|
|
+}
|
|
+#endif
|
|
+
|