Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Mar 2001 00:20:43 -0600
From:      "Michael C . Wu" <keichii@iteration.net>
To:        current@freebsd.org
Cc:        ache@freebsd.org, i18n@freebsd.org, imp@freebsd.org
Subject:   Request for review [Re: /bin/ls patch round #2]
Message-ID:  <20010320002043.A46115@peorth.iteration.net>
In-Reply-To: <20010319195438.A43266@peorth.iteration.net>; from keichii@iteration.net on Mon, Mar 19, 2001 at 07:54:38PM -0600
References:  <20010319195438.A43266@peorth.iteration.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Everyone,

This patch should allow our /bin/(color)ls to output Chinese,
Japanese, Korean, and all European languages(including Russian)
correctly.  Thinker and I both tested this independently.
isprint() already checks for _CTYPE stuff that Ache asked us to check.

Thinker also fixed the infinite loop in this patch.
This should all us to catch up with GNU/Linux and gnuls somewhat. :)

Please review this patch and comment on it.  I plan to commit
this in a few days if there are no more objections.

Thanks, 
Michael

On Mon, Mar 19, 2001 at 07:54:38PM -0600, Michael C . Wu scribbled:
| 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> -----
| From: thinker <thinker@master.branda.to>
| 
| 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;
|  }
|  
|  /*


-- 
+-----------------------------------------------------------+
| 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-current" in the body of the message




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