1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

First attempt at getting the build to work with Tcl 9.0.

FossilOrigin-Name: 6e5bb48a74d63fb8c30528f0005d1763cd2dbb882abf86baf1565721e6bfcf84
This commit is contained in:
drh
2024-07-30 15:49:02 +00:00
parent 07f215ad9e
commit 064b681e9b
56 changed files with 375 additions and 550 deletions

View File

@@ -18,11 +18,7 @@
** easier and safer to build our own mechanism.
*/
#include "sqliteInt.h"
#if defined(INCLUDE_SQLITE_TCL_H)
# include "sqlite_tcl.h"
#else
# include "tcl.h"
#endif
#include "tclsqlite.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
@@ -155,7 +151,8 @@ static int SQLITE_TCLAPI hexio_write(
Tcl_Obj *CONST objv[]
){
int offset;
int nIn, nOut, written;
Tcl_Size nIn;
int nOut, written;
const char *zFile;
const unsigned char *zIn;
unsigned char *aOut;
@@ -168,11 +165,11 @@ static int SQLITE_TCLAPI hexio_write(
if( Tcl_GetIntFromObj(interp, objv[2], &offset) ) return TCL_ERROR;
zFile = Tcl_GetString(objv[1]);
zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[3], &nIn);
aOut = sqlite3_malloc( 1 + nIn/2 );
aOut = sqlite3_malloc64( 1 + nIn/2 );
if( aOut==0 ){
return TCL_ERROR;
}
nOut = sqlite3TestHexToBin(zIn, nIn, aOut);
nOut = sqlite3TestHexToBin(zIn, (int)nIn, aOut);
out = fopen(zFile, "r+b");
if( out==0 ){
out = fopen(zFile, "r+");
@@ -203,7 +200,8 @@ static int SQLITE_TCLAPI hexio_get_int(
Tcl_Obj *CONST objv[]
){
int val;
int nIn, nOut;
Tcl_Size nIn;
int nOut;
const unsigned char *zIn;
unsigned char *aOut;
unsigned char aNum[4];
@@ -213,11 +211,11 @@ static int SQLITE_TCLAPI hexio_get_int(
return TCL_ERROR;
}
zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[1], &nIn);
aOut = sqlite3_malloc( 1 + nIn/2 );
aOut = sqlite3_malloc64( 1 + nIn/2 );
if( aOut==0 ){
return TCL_ERROR;
}
nOut = sqlite3TestHexToBin(zIn, nIn, aOut);
nOut = sqlite3TestHexToBin(zIn, (int)nIn, aOut);
if( nOut>=4 ){
memcpy(aNum, aOut, 4);
}else{
@@ -300,7 +298,7 @@ static int SQLITE_TCLAPI utf8_to_utf8(
Tcl_Obj *CONST objv[]
){
#ifdef SQLITE_DEBUG
int n;
Tcl_Size n;
int nOut;
const unsigned char *zOrig;
unsigned char *z;
@@ -309,8 +307,8 @@ static int SQLITE_TCLAPI utf8_to_utf8(
return TCL_ERROR;
}
zOrig = (unsigned char *)Tcl_GetStringFromObj(objv[1], &n);
z = sqlite3_malloc( n+4 );
n = sqlite3TestHexToBin(zOrig, n, z);
z = sqlite3_malloc64( n+4 );
n = sqlite3TestHexToBin(zOrig, (int)n, z);
z[n] = 0;
nOut = sqlite3Utf8To8(z);
sqlite3TestBinToHex(z,nOut);
@@ -361,7 +359,7 @@ static int SQLITE_TCLAPI read_fts3varint(
int objc,
Tcl_Obj *CONST objv[]
){
int nBlob;
Tcl_Size nBlob;
unsigned char *zBlob;
sqlite3_int64 iVal;
int nVal;
@@ -388,10 +386,10 @@ static int SQLITE_TCLAPI make_fts3record(
Tcl_Obj *CONST objv[]
){
Tcl_Obj **aArg = 0;
int nArg = 0;
Tcl_Size nArg = 0;
unsigned char *aOut = 0;
int nOut = 0;
int nAlloc = 0;
sqlite3_int64 nOut = 0;
sqlite3_int64 nAlloc = 0;
int i;
if( objc!=2 ){
@@ -402,7 +400,7 @@ static int SQLITE_TCLAPI make_fts3record(
return TCL_ERROR;
}
for(i=0; i<nArg; i++){
for(i=0; i<(int)nArg; i++){
sqlite3_int64 iVal;
if( TCL_OK==Tcl_GetWideIntFromObj(0, aArg[i], &iVal) ){
if( nOut+10>nAlloc ){
@@ -417,11 +415,11 @@ static int SQLITE_TCLAPI make_fts3record(
}
nOut += putFts3Varint((char*)&aOut[nOut], iVal);
}else{
int nVal = 0;
Tcl_Size nVal = 0;
char *zVal = Tcl_GetStringFromObj(aArg[i], &nVal);
while( (nOut + nVal)>nAlloc ){
int nNew = nAlloc?nAlloc*2:128;
unsigned char *aNew = sqlite3_realloc(aOut, nNew);
sqlite3_int64 nNew = nAlloc?nAlloc*2:128;
unsigned char *aNew = sqlite3_realloc64(aOut, nNew);
if( aNew==0 ){
sqlite3_free(aOut);
return TCL_ERROR;