Date: Mon, 19 Mar 2001 19:54:38 -0600 From: "Michael C . Wu" <keichii@iteration.net> To: ache@freebsd.org, i18n@freebsd.org Cc: imp@freebsd.org Subject: /bin/ls patch round #2 Message-ID: <20010319195438.A43266@peorth.iteration.net>
index | next in thread | raw e-mail
Hi everyone,
Is this satisfactory with you all?
Ache: how should we check for Russian and single-byte char compatibility?
----- Forwarded message from thinker <thinker@master.branda.to> -----
Date: Tue, 20 Mar 2001 10:05:58 +0800
From: thinker <thinker@master.branda.to>
Subject: Re: [keichii@iteration.net: Re: [thinker@master.branda.to: Ãö©ó /bin/ls]]
To: "Michael C . Wu" <keichii@peorth.iteration.net>
User-Agent: Mutt/1.2.5i
Following is new patch file for /bin/ls.
-------------------------------------
--- util.c.orig Sun Mar 18 16:35:12 2001
+++ util.c Tue Mar 20 09:49:47 2001
@@ -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,36 @@
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++ = '?';
+ p1++;
+ }
+ }
+ }
+ *ri = 0;
+ printf("%s", r);
+ free(r);
+ return len;
}
/*
----- End forwarded message -----
--
+-----------------------------------------------------------+
| keichii@iteration.net | keichii@freebsd.org |
| http://iteration.net/~keichii | Yes, BSD is a conspiracy. |
+-----------------------------------------------------------+
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-i18n" in the body of the message
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010319195438.A43266>
