]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Begin the process of integrating QRF into the CLI. Adjust makefiles.
authordrh <>
Fri, 7 Nov 2025 14:31:17 +0000 (14:31 +0000)
committerdrh <>
Fri, 7 Nov 2025 14:31:17 +0000 (14:31 +0000)
Include the QRF code in shell.c.  But QRF is not yet used by the CLI.

FossilOrigin-Name: 7596fc32b371e5e657e830c2e80e61b0947320a7359833e915a888a438c2e935

Makefile.msc
ext/qrf/qrf.c
ext/qrf/qrf.h
main.mk
manifest
manifest.uuid
src/shell.c.in

index 9cf622029abac2a96cd87bc25a58a7157ce4ea7c..1a26f1abad19eab194ebc8f0e1b77cc95aeab6ca 100644 (file)
@@ -2388,6 +2388,8 @@ keywordhash.h:    $(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe
 # Source and header files that shell.c depends on
 SHELL_DEP = \
     $(TOP)\src\shell.c.in \
+    $(TOP)\ext\qrf\qrf.c \
+    $(TOP)\ext\qrf\qrf.h \
     $(TOP)\ext\expert\sqlite3expert.c \
     $(TOP)\ext\expert\sqlite3expert.h \
     $(TOP)\ext\intck\sqlite3intck.c \
index 8eda109c474d65a1d96391193224edaf7c761487..1f5590bbb76ab69922eb4568fea50c4fb8ef6923 100644 (file)
 typedef sqlite3_int64 i64;
 
 /* A single line in the EQP output */
-typedef struct EQPGraphRow EQPGraphRow;
-struct EQPGraphRow {
-  int iEqpId;           /* ID for this row */
-  int iParentId;        /* ID of the parent row */
-  EQPGraphRow *pNext;   /* Next row in sequence */
-  char zText[1];        /* Text to display for this row */
+typedef struct qrfEQPGraphRow qrfEQPGraphRow;
+struct qrfEQPGraphRow {
+  int iEqpId;            /* ID for this row */
+  int iParentId;         /* ID of the parent row */
+  qrfEQPGraphRow *pNext; /* Next row in sequence */
+  char zText[1];         /* Text to display for this row */
 };
 
 /* All EQP output is collected into an instance of the following */
-typedef struct EQPGraph EQPGraph;
-struct EQPGraph {
-  EQPGraphRow *pRow;    /* Linked list of all rows of the EQP output */
-  EQPGraphRow *pLast;   /* Last element of the pRow list */
-  char zPrefix[100];    /* Graph prefix */
+typedef struct qrfEQPGraph qrfEQPGraph;
+struct qrfEQPGraph {
+  qrfEQPGraphRow *pRow;  /* Linked list of all rows of the EQP output */
+  qrfEQPGraphRow *pLast; /* Last element of the pRow list */
+  char zPrefix[100];     /* Graph prefix */
 };
 
 /*
@@ -57,7 +57,7 @@ struct Qrf {
       int mxColWth;             /* Maximum display width of any column */
       const char **azCol;       /* Names of output columns (MODE_Line) */
     } sLine;
-    EQPGraph *pGraph;         /* EQP graph (Eqp, Stats, and StatsEst) */
+    qrfEQPGraph *pGraph;      /* EQP graph (Eqp, Stats, and StatsEst) */
     struct {                  /* Content for QRF_STYLE_Explain */
       int nIndent;              /* Slots allocated for aiIndent */
       int iIndent;              /* Current slot */
@@ -104,16 +104,16 @@ static void qrfOom(Qrf *p){
 ** Add a new entry to the EXPLAIN QUERY PLAN data
 */
 static void qrfEqpAppend(Qrf *p, int iEqpId, int p2, const char *zText){
-  EQPGraphRow *pNew;
+  qrfEQPGraphRow *pNew;
   sqlite3_int64 nText;
   if( zText==0 ) return;
   if( p->u.pGraph==0 ){
-    p->u.pGraph = sqlite3_malloc64( sizeof(EQPGraph) );
+    p->u.pGraph = sqlite3_malloc64( sizeof(qrfEQPGraph) );
     if( p->u.pGraph==0 ){
       qrfOom(p);
       return;
     }
-    memset(p->u.pGraph, 0, sizeof(EQPGraph) );
+    memset(p->u.pGraph, 0, sizeof(qrfEQPGraph) );
   }
   nText = strlen(zText);
   pNew = sqlite3_malloc64( sizeof(*pNew) + nText );
@@ -138,7 +138,7 @@ static void qrfEqpAppend(Qrf *p, int iEqpId, int p2, const char *zText){
 ** in p->u.pGraph.
 */
 static void qrfEqpReset(Qrf *p){
-  EQPGraphRow *pRow, *pNext;
+  qrfEQPGraphRow *pRow, *pNext;
   if( p->u.pGraph ){
     for(pRow = p->u.pGraph->pRow; pRow; pRow = pNext){
       pNext = pRow->pNext;
@@ -152,8 +152,8 @@ static void qrfEqpReset(Qrf *p){
 /* Return the next EXPLAIN QUERY PLAN line with iEqpId that occurs after
 ** pOld, or return the first such line if pOld is NULL
 */
-static EQPGraphRow *qrfEqpNextRow(Qrf *p, int iEqpId, EQPGraphRow *pOld){
-  EQPGraphRow *pRow = pOld ? pOld->pNext : p->u.pGraph->pRow;
+static qrfEQPGraphRow *qrfEqpNextRow(Qrf *p, int iEqpId, qrfEQPGraphRow *pOld){
+  qrfEQPGraphRow *pRow = pOld ? pOld->pNext : p->u.pGraph->pRow;
   while( pRow && pRow->iParentId!=iEqpId ) pRow = pRow->pNext;
   return pRow;
 }
@@ -162,7 +162,7 @@ static EQPGraphRow *qrfEqpNextRow(Qrf *p, int iEqpId, EQPGraphRow *pOld){
 ** recursively to render sublevels.
 */
 static void qrfEqpRenderLevel(Qrf *p, int iEqpId){
-  EQPGraphRow *pRow, *pNext;
+  qrfEQPGraphRow *pRow, *pNext;
   i64 n = strlen(p->u.pGraph->zPrefix);
   char *z;
   for(pRow = qrfEqpNextRow(p, iEqpId, 0); pRow; pRow = pNext){
@@ -182,7 +182,7 @@ static void qrfEqpRenderLevel(Qrf *p, int iEqpId){
 ** Display and reset the EXPLAIN QUERY PLAN data
 */
 static void qrfEqpRender(Qrf *p, i64 nCycle){
-  EQPGraphRow *pRow;
+  qrfEQPGraphRow *pRow;
   if( p->u.pGraph!=0 && (pRow = p->u.pGraph->pRow)!=0 ){
     if( pRow->zText[0]=='-' ){
       if( pRow->pNext==0 ){
index 7d18a9e1d65881ed812dcddb66a90fbf8777483c..223a2ec304ec5a280d5dfa9ed7b1751fe96fb889 100644 (file)
@@ -129,4 +129,23 @@ int sqlite3_format_query_result(
 #define QRF_SW_Off      1 /* This setting is forced off */
 #define QRF_SW_On       2 /* This setting is forced on */
 
+/*
+** Auxiliary routines contined within this module that might be useful
+** in other contexts, and which are therefore exported.
+*/
+/*
+** Return an estimate of the width, in columns, for the single Unicode
+** character c.  For normal characters, the answer is always 1.  But the
+** estimate might be 0 or 2 for zero-width and double-width characters.
+**
+** Different display devices display unicode using different widths.  So
+** it is impossible to know that true display width with 100% accuracy.
+** Inaccuracies in the width estimates might cause columns to be misaligned.
+** Unfortunately, there is nothing we can do about that.
+*/
+int sqlite3_qrf_wcwidth(int c);
+
+
+
+
 #endif /* !defined(SQLITE_QRF_H) */
diff --git a/main.mk b/main.mk
index a88f5469bacd991dba796362eda0fbe1f88de053..9ed96aab6a533740f14cefa53f6bc24864e1891a 100644 (file)
--- a/main.mk
+++ b/main.mk
@@ -2341,6 +2341,8 @@ mptest:   mptester$(T.exe)
 # Source and header files that shell.c depends on
 SHELL_DEP = \
     $(TOP)/src/shell.c.in \
+    $(TOP)/ext/qrf/qrf.c \
+    $(TOP)/ext/qrf/qrf.h \
     $(TOP)/ext/expert/sqlite3expert.c \
     $(TOP)/ext/expert/sqlite3expert.h \
     $(TOP)/ext/intck/sqlite3intck.c \
index 573e98b7779667310e20208d2b16ec4c2ec115b2..21d8803608c8dd3a2a0c231a5a055dd68948bfd6 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,12 +1,12 @@
-C Update\sdocumentation\sto\sclarify\sthat\smxTotalWidth\sand\smxLength\sare\snot\nyet\simplemented.
-D 2025-11-07T13:23:29.694
+C Begin\sthe\sprocess\sof\sintegrating\sQRF\sinto\sthe\sCLI.\s\sAdjust\smakefiles.\nInclude\sthe\sQRF\scode\sin\sshell.c.\s\sBut\sQRF\sis\snot\syet\sused\sby\sthe\sCLI.
+D 2025-11-07T14:31:17.711
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md 6bc480fc673fb4acbc4094e77edb326267dd460162d7723c7f30bee2d3d9e97d
 F Makefile.in 3ce07126d7e87c7464301482e161fdae6a51d0a2aa06b200b8f0000ef4d6163b
 F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0
-F Makefile.msc d6b89223071f1964940c8d311236ff37533fd5a674b46f47e01a617b40688357
+F Makefile.msc dd05d27472da51ecabf01dee8c1b06ae6e1b55740d0966bfe9dc663c78e6a240
 F README.md dae499194b75deed76a13a4a83c82493f2530331882d7dfe5754d63287d3f8f7
 F VERSION 16eddb43056a79c1977427ab7a05f3457c373fa159dcdced8754eb89ce7e06b8
 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5
@@ -417,8 +417,8 @@ F ext/misc/windirent.h 02211ce51f3034c675f2dbf4d228194d51b3ee05734678bad5106fff6
 F ext/misc/zipfile.c 09e6e3a3ff40a99677de3c0bc6569bd5f4709b1844ac3d1c1452a456c5a62f1c
 F ext/misc/zorder.c bddff2e1b9661a90c95c2a9a9c7ecd8908afab5763256294dd12d609d4664eee
 F ext/qrf/README.md d91dccf517075567048e510b527cb7785d2ac73a5dd0e9076b1ccd513de9f6cf
-F ext/qrf/qrf.c 2b4584ebe730e5fbedd2aa9444b8ff1ddb27d0cc5382f57f8319585f66d24688
-F ext/qrf/qrf.h a02d156e54e05c5ef66012b66817beecd6e2c60327491d98eb11361e7c0a19e2
+F ext/qrf/qrf.c 074fc3f4f9e484a3bbf948e8360e52877556111d9948e2a197a6c67725972c16
+F ext/qrf/qrf.h c795d389f71c00c612ce3e4d428c5030288f57a6cde53e84675662363ddf66b9
 F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8
 F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255
 F ext/rbu/rbu10.test 7c22caa32c2ff26983ca8320779a31495a6555737684af7aba3daaf762ef3363
@@ -657,7 +657,7 @@ F ext/wasm/tests/opfs/sahpool/index.html be736567fd92d3ecb9754c145755037cbbd2bca
 F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js f264925cfc82155de38cecb3d204c36e0f6991460fff0cb7c15079454679a4e2
 F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61
 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
-F main.mk 27873023570af57091768db5ed89e449e6a1a4ec9f72a43823871e435f89efea
+F main.mk 9ee54d4a0eb6c78ba6a3065a70831a9a016c8b1c92337b88492089eee4a49fcf
 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421
@@ -735,7 +735,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c 5616fbcf3b833c7c705b24371828215ad0925d0c0073216c4f153348d5753f0a
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c ba9cd07ffa3277883c1986085f6ddc4320f4d35d5f212ab58df79a7ecc1a576a
-F src/shell.c.in 265015aaec4580a0bef50ff570ec8d2813498ee49dcfdf9757e76f3b2a59fc97
+F src/shell.c.in 7d1786d6173d7b1699b95edf135d596ba4544ee6585823d3abee26ba3ca31a81
 F src/sqlite.h.in 43f60117ce68847b9d4e7fa43c2ac42bb324185e66b924d3114b24d4037fc263
 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
 F src/sqlite3ext.h 7f236ca1b175ffe03316d974ef57df79b3938466c28d2f95caef5e08c57f3a52
@@ -2173,8 +2173,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 3f327e8fbc295b43c79118f8f49f8d2e20c2f3ac96e3b7f996720dab858d8199
-R 291d8ef19851bb32af2d813dcd936c30
+P c25806fc5491554f1cd55174c6cf98b509d619e3011b8e26abdf05b24133a6e8
+R 7544920a37eca1e4feb4987f63beb1a3
 U drh
-Z 66cdea4d6e2d02de091d01bffff99742
+Z 7d3a34f734ef8b065b7851ca62716052
 # Remove this line to create a well-formed Fossil manifest.
index 0a847ffaf36e09aed4af9b21992e51f94e7afbc0..1cb2887217db7216a186347546be5c372a960871 100644 (file)
@@ -1 +1 @@
-c25806fc5491554f1cd55174c6cf98b509d619e3011b8e26abdf05b24133a6e8
+7596fc32b371e5e657e830c2e80e61b0947320a7359833e915a888a438c2e935
index bd44a325102e33b54fa1760e0b3843eb41268c87..8ffed17e3337e44aee4452d67625c9bfb242d1c2 100644 (file)
@@ -239,6 +239,8 @@ extern LPWSTR sqlite3_win32_utf8_to_unicode(const char *zText);
 
 INCLUDE ../ext/misc/sqlite3_stdio.h
 INCLUDE ../ext/misc/sqlite3_stdio.c
+INCLUDE ../ext/qrf/qrf.h
+INCLUDE ../ext/qrf/qrf.c
 
 /* Use console I/O package as a direct INCLUDE. */
 #define SQLITE_INTERNAL_LINKAGE static
@@ -651,111 +653,6 @@ static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){
 }
 #endif
 
-/* Lookup table to estimate the number of columns consumed by a Unicode
-** character.
-*/
-static const struct {
-  unsigned char w;    /* Width of the character in columns */
-  int iFirst;         /* First character in a span having this width */
-} aUWidth[] = {
-   /* {1, 0x00000}, */
-  {0, 0x00300},  {1, 0x00370},  {0, 0x00483},  {1, 0x00487},  {0, 0x00488},
-  {1, 0x0048a},  {0, 0x00591},  {1, 0x005be},  {0, 0x005bf},  {1, 0x005c0},
-  {0, 0x005c1},  {1, 0x005c3},  {0, 0x005c4},  {1, 0x005c6},  {0, 0x005c7},
-  {1, 0x005c8},  {0, 0x00600},  {1, 0x00604},  {0, 0x00610},  {1, 0x00616},
-  {0, 0x0064b},  {1, 0x0065f},  {0, 0x00670},  {1, 0x00671},  {0, 0x006d6},
-  {1, 0x006e5},  {0, 0x006e7},  {1, 0x006e9},  {0, 0x006ea},  {1, 0x006ee},
-  {0, 0x0070f},  {1, 0x00710},  {0, 0x00711},  {1, 0x00712},  {0, 0x00730},
-  {1, 0x0074b},  {0, 0x007a6},  {1, 0x007b1},  {0, 0x007eb},  {1, 0x007f4},
-  {0, 0x00901},  {1, 0x00903},  {0, 0x0093c},  {1, 0x0093d},  {0, 0x00941},
-  {1, 0x00949},  {0, 0x0094d},  {1, 0x0094e},  {0, 0x00951},  {1, 0x00955},
-  {0, 0x00962},  {1, 0x00964},  {0, 0x00981},  {1, 0x00982},  {0, 0x009bc},
-  {1, 0x009bd},  {0, 0x009c1},  {1, 0x009c5},  {0, 0x009cd},  {1, 0x009ce},
-  {0, 0x009e2},  {1, 0x009e4},  {0, 0x00a01},  {1, 0x00a03},  {0, 0x00a3c},
-  {1, 0x00a3d},  {0, 0x00a41},  {1, 0x00a43},  {0, 0x00a47},  {1, 0x00a49},
-  {0, 0x00a4b},  {1, 0x00a4e},  {0, 0x00a70},  {1, 0x00a72},  {0, 0x00a81},
-  {1, 0x00a83},  {0, 0x00abc},  {1, 0x00abd},  {0, 0x00ac1},  {1, 0x00ac6},
-  {0, 0x00ac7},  {1, 0x00ac9},  {0, 0x00acd},  {1, 0x00ace},  {0, 0x00ae2},
-  {1, 0x00ae4},  {0, 0x00b01},  {1, 0x00b02},  {0, 0x00b3c},  {1, 0x00b3d},
-  {0, 0x00b3f},  {1, 0x00b40},  {0, 0x00b41},  {1, 0x00b44},  {0, 0x00b4d},
-  {1, 0x00b4e},  {0, 0x00b56},  {1, 0x00b57},  {0, 0x00b82},  {1, 0x00b83},
-  {0, 0x00bc0},  {1, 0x00bc1},  {0, 0x00bcd},  {1, 0x00bce},  {0, 0x00c3e},
-  {1, 0x00c41},  {0, 0x00c46},  {1, 0x00c49},  {0, 0x00c4a},  {1, 0x00c4e},
-  {0, 0x00c55},  {1, 0x00c57},  {0, 0x00cbc},  {1, 0x00cbd},  {0, 0x00cbf},
-  {1, 0x00cc0},  {0, 0x00cc6},  {1, 0x00cc7},  {0, 0x00ccc},  {1, 0x00cce},
-  {0, 0x00ce2},  {1, 0x00ce4},  {0, 0x00d41},  {1, 0x00d44},  {0, 0x00d4d},
-  {1, 0x00d4e},  {0, 0x00dca},  {1, 0x00dcb},  {0, 0x00dd2},  {1, 0x00dd5},
-  {0, 0x00dd6},  {1, 0x00dd7},  {0, 0x00e31},  {1, 0x00e32},  {0, 0x00e34},
-  {1, 0x00e3b},  {0, 0x00e47},  {1, 0x00e4f},  {0, 0x00eb1},  {1, 0x00eb2},
-  {0, 0x00eb4},  {1, 0x00eba},  {0, 0x00ebb},  {1, 0x00ebd},  {0, 0x00ec8},
-  {1, 0x00ece},  {0, 0x00f18},  {1, 0x00f1a},  {0, 0x00f35},  {1, 0x00f36},
-  {0, 0x00f37},  {1, 0x00f38},  {0, 0x00f39},  {1, 0x00f3a},  {0, 0x00f71},
-  {1, 0x00f7f},  {0, 0x00f80},  {1, 0x00f85},  {0, 0x00f86},  {1, 0x00f88},
-  {0, 0x00f90},  {1, 0x00f98},  {0, 0x00f99},  {1, 0x00fbd},  {0, 0x00fc6},
-  {1, 0x00fc7},  {0, 0x0102d},  {1, 0x01031},  {0, 0x01032},  {1, 0x01033},
-  {0, 0x01036},  {1, 0x01038},  {0, 0x01039},  {1, 0x0103a},  {0, 0x01058},
-  {1, 0x0105a},  {2, 0x01100},  {0, 0x01160},  {1, 0x01200},  {0, 0x0135f},
-  {1, 0x01360},  {0, 0x01712},  {1, 0x01715},  {0, 0x01732},  {1, 0x01735},
-  {0, 0x01752},  {1, 0x01754},  {0, 0x01772},  {1, 0x01774},  {0, 0x017b4},
-  {1, 0x017b6},  {0, 0x017b7},  {1, 0x017be},  {0, 0x017c6},  {1, 0x017c7},
-  {0, 0x017c9},  {1, 0x017d4},  {0, 0x017dd},  {1, 0x017de},  {0, 0x0180b},
-  {1, 0x0180e},  {0, 0x018a9},  {1, 0x018aa},  {0, 0x01920},  {1, 0x01923},
-  {0, 0x01927},  {1, 0x01929},  {0, 0x01932},  {1, 0x01933},  {0, 0x01939},
-  {1, 0x0193c},  {0, 0x01a17},  {1, 0x01a19},  {0, 0x01b00},  {1, 0x01b04},
-  {0, 0x01b34},  {1, 0x01b35},  {0, 0x01b36},  {1, 0x01b3b},  {0, 0x01b3c},
-  {1, 0x01b3d},  {0, 0x01b42},  {1, 0x01b43},  {0, 0x01b6b},  {1, 0x01b74},
-  {0, 0x01dc0},  {1, 0x01dcb},  {0, 0x01dfe},  {1, 0x01e00},  {0, 0x0200b},
-  {1, 0x02010},  {0, 0x0202a},  {1, 0x0202f},  {0, 0x02060},  {1, 0x02064},
-  {0, 0x0206a},  {1, 0x02070},  {0, 0x020d0},  {1, 0x020f0},  {2, 0x02329},
-  {1, 0x0232b},  {2, 0x02e80},  {0, 0x0302a},  {2, 0x03030},  {1, 0x0303f},
-  {2, 0x03040},  {0, 0x03099},  {2, 0x0309b},  {1, 0x0a4d0},  {0, 0x0a806},
-  {1, 0x0a807},  {0, 0x0a80b},  {1, 0x0a80c},  {0, 0x0a825},  {1, 0x0a827},
-  {2, 0x0ac00},  {1, 0x0d7a4},  {2, 0x0f900},  {1, 0x0fb00},  {0, 0x0fb1e},
-  {1, 0x0fb1f},  {0, 0x0fe00},  {2, 0x0fe10},  {1, 0x0fe1a},  {0, 0x0fe20},
-  {1, 0x0fe24},  {2, 0x0fe30},  {1, 0x0fe70},  {0, 0x0feff},  {2, 0x0ff00},
-  {1, 0x0ff61},  {2, 0x0ffe0},  {1, 0x0ffe7},  {0, 0x0fff9},  {1, 0x0fffc},
-  {0, 0x10a01},  {1, 0x10a04},  {0, 0x10a05},  {1, 0x10a07},  {0, 0x10a0c},
-  {1, 0x10a10},  {0, 0x10a38},  {1, 0x10a3b},  {0, 0x10a3f},  {1, 0x10a40},
-  {0, 0x1d167},  {1, 0x1d16a},  {0, 0x1d173},  {1, 0x1d183},  {0, 0x1d185},
-  {1, 0x1d18c},  {0, 0x1d1aa},  {1, 0x1d1ae},  {0, 0x1d242},  {1, 0x1d245},
-  {2, 0x20000},  {1, 0x2fffe},  {2, 0x30000},  {1, 0x3fffe},  {0, 0xe0001},
-  {1, 0xe0002},  {0, 0xe0020},  {1, 0xe0080},  {0, 0xe0100},  {1, 0xe01f0}
-};
-
-/*
-** Return an estimate of the width, in columns, for the single Unicode
-** character c.  For normal characters, the answer is always 1.  But the
-** estimate might be 0 or 2 for zero-width and double-width characters.
-**
-** Different display devices display unicode using different widths.  So
-** it is impossible to know that true display width with 100% accuracy.
-** Inaccuracies in the width estimates might cause columns to be misaligned.
-** Unfortunately, there is nothing we can do about that.
-*/
-int cli_wcwidth(int c){
-  int iFirst, iLast;
-
-  /* Fast path for common characters */
-  if( c<=0x300 ) return 1;
-
-  /* The general case */
-  iFirst = 0;
-  iLast = sizeof(aUWidth)/sizeof(aUWidth[0]) - 1;
-  while( iFirst<iLast-1 ){
-    int iMid = (iFirst+iLast)/2;
-    int cMid = aUWidth[iMid].iFirst;
-    if( cMid < c ){
-      iFirst = iMid;
-    }else if( cMid > c ){
-      iLast = iMid - 1;
-    }else{
-      return aUWidth[iMid].w;
-    }
-  }
-  if( aUWidth[iLast].iFirst > c ) return aUWidth[iFirst].w;
-  return aUWidth[iLast].w;
-}
-
 /*
 ** Compute the value and length of a multi-byte UTF-8 character that
 ** begins at z[0].   Return the length.  Write the Unicode value into *pU.
@@ -800,7 +697,7 @@ int cli_wcswidth(const char *z){
       int u;
       int len = decodeUtf8(&a[i], &u);
       i += len;
-      n += cli_wcwidth(u);
+      n += sqlite3_qrf_wcwidth(u);
     }else if( c>=' ' ){
       n++;
       i++;
@@ -861,7 +758,7 @@ static void utf8_width_print(FILE *out, int w, const char *zUtf){
     if( (c&0xc0)==0xc0 ){
       int u;
       int len = decodeUtf8(a+i, &u);
-      int x = cli_wcwidth(u);
+      int x = sqlite3_qrf_wcwidth(u);
       if( x+n>aw ){
         break;
       }
@@ -938,7 +835,7 @@ static int strlenChar(const char *z){
       int u = 0;
       int len = decodeUtf8((const u8*)z, &u);
       z += len;
-      n += cli_wcwidth(u);
+      n += sqlite3_qrf_wcwidth(u);
     }
   }
   return n;
@@ -4068,7 +3965,7 @@ static char *translateForDisplayAndDup(
       int len = decodeUtf8(&z[i], &u);
       i += len;
       j += len;
-      n += cli_wcwidth(u);
+      n += sqlite3_qrf_wcwidth(u);
       continue;
     }
     if( c>=' ' ){
@@ -4132,7 +4029,7 @@ static char *translateForDisplayAndDup(
       int u;
       int len = decodeUtf8(&z[i], &u);
       do{ zOut[j++] = z[i++]; }while( (--len)>0 );
-      n += cli_wcwidth(u);
+      n += sqlite3_qrf_wcwidth(u);
       continue;
     }
     if( c>=' ' ){