Fossil SCM

Fix the unicode code-point width estimating function to align with the SQLite CLI.

drh 2024-09-30 18:21 trunk
Commit e483b3b15fad08e6dc03fe1d7f304d6cee69db48539dd3a2912561813ae9b8d4
1 file changed +1 -4
+1 -4
--- src/comformat.c
+++ src/comformat.c
@@ -39,11 +39,11 @@
3939
*/
4040
static const struct {
4141
unsigned char w; /* Width of the character in columns */
4242
int iFirst; /* First character in a span having this width */
4343
} aUWidth[] = {
44
- /* {0, 0x00000}, {1, 0x00020}, {0, 0x0007f}, {1, 0x000a0}, */
44
+ /* {1, 0x00000}, */
4545
{0, 0x00300}, {1, 0x00370}, {0, 0x00483}, {1, 0x00487}, {0, 0x00488},
4646
{1, 0x0048a}, {0, 0x00591}, {1, 0x005be}, {0, 0x005bf}, {1, 0x005c0},
4747
{0, 0x005c1}, {1, 0x005c3}, {0, 0x005c4}, {1, 0x005c6}, {0, 0x005c7},
4848
{1, 0x005c8}, {0, 0x00600}, {1, 0x00604}, {0, 0x00610}, {1, 0x00616},
4949
{0, 0x0064b}, {1, 0x0065f}, {0, 0x00670}, {1, 0x00671}, {0, 0x006d6},
@@ -117,13 +117,10 @@
117117
*/
118118
static int cli_wcwidth(int c){
119119
int iFirst, iLast;
120120
121121
/* Fast path for common characters */
122
- if( c<0x20 ) return 0;
123
- if( c<0x7f ) return 1;
124
- if( c<0xa0 ) return 0;
125122
if( c<=0x300 ) return 1;
126123
127124
/* The general case */
128125
iFirst = 0;
129126
iLast = sizeof(aUWidth)/sizeof(aUWidth[0]) - 1;
130127
--- src/comformat.c
+++ src/comformat.c
@@ -39,11 +39,11 @@
39 */
40 static const struct {
41 unsigned char w; /* Width of the character in columns */
42 int iFirst; /* First character in a span having this width */
43 } aUWidth[] = {
44 /* {0, 0x00000}, {1, 0x00020}, {0, 0x0007f}, {1, 0x000a0}, */
45 {0, 0x00300}, {1, 0x00370}, {0, 0x00483}, {1, 0x00487}, {0, 0x00488},
46 {1, 0x0048a}, {0, 0x00591}, {1, 0x005be}, {0, 0x005bf}, {1, 0x005c0},
47 {0, 0x005c1}, {1, 0x005c3}, {0, 0x005c4}, {1, 0x005c6}, {0, 0x005c7},
48 {1, 0x005c8}, {0, 0x00600}, {1, 0x00604}, {0, 0x00610}, {1, 0x00616},
49 {0, 0x0064b}, {1, 0x0065f}, {0, 0x00670}, {1, 0x00671}, {0, 0x006d6},
@@ -117,13 +117,10 @@
117 */
118 static int cli_wcwidth(int c){
119 int iFirst, iLast;
120
121 /* Fast path for common characters */
122 if( c<0x20 ) return 0;
123 if( c<0x7f ) return 1;
124 if( c<0xa0 ) return 0;
125 if( c<=0x300 ) return 1;
126
127 /* The general case */
128 iFirst = 0;
129 iLast = sizeof(aUWidth)/sizeof(aUWidth[0]) - 1;
130
--- src/comformat.c
+++ src/comformat.c
@@ -39,11 +39,11 @@
39 */
40 static const struct {
41 unsigned char w; /* Width of the character in columns */
42 int iFirst; /* First character in a span having this width */
43 } aUWidth[] = {
44 /* {1, 0x00000}, */
45 {0, 0x00300}, {1, 0x00370}, {0, 0x00483}, {1, 0x00487}, {0, 0x00488},
46 {1, 0x0048a}, {0, 0x00591}, {1, 0x005be}, {0, 0x005bf}, {1, 0x005c0},
47 {0, 0x005c1}, {1, 0x005c3}, {0, 0x005c4}, {1, 0x005c6}, {0, 0x005c7},
48 {1, 0x005c8}, {0, 0x00600}, {1, 0x00604}, {0, 0x00610}, {1, 0x00616},
49 {0, 0x0064b}, {1, 0x0065f}, {0, 0x00670}, {1, 0x00671}, {0, 0x006d6},
@@ -117,13 +117,10 @@
117 */
118 static int cli_wcwidth(int c){
119 int iFirst, iLast;
120
121 /* Fast path for common characters */
 
 
 
122 if( c<=0x300 ) return 1;
123
124 /* The general case */
125 iFirst = 0;
126 iLast = sizeof(aUWidth)/sizeof(aUWidth[0]) - 1;
127

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button