Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Mar 2001 17:41:01 +0800
From:      Clive Lin <clive@CirX.ORG>
To:        freebsd-i18n@FreeBSD.org
Cc:        Thinker.bbs@bbs.yzu.edu.tw
Subject:   ls(1) mb patch
Message-ID:  <20010318174101.A8012@cartier.cirx.org>

next in thread | raw e-mail | index | archive | help

--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 <clive@CirX.ORG>
     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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <rune.h>
 
 #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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010318174101.A8012>