From owner-freebsd-i18n Mon Mar 19 17:54:47 2001 Delivered-To: freebsd-i18n@freebsd.org Received: from peorth.iteration.net (peorth.iteration.net [208.190.180.178]) by hub.freebsd.org (Postfix) with ESMTP id DC17637B722; Mon, 19 Mar 2001 17:54:38 -0800 (PST) (envelope-from keichii@peorth.iteration.net) Received: by peorth.iteration.net (Postfix, from userid 1001) id 3F28E59283; Mon, 19 Mar 2001 19:54:38 -0600 (CST) Date: Mon, 19 Mar 2001 19:54:38 -0600 From: "Michael C . Wu" To: ache@freebsd.org, i18n@freebsd.org Cc: imp@freebsd.org Subject: /bin/ls patch round #2 Message-ID: <20010319195438.A43266@peorth.iteration.net> Reply-To: "Michael C . Wu" Mime-Version: 1.0 Content-Type: text/plain; charset=big5 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i X-PGP-Fingerprint: 5025 F691 F943 8128 48A8 5025 77CE 29C5 8FA1 2E20 X-PGP-Key-ID: 0x8FA12E20 Sender: owner-freebsd-i18n@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi everyone, Is this satisfactory with you all? Ache: how should we check for Russian and single-byte char compatibility? ----- Forwarded message from thinker ----- Date: Tue, 20 Mar 2001 10:05:58 +0800 From: thinker Subject: Re: [keichii@iteration.net: Re: [thinker@master.branda.to: Ãö©ó /bin/ls]] To: "Michael C . Wu" User-Agent: Mutt/1.2.5i 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 #include #include +#include #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; } /* ----- End forwarded message ----- -- +-----------------------------------------------------------+ | keichii@iteration.net | keichii@freebsd.org | | http://iteration.net/~keichii | Yes, BSD is a conspiracy. | +-----------------------------------------------------------+ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-i18n" in the body of the message