-C Simplifications\sto\sthe\sdescription\sof\sthe\snByte\sparameter\sto\ssqlite3_prepare()\nand\sfriends.
-D 2015-02-26T02:33:52.248
+C In\sthe\scommand-line\sshell,\schange\sthe\sunits\son\sthe\s".width"\sseparate\sfrom\nbytes\sto\scharacters.
+D 2015-02-26T14:27:16.982
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 6b9e7677829aa94b9f30949656e27312aefb9a46
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/resolve.c f4d79e31ffa5820c2e3d1740baa5e9b190425f2b
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
F src/select.c e46cef4c224549b439384c88fc7f57ba064dad54
-F src/shell.c f06cca68a3f07e03d35d2f879375967169db6a61
+F src/shell.c c8a769c563b41b16196dfef675b008ba543a492f
F src/sqlite.h.in 62d3997824038cc32335b04aaa18cc8f4c19e9be
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 6d132e7a224ee68b5cefe9222944aac5760ffc20
-R 32aba763c92a19bba8ed1b93e2ee7564
+P 4bee8295e36fb61f903210b6d052ee9b8fb3b6d0
+R 143a1a32cdae3a721c8dd7822db13dda
+T *branch * cli-char-width
+T *sym-cli-char-width *
+T -sym-trunk *
U drh
-Z b332eede7bc32b2767cceb08a9880768
+Z 9e05d9065c7895cfbe90dd1f0cc9db4d
}
#endif
+/*
+** Return the length of a string in characters. Multibyte UTF8 characters
+** count as a single character.
+*/
+static int strlenChar(const char *z){
+ int n = 0;
+ while( *z ){
+ if( (0xc0&*(z++))!=0x80 ) n++;
+ }
+ return n;
+}
+
+/*
+** Print abs(w) characters of string "z" on FILE "out".
+**
+** w is in units of characters, not bytes!
+**
+** The output is always exactly abs(w) characters wide. If z contains
+** more than abs(w) characters, it is truncated. If z contains fewer
+** than abs(w) characters it is padded with spaces. Spaces are added
+** on the right if w>0 (left justification) or on the left if w<0
+** (right justification).
+*/
+static void outputFixedWidth(FILE *out, int w, const char *z){
+ int n = strlenChar(z);
+ int absw = w<0 ? -w : w;
+ int i;
+
+ if( n<=absw ){
+ if( w<0 ) for(i=absw-n; i>0; i--) putc(' ', out);
+ fputs(z, out);
+ if( w>0 ) for(i=absw-n; i>0; i--) putc(' ', out);
+ }else{
+ for(i=n=0; z[i]; i++){
+ if( (z[i]&0xc0)==0x80 ) continue;
+ if( n==absw ) break;
+ n++;
+ }
+ fwrite(z, 1, i, out);
+ }
+}
+
/*
** This is the callback routine that the shell
** invokes for each row of a query result.
w = 0;
}
if( w==0 ){
- w = strlen30(azCol[i] ? azCol[i] : "");
+ w = strlenChar(azCol[i] ? azCol[i] : "");
if( w<10 ) w = 10;
- n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullValue);
+ n = strlenChar(azArg && azArg[i] ? azArg[i] : p->nullValue);
if( w<n ) w = n;
}
if( i<ArraySize(p->actualWidth) ){
p->actualWidth[i] = w;
}
if( p->showHeader ){
- if( w<0 ){
- fprintf(p->out,"%*.*s%s",-w,-w,azCol[i],
- i==nArg-1 ? p->rowSeparator : " ");
- }else{
- fprintf(p->out,"%-*.*s%s",w,w,azCol[i],
- i==nArg-1 ? p->rowSeparator : " ");
- }
+ outputFixedWidth(p->out, w, azCol[i]);
+ fprintf(p->out, "%s", i==nArg-1 ? p->rowSeparator : " ");
}
}
if( p->showHeader ){
w = 10;
}
if( p->mode==MODE_Explain && azArg[i] && strlen30(azArg[i])>w ){
- w = strlen30(azArg[i]);
+ w = strlenChar(azArg[i]);
}
if( i==1 && p->aiIndent && p->pStmt ){
if( p->iIndent<p->nIndent ){
}
p->iIndent++;
}
- if( w<0 ){
- fprintf(p->out,"%*.*s%s",-w,-w,
- azArg[i] ? azArg[i] : p->nullValue,
- i==nArg-1 ? p->rowSeparator : " ");
- }else{
- fprintf(p->out,"%-*.*s%s",w,w,
- azArg[i] ? azArg[i] : p->nullValue,
- i==nArg-1 ? p->rowSeparator : " ");
- }
+ outputFixedWidth(p->out, w, azArg[i] ? azArg[i] : p->nullValue);
+ fprintf(p->out, "%s", i==nArg-1 ? p->rowSeparator : " ");
}
break;
}