Date: 16 May 2002 15:51:21 -0000 From: thinker <thinker@branda.to> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/38152: Message-ID: <20020516155121.12543.qmail@master.branda.to>
next in thread | raw e-mail | index | archive | help
>Number: 38152
>Category: bin
>Synopsis:
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu May 16 09:00:07 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: thinker
>Release: FreeBSD 5.0-CURRENT i386
>Organization:
YZU
>Environment:
System: FreeBSD master.branda.to 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Wed Jan 16 14:10:31 CST 2002 thinker@master.branda.to:/mnt/src/sys/i386/compile/thk i386
>Description:
/bin/ls could not deal about mb language.
>How-To-Repeat:
>Fix:
--- util.c.orig Thu May 16 23:37:22 2002
+++ util.c Thu May 16 23:43:19 2002
@@ -52,6 +52,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <rune.h>
+#include <wctype.h>
#include "ls.h"
#include "extern.h"
@@ -60,15 +62,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;
}
/*
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020516155121.12543.qmail>
