From owner-freebsd-i18n Sun Mar 18 4:56:55 2001 Delivered-To: freebsd-i18n@freebsd.org Received: from cartier.cirx.org (cartier.cirx.org [211.72.15.243]) by hub.freebsd.org (Postfix) with ESMTP id DC68A37B718; Sun, 18 Mar 2001 04:56:45 -0800 (PST) (envelope-from clive@CirX.ORG) Received: from cartier.cirx.org (nullmail@localhost [127.0.0.1]) by cartier.cirx.org (8.11.3/8.11.3) with SMTP id f2ICuSQ10611; Sun, 18 Mar 2001 20:56:29 +0800 (CST) (envelope-from clive@CirX.ORG) Received: (nullmailer pid 10607 invoked by uid 1000); Sun, 18 Mar 2001 12:56:28 -0000 Date: Sun, 18 Mar 2001 20:56:28 +0800 From: Clive Lin To: "Andrey A. Chernov" Cc: "Michael C . Wu" , imp@FreeBSD.ORG, freebsd-i18n@FreeBSD.ORG, thinker@branda.to Subject: fix for single char locale (Was: Re: ls(1) mb patch) Message-ID: <20010318205628.A10534@cartier.cirx.org> References: <20010318174101.A8012@cartier.cirx.org> <20010318050746.A4964@peorth.iteration.net> <20010318144136.A40114@nagual.pp.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="RnlQjJ0d97Da+TV1" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010318144136.A40114@nagual.pp.ru>; from ache@nagual.pp.ru on Sun, Mar 18, 2001 at 02:41:36PM +0300 Sender: owner-freebsd-i18n@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --RnlQjJ0d97Da+TV1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Mar 18, 2001 at 02:41:36PM +0300, Andrey A. Chernov wrote: > Objection. It breaks isprint() for single char locales. Sorry about that.. originally submitter fixed this. It should be ok now ,hopefully. -- pub 1024D/F8D2B472 2000-08-05 Clive Lin Key fingerprint = 7F9D 57A8 55C7 AA18 49B5 3820 570B 27F6 F8D2 B472 --RnlQjJ0d97Da+TV1 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ls.diff" Index: util.c =================================================================== RCS file: /home/ncvs/src/bin/ls/util.c,v retrieving revision 1.23 diff -u -r1.23 util.c --- util.c 2000/07/22 05:28:46 1.23 +++ util.c 2001/03/18 12:51:29 @@ -52,6 +52,7 @@ #include #include #include +#include #include "ls.h" #include "extern.h" @@ -60,15 +61,33 @@ 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++ = '?'; + } + } + *ri = 0; + printf("%s", r); + return len; } /* --RnlQjJ0d97Da+TV1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-i18n" in the body of the message