diff options
author | jan.nijtmans <jan.nijtmans@noemail.net> | 2025-03-27 17:30:49 +0000 |
---|---|---|
committer | jan.nijtmans <jan.nijtmans@noemail.net> | 2025-03-27 17:30:49 +0000 |
commit | 1f3207a52abfd36650314e9d81dbcdb51b39a9f1 (patch) | |
tree | 9e0b678349372052abb43ec2fb6517401c0ffbe3 /src | |
parent | 7b3477c7764cb48cfc676454f9a35c377cb7c79f (diff) | |
download | sqlite-1f3207a52abfd36650314e9d81dbcdb51b39a9f1.tar.gz sqlite-1f3207a52abfd36650314e9d81dbcdb51b39a9f1.zip |
Fix for forum-post [/forum/forumpost/b5fde3596c|b5fde3596c]. Also fix encoding issue for non-ASCII characters.
Also includes a fix from Stephan Beal, about a missing <stdint.h> include.
FossilOrigin-Name: e60198001e12f85a5d6504ce72226dfceb8666fe5ec649237fa23ae20e8aa32d
Diffstat (limited to 'src')
-rw-r--r-- | src/tclsqlite.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c index c619ffca4..7675a9125 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -76,7 +76,9 @@ # define SQLITE_PTRSIZE 8 # endif # endif /* SQLITE_PTRSIZE */ -# if defined(HAVE_STDINT_H) +# if defined(HAVE_STDINT_H) || (defined(__STDC_VERSION__) && \ + (__STDC_VERSION__ >= 199901L)) +# include <stdint.h> typedef uintptr_t uptr; # elif SQLITE_PTRSIZE==4 typedef unsigned int uptr; @@ -2525,7 +2527,7 @@ static int SQLITE_TCLAPI DbObjCmd( Tcl_Channel in; /* The input file */ int lineno = 0; /* Line number of input file */ char zLineNum[80]; /* Line number print buffer */ - Tcl_DString str; + Tcl_Obj *str; Tcl_Obj *pResult; /* interp result */ const char *zSep; @@ -2609,19 +2611,22 @@ static int SQLITE_TCLAPI DbObjCmd( sqlite3_finalize(pStmt); return TCL_ERROR; } + Tcl_SetChannelOption(NULL, in, "-translation", "auto"); azCol = malloc( sizeof(azCol[0])*(nCol+1) ); if( azCol==0 ) { Tcl_AppendResult(interp, "Error: can't malloc()", (char*)0); Tcl_Close(interp, in); return TCL_ERROR; } - Tcl_DStringInit(&str); + str = Tcl_NewObj(); + Tcl_IncrRefCount(str); (void)sqlite3_exec(pDb->db, "BEGIN", 0, 0, 0); zCommit = "COMMIT"; - while( Tcl_Gets(in, &str)>=0 ) { + while( Tcl_GetsObj(in, str)>=0 ) { char *z; + Tcl_Size byteLen; lineno++; - zLine = Tcl_DStringValue(&str); + zLine = (char *)Tcl_GetByteArrayFromObj(str, &byteLen); azCol[0] = zLine; for(i=0, z=zLine; *z; z++){ if( *z==zSep[0] && strncmp(z, zSep, nSep)==0 ){ @@ -2659,14 +2664,14 @@ static int SQLITE_TCLAPI DbObjCmd( } sqlite3_step(pStmt); rc = sqlite3_reset(pStmt); - Tcl_DStringSetLength(&str, 0); + Tcl_SetObjLength(str, 0); if( rc!=SQLITE_OK ){ Tcl_AppendResult(interp,"Error: ", sqlite3_errmsg(pDb->db), (char*)0); zCommit = "ROLLBACK"; break; } } - Tcl_DStringFree(&str); + Tcl_DecrRefCount(str); free(azCol); Tcl_Close(interp, in); sqlite3_finalize(pStmt); |