From owner-freebsd-i18n Sun Mar 18 1:41: 8 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 3575637B71F for ; Sun, 18 Mar 2001 01:41:03 -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 f2I9f1Q08069; Sun, 18 Mar 2001 17:41:01 +0800 (CST) (envelope-from clive@CirX.ORG) Received: (nullmailer pid 8065 invoked by uid 1000); Sun, 18 Mar 2001 09:41:01 -0000 Date: Sun, 18 Mar 2001 17:41:01 +0800 From: Clive Lin To: freebsd-i18n@FreeBSD.org Cc: Thinker.bbs@bbs.yzu.edu.tw Subject: ls(1) mb patch Message-ID: <20010318174101.A8012@cartier.cirx.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-i18n@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Here's a mb patch. Could kr- and jp- (CJK people :p) test this ? I can't talk too much about the details. It just uses the right way to call our isprint(3). If you have any problems, please discuss with the original author: Thinker.bbs@bbs.yzu.edu.tw (Cc'd) -- pub 1024D/F8D2B472 2000-08-05 Clive Lin Key fingerprint = 7F9D 57A8 55C7 AA18 49B5 3820 570B 27F6 F8D2 B472 --jRHKVT23PllUwdXP 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 09:28:18 @@ -52,6 +52,7 @@ #include #include #include +#include #include "ls.h" #include "extern.h" @@ -60,15 +61,29 @@ 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; + while(p1 != p2) + *ri++ = *p1++; + } + } + *ri = 0; + printf("%s", r); + return len; } /* --jRHKVT23PllUwdXP-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-i18n" in the body of the message