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

Changes to console I/O for Fiddle build, to always defer to C library (as before.) A WIP, pending testing with Fiddle build.

FossilOrigin-Name: 45b8061e7568ccca164fe000f1f0a0d984b1c28fad530bc9fdea35793a0f40bc
This commit is contained in:
larrybr
2023-11-15 15:20:52 +00:00
parent 26b57aaed7
commit c283f969aa
5 changed files with 58 additions and 24 deletions

View File

@@ -18,6 +18,8 @@
# define SQLITE_CDECL
#endif
#ifndef SQLITE_SHELL_FIDDLE
#ifndef SHELL_NO_SYSINC
# include <stdarg.h>
# include <string.h>
@@ -498,6 +500,8 @@ SQLITE_INTERNAL_LINKAGE int oPutsUtf8(const char *z){
#endif
}
#endif /* !defined(SQLITE_SHELL_FIDDLE) */
/* Skip over as much z[] input char sequence as is valid UTF-8,
** limited per nAccept char's or whole characters and containing
** no char cn such that ((1<<cn) & ccm)!=0. On return, the
@@ -508,7 +512,7 @@ static const char* zSkipValidUtf8(const char *z, int nAccept, long ccm){
int ng = (nAccept<0)? -nAccept : 0;
const char *pcLimit = (nAccept>=0)? z+nAccept : 0;
assert(z!=0);
while( (pcLimit)? (z<pcLimit) : (ng-- > 0) ){
while( (pcLimit)? (z<pcLimit) : (ng-- != 0) ){
char c = *z;
if( (c & 0x80) == 0 ){
if( ccm != 0L && c < 0x20 && ((1L<<c) & ccm) != 0 ) return z;
@@ -532,6 +536,28 @@ static const char* zSkipValidUtf8(const char *z, int nAccept, long ccm){
return z;
}
#ifdef SQLITE_SHELL_FIDDLE
# define fPutbUtf8(f, cB, nA, cM) \
((f)? fwrite(cB,1,nA,f) : zSkipValidUtf8(cB,nA,cM))
static int oprintf(const char zFmt, ...){
va_list ap;
int rv;
va_start(ap, zFormat);
rv = vfprintf(stdout, zFmt, ap);
va_end(ap);
return rv;
}
static int eprintf(const char zFmt, ...){
va_list ap;
int rv;
va_start(ap, zFormat);
rv = vfprintf(stderr, zFmt, ap);
va_end(ap);
return rv;
}
#else
SQLITE_INTERNAL_LINKAGE int
fPutbUtf8(FILE *pfO, const char *cBuf, int nAccept, long ctrlMask){
const char *zPast = zSkipValidUtf8(cBuf, nAccept, ctrlMask);
@@ -662,3 +688,4 @@ SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){
}
#undef SHELL_INVALID_FILE_PTR
#endif /* !defined(SQLITE_SHELL_FIDDLE) */

View File

@@ -42,6 +42,7 @@ typedef enum StreamsAreConsole {
SAC_AnyConsole = 0x7
} StreamsAreConsole;
#ifndef SQLITE_SHELL_FIDDLE
/*
** Classify the three standard I/O streams according to whether
** they are connected to a console attached to the process.
@@ -262,3 +263,4 @@ shellGetLine(FILE *pfIn, char *zBufPrior, int nLen,
** may have to establish console operating mode, possibly
** in a way that interferes with the above functionality.
*/
#endif /* !defined(SQLITE_SHELL_FIDDLE) */