diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dbpage.c | 4 | ||||
-rw-r--r-- | src/shell.c.in | 43 | ||||
-rw-r--r-- | src/wal.c | 6 |
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++; } @@ -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 { |