aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2025-03-26 00:02:15 +0000
committerstephan <stephan@noemail.net>2025-03-26 00:02:15 +0000
commit22d502e33a294f3f2c05d0dc1c51494589ef9724 (patch)
tree1e34a4d29ba1373cc33cc1731f0487c1138adfd4 /src
parent339f9a33b4a9c675b9e7e0457868a2a1b99833fe (diff)
parent6de1c9d55985dc1540deb4ccd4aa8e3a94f129c1 (diff)
downloadsqlite-22d502e33a294f3f2c05d0dc1c51494589ef9724.tar.gz
sqlite-22d502e33a294f3f2c05d0dc1c51494589ef9724.zip
Merge trunk into cygwin-fixes branch. Add .fossil-settings/binary-glob to squelch warnings about *.db files on Cygwin.
FossilOrigin-Name: a8328b921c5504eceacade417e16e713999eff63978caf3418fd79501590b1cb
Diffstat (limited to 'src')
-rw-r--r--src/dbpage.c4
-rw-r--r--src/shell.c.in43
-rw-r--r--src/wal.c6
3 files changed, 42 insertions, 11 deletions
diff --git a/src/dbpage.c b/src/dbpage.c
index eb5ab33fe..f9fdcc5a3 100644
--- a/src/dbpage.c
+++ b/src/dbpage.c
@@ -395,8 +395,8 @@ static int dbpageUpdate(
/* "INSERT INTO dbpage($PGNO,NULL)" causes page number $PGNO and
** all subsequent pages to be deleted. */
pTab->iDbTrunc = iDb;
- pgno--;
- pTab->pgnoTrunc = pgno;
+ pTab->pgnoTrunc = pgno-1;
+ pgno = 1;
}else{
zErr = "bad page value";
goto update_fail;
diff --git a/src/shell.c.in b/src/shell.c.in
index 93d73e6ac..8272956eb 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -785,6 +785,23 @@ int cli_wcswidth(const char *z){
#endif
/*
+** Check to see if z[] is a valid VT100 escape. If it is, then
+** return the number of bytes in the escape sequence. Return 0 if
+** z[] is not a VT100 escape.
+**
+** This routine assumes that z[0] is \033 (ESC).
+*/
+static int isVt100(const unsigned char *z){
+ int i;
+ if( z[1]!='[' ) return 0;
+ i = 2;
+ while( z[i]>=0x30 && z[i]<=0x3f ){ i++; }
+ while( z[i]>=0x20 && z[i]<=0x2f ){ i++; }
+ if( z[i]<0x40 || z[i]>0x7e ) return 0;
+ return i+1;
+}
+
+/*
** Output string zUtf to stdout as w characters. If w is negative,
** then right-justify the text. W is the width in UTF-8 characters, not
** in bytes. This is different from the %*.*s specification in printf
@@ -799,6 +816,7 @@ static void utf8_width_print(FILE *out, int w, const char *zUtf){
unsigned char c;
int i = 0;
int n = 0;
+ int k;
int aw = w<0 ? -w : w;
if( zUtf==0 ) zUtf = "";
while( (c = a[i])!=0 ){
@@ -811,6 +829,8 @@ static void utf8_width_print(FILE *out, int w, const char *zUtf){
}
i += len;
n += x;
+ }else if( c==0x1b && (k = isVt100(&a[i]))>0 ){
+ i += k;
}else if( n>=aw ){
break;
}else{
@@ -3998,9 +4018,14 @@ static char *translateForDisplayAndDup(
i++;
continue;
}
- n++;
- j += 3;
- i++;
+ if( c==0x1b && p->eEscMode==SHELL_ESC_OFF && (k = isVt100(&z[i]))>0 ){
+ i += k;
+ j += k;
+ }else{
+ n++;
+ j += 3;
+ i++;
+ }
}
if( n>=mxWidth && bWordWrap ){
/* Perhaps try to back up to a better place to break the line */
@@ -4066,9 +4091,17 @@ static char *translateForDisplayAndDup(
zOut[j++] = '^';
zOut[j++] = 0x40 + c;
break;
- case SHELL_ESC_OFF:
- zOut[j++] = c;
+ case SHELL_ESC_OFF: {
+ int nn;
+ if( c==0x1b && (nn = isVt100(&z[i]))>0 ){
+ memcpy(&zOut[j], &z[i], nn);
+ j += nn;
+ i += nn - 1;
+ }else{
+ zOut[j++] = c;
+ }
break;
+ }
}
i++;
}
diff --git a/src/wal.c b/src/wal.c
index 7f091a48c..5fe2296d6 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -871,10 +871,8 @@ static void walChecksumBytes(
s1 = s2 = 0;
}
- assert( nByte>=8 );
- assert( (nByte&0x00000007)==0 );
- assert( nByte<=65536 );
- assert( nByte%4==0 );
+ /* nByte is a multiple of 8 between 8 and 65536 */
+ assert( nByte>=8 && (nByte&7)==0 && nByte<=65536 );
if( !nativeCksum ){
do {