Hi Axel,

On 2023-01-05 03:25, Axel Beckert wrote:
> Hi Aurelien,
> 
> Axel Beckert wrote:
> > Aurelien Jarno wrote:
> > > An alternative is to not try to support all systems and reinvent the
> > > wheel, and instead assume a POSIX system.
> > 
> > I'd say on Debian — independent of the actually used kernel — we can
> > do assume this at least.
> > 
> > > That way the attached patch can be used.
> > 
> > Nice patch! Thanks!
> 
> Hrm, with that patch, autopkgtest fails the test case for #600246,
> i.e. it seems to reopen the infamous and seemingly non-trivial
> https://bugs.debian.org/600246 — not sure why though. (Wonder if
> Thorsten's patch works better for #600246 than the current one. Or
> maybe my way of testing is borked?)

It appear I tried to replace too much code with the glibc function,
only the wide array can be easily replaced by wcwidth. I have attached
an updated version of the patch. It appears to fix the reported bug and
still pass the autopkgtest.

Cheers
Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurel...@aurel32.net                 http://www.aurel32.net
--- screen-4.9.0.orig/encoding.c
+++ screen-4.9.0/encoding.c
@@ -22,6 +22,7 @@
  */
 
 #include <sys/types.h>
+#include <wchar.h>
 
 #include "config.h"
 #include "screen.h"
@@ -1145,127 +1146,10 @@ int c;
     {0xF0000, 0xFFFFD},
     {0x100000, 0x10FFFD},
   };
-  /* A sorted list of intervals of double width characters generated by
-   * https://github.com/GNOME/glib/blob/glib-2-50/glib/gen-unicode-tables.pl */
-  static const struct interval wide[] = {
-    {0x1100, 0x115F},
-    {0x231A, 0x231B},
-    {0x2329, 0x232A},
-    {0x23E9, 0x23EC},
-    {0x23F0, 0x23F0},
-    {0x23F3, 0x23F3},
-    {0x25FD, 0x25FE},
-    {0x2614, 0x2615},
-    {0x2648, 0x2653},
-    {0x267F, 0x267F},
-    {0x2693, 0x2693},
-    {0x26A1, 0x26A1},
-    {0x26AA, 0x26AB},
-    {0x26BD, 0x26BE},
-    {0x26C4, 0x26C5},
-    {0x26CE, 0x26CE},
-    {0x26D4, 0x26D4},
-    {0x26EA, 0x26EA},
-    {0x26F2, 0x26F3},
-    {0x26F5, 0x26F5},
-    {0x26FA, 0x26FA},
-    {0x26FD, 0x26FD},
-    {0x2705, 0x2705},
-    {0x270A, 0x270B},
-    {0x2728, 0x2728},
-    {0x274C, 0x274C},
-    {0x274E, 0x274E},
-    {0x2753, 0x2755},
-    {0x2757, 0x2757},
-    {0x2795, 0x2797},
-    {0x27B0, 0x27B0},
-    {0x27BF, 0x27BF},
-    {0x2B1B, 0x2B1C},
-    {0x2B50, 0x2B50},
-    {0x2B55, 0x2B55},
-    {0x2E80, 0x2E99},
-    {0x2E9B, 0x2EF3},
-    {0x2F00, 0x2FD5},
-    {0x2FF0, 0x2FFB},
-    {0x3000, 0x303E},
-    {0x3041, 0x3096},
-    {0x3099, 0x30FF},
-    {0x3105, 0x312F},
-    {0x3131, 0x318E},
-    {0x3190, 0x31BA},
-    {0x31C0, 0x31E3},
-    {0x31F0, 0x321E},
-    {0x3220, 0x3247},
-    {0x3250, 0x4DBF},
-    {0x4E00, 0xA48C},
-    {0xA490, 0xA4C6},
-    {0xA960, 0xA97C},
-    {0xAC00, 0xD7A3},
-    {0xF900, 0xFAFF},
-    {0xFE10, 0xFE19},
-    {0xFE30, 0xFE52},
-    {0xFE54, 0xFE66},
-    {0xFE68, 0xFE6B},
-    {0xFF01, 0xFF60},
-    {0xFFE0, 0xFFE6},
-    {0x16FE0, 0x16FE3},
-    {0x17000, 0x187F7},
-    {0x18800, 0x18AF2},
-    {0x1B000, 0x1B11E},
-    {0x1B150, 0x1B152},
-    {0x1B164, 0x1B167},
-    {0x1B170, 0x1B2FB},
-    {0x1F004, 0x1F004},
-    {0x1F0CF, 0x1F0CF},
-    {0x1F18E, 0x1F18E},
-    {0x1F191, 0x1F19A},
-    {0x1F200, 0x1F202},
-    {0x1F210, 0x1F23B},
-    {0x1F240, 0x1F248},
-    {0x1F250, 0x1F251},
-    {0x1F260, 0x1F265},
-    {0x1F300, 0x1F320},
-    {0x1F32D, 0x1F335},
-    {0x1F337, 0x1F37C},
-    {0x1F37E, 0x1F393},
-    {0x1F3A0, 0x1F3CA},
-    {0x1F3CF, 0x1F3D3},
-    {0x1F3E0, 0x1F3F0},
-    {0x1F3F4, 0x1F3F4},
-    {0x1F3F8, 0x1F43E},
-    {0x1F440, 0x1F440},
-    {0x1F442, 0x1F4FC},
-    {0x1F4FF, 0x1F53D},
-    {0x1F54B, 0x1F54E},
-    {0x1F550, 0x1F567},
-    {0x1F57A, 0x1F57A},
-    {0x1F595, 0x1F596},
-    {0x1F5A4, 0x1F5A4},
-    {0x1F5FB, 0x1F64F},
-    {0x1F680, 0x1F6C5},
-    {0x1F6CC, 0x1F6CC},
-    {0x1F6D0, 0x1F6D2},
-    {0x1F6D5, 0x1F6D5},
-    {0x1F6EB, 0x1F6EC},
-    {0x1F6F4, 0x1F6FA},
-    {0x1F7E0, 0x1F7EB},
-    {0x1F90D, 0x1F971},
-    {0x1F973, 0x1F976},
-    {0x1F97A, 0x1F9A2},
-    {0x1F9A5, 0x1F9AA},
-    {0x1F9AE, 0x1F9CA},
-    {0x1F9CD, 0x1F9FF},
-    {0x1FA70, 0x1FA73},
-    {0x1FA78, 0x1FA7A},
-    {0x1FA80, 0x1FA82},
-    {0x1FA90, 0x1FA95},
-    {0x20000, 0x2FFFD},
-    {0x30000, 0x3FFFD},
-  };
 
   if (c >= 0xdf00 && c <= 0xdfff)
     return 1;			/* dw combining sequence */
-  return ((bisearch(c, wide, sizeof(wide) / sizeof(struct interval) - 1)) ||
+  return ((wcwidth(c) == 2) ||
           (cjkwidth &&
            bisearch(c, ambiguous,
 	            sizeof(ambiguous) / sizeof(struct interval) - 1)));

Reply via email to