Hi Everyone,

This patch should allow our /bin/(color)ls to output Chinese,
Japanese, Korean, and all European languages(including Russian)
correctly.  Thinker and I both tested this independently.
isprint() already checks for _CTYPE stuff that Ache asked us to check.

Thinker also fixed the infinite loop in this patch.
This should all us to catch up with GNU/Linux and gnuls somewhat. :)

Please review this patch and comment on it.  I plan to commit
this in a few days if there are no more objections.

Thanks, 
Michael

On Mon, Mar 19, 2001 at 07:54:38PM -0600, Michael C . Wu scribbled:
| Hi everyone,
| Is this satisfactory with you all?  
| Ache: how should we check for Russian and single-byte char compatibility?
| ----- Forwarded message from thinker <[EMAIL PROTECTED]> -----
| From: thinker <[EMAIL PROTECTED]>
| 
| Following is new patch file for /bin/ls.
| -------------------------------------
| --- util.c.orig       Sun Mar 18 16:35:12 2001
| +++ util.c    Tue Mar 20 09:49:47 2001
| @@ -52,6 +52,7 @@
|  #include <stdio.h>
|  #include <stdlib.h>
|  #include <string.h>
| +#include <rune.h>
|  
|  #include "ls.h"
|  #include "extern.h"
| @@ -60,15 +61,36 @@
|  prn_printable(s)
|       const char *s;
|  {
| -     unsigned char c;
| -     int n;
| +     const char *p1, *p2;
| +     char *r, *ri;
| +     int len, dc;
| +     rune_t c;
|  
| -     for (n = 0; (c = *s) != '\0'; ++s, ++n)
| -             if (isprint(c))
| -                     putchar(c);
| -             else
| -                     putchar('?');
| -     return n;
| +     p1 = s;
| +     dc = len = strlen(s);
| +     ri = r = (char *)malloc(len + 1);
| +     while(*p1 != 0) {
| +             c = sgetrune(p1, dc, &p2);
| +             if(c == _INVALID_RUNE) {
| +                     p1++;
| +                     dc--;
| +                     *ri++ = '?';
| +             } else {
| +                     dc -= p2 - p1;
| +                     if(isprint(c))
| +                             while(p1 != p2)
| +                                     *ri++ = *p1++;
| +                     else
| +                             while(p1 != p2) {
| +                                     *ri++ = '?';
| +                                     p1++;
| +                             }
| +             }
| +     }
| +     *ri = 0;
| +     printf("%s", r);
| +     free(r);
| +     return len;
|  }
|  
|  /*


-- 
+-----------------------------------------------------------+
| [EMAIL PROTECTED]         | [EMAIL PROTECTED]       |
| http://iteration.net/~keichii | Yes, BSD is a conspiracy. |
+-----------------------------------------------------------+

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to