From owner-freebsd-i18n Mon Mar 19 22:20:56 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 6AD0637B71A; Mon, 19 Mar 2001 22:20:49 -0800 (PST) (envelope-from keichii@peorth.iteration.net) Received: by peorth.iteration.net (Postfix, from userid 1001) id 5035859283; Tue, 20 Mar 2001 00:20:43 -0600 (CST) Date: Tue, 20 Mar 2001 00:20:43 -0600 From: "Michael C . Wu" To: current@freebsd.org Cc: ache@freebsd.org, i18n@freebsd.org, imp@freebsd.org Subject: Request for review [Re: /bin/ls patch round #2] Message-ID: <20010320002043.A46115@peorth.iteration.net> Reply-To: "Michael C . Wu" References: <20010319195438.A43266@peorth.iteration.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010319195438.A43266@peorth.iteration.net>; from keichii@iteration.net on Mon, Mar 19, 2001 at 07:54:38PM -0600 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, 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 ----- | From: thinker | | 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; | } | | /* -- +-----------------------------------------------------------+ | 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