From owner-freebsd-current Tue Mar 20 0:48:29 2001 Delivered-To: freebsd-current@freebsd.org Received: from hell.branda.to (61-216-80-81.HINET-IP.hinet.net [61.216.80.81]) by hub.freebsd.org (Postfix) with ESMTP id 0478D37B719 for ; Tue, 20 Mar 2001 00:48:25 -0800 (PST) (envelope-from thinker@branda.to) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by hell.branda.to with local; Tue, 20 Mar 2001 16:49:01 +0000 Date: Tue, 20 Mar 2001 16:49:01 +0000 From: thinker To: freebsd-current@freebsd.org Subject: patch /bin/ls again, for mb supporting. Message-ID: <20010320164901.A14424@hell.branda.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, There are some disscuss about patch file of /bin/ls. You guys give me some suggestion, and I make a new patch file for /bin/ls to meet people's wish. Following is patch for /bin/ls, plz review again. I had change from rune to mb* & wc* ways. ------------- begin --------- --- util.c.orig Sun Mar 18 16:35:12 2001 +++ util.c Tue Mar 20 16:11:37 2001 @@ -60,15 +60,37 @@ prn_printable(s) const char *s; { - unsigned char c; - int n; + const char *p; + char *r, *ri; + int len, dc; + size_t sz; + wchar_t c; - for (n = 0; (c = *s) != '\0'; ++s, ++n) - if (isprint(c)) - putchar(c); - else - putchar('?'); - return n; + p = s; + dc = len = strlen(s); + ri = r = (char *)malloc(len + 1); + while (dc) { + sz = mbtowc(&c, p, dc); + if (sz < 0) { + p++; + dc--; + *ri++ = '?'; + } else { + dc -= sz; + if (isprint(c)) { + while(sz--) + *ri++ = *p++; + } else { + p += sz; + while(sz--) + *ri++ = '?'; + } + } + } + *ri = 0; + printf("%s", r); + free(r); + return len; } /* -------------- end ------------------ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message