Tags: patch

Here is a patch that fixes the problem:

--- tc.nls.c~   2005-02-15 16:09:02.000000000 -0500
+++ tc.nls.c    2007-02-20 00:13:24.090033003 -0500
@@ -88,9 +88,11 @@
 int
 NLSStringWidth(Char *s)
 {
-    int w = 0;
-    while (*s)
-       w += wcwidth(*s++);
+    int w = 0, r;
+    while (*s) {
+       r = wcwidth(*s++);
+       w += (r < 0 ? 4 : r); //non printables are output as \xxx - 4 characters
+    }
     return w;
 }


It worked perfectly, where before when I hit tab on a directory with non-printable file names, the columns did not line up (even if it didn't crash).

With this patch, not only doesn't it crash, but the columns also lined up.

The only question is if it's appropriate to add 4 for non-printables. It all depends on the usage of this function. At the very minimum it should add 0 and not -1.

        -Ariel


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to