[M3devel] AND (., 16_ff). Not serious - or so I hope!

Jay K jay.krell at cornell.edu
Tue Jun 26 16:28:46 CEST 2012


 > 128 limit

I haven't read the code enough yet to verify that but you are probably right

 > ignoring everything over 16_FF

Probably that is the responsibility/claim of the caller of GetChars.
If you want to be correct in the face of non-ASCII, you are probably obligated to call GetWideChars.
Perhaps raising an exception would be reasonable to signal the loss of data. Or something.
There is HasWideChars for you to check.

There is no encoding implied remember.
This isn't UTF8 data.


 - Jay


________________________________
> From: dragisha at m3w.org 
> Date: Tue, 26 Jun 2012 14:27:00 +0200 
> To: dabenavidesd at yahoo.es 
> CC: m3devel at elegosoft.com 
> Subject: Re: [M3devel] AND (., 16_ff). Not serious - or so I hope! 
>  
> If you cared to read, for example Text.i3, you would see this is  
> exactly what cm3 people meant to be. 
>  
> On Jun 26, 2012, at 2:12 PM, Daniel Alejandro Benavides D. wrote: 
>  
> Hi all: 
> Maybe is a left over of older code (almost just used a decade ago) but  
> if not, then this meant to be just a partial implementation? If we are  
> to get serious about memory usage seems over strict (or just in case  
> you don't need system NIL terminated widechars be checked?). 
> Thanks in advance 
>  
> --- El mar, 26/6/12, Dragiša Durić  
> <dragisha at m3w.org<mailto:dragisha at m3w.org>> escribió: 
>  
> De: Dragiša Durić <dragisha at m3w.org<mailto:dragisha at m3w.org>> 
> Asunto: [M3devel] AND (., 16_ff). Not serious - or so I hope! 
> Para: "m3devel" <m3devel at elegosoft.com<mailto:m3devel at elegosoft.com>> 
> Fecha: martes, 26 de junio, 2012 05:18 
>  
> This piece of code, from TextClass.m3, disturbs me. a lot. 
>  
> If we are to use WIDECHAR, I think we must be a lot more serious than this. 
>  
> Probably, text pieces are limited to 128 bytes by design, somewhere.  
> But - whose idea was to "narrow" by ignoring everything except 8 LSB's?  
> By mapping set of 2^20 elements to set of 2^8 elements. 
>  
> Probably by someone whose mother tongue is fully writeable with ASCII :). 
>  
> ==== 
> PROCEDURE GetChars (t: TEXT;  VAR a: ARRAY OF CHAR;  start: CARDINAL) = 
> VAR 
>     info : Info; 
>     cnt  : INTEGER; 
>     next : CARDINAL := 0; 
>     buf  : ARRAY [0..127] OF WIDECHAR; 
> BEGIN 
>     t.get_info (info); 
>     cnt := MIN (NUMBER (a), info.length - start); 
>     WHILE (cnt > 0) DO 
>       t.get_wide_chars (buf, start); 
>       FOR i := FIRST (buf) TO LAST (buf) DO 
>         IF (cnt = 0) THEN RETURN END; 
>         a[next] := VAL (Word.And (ORD (buf[i]), 16_ff), CHAR); 
>         INC (next);  DEC (cnt); 
>       END; 
>       INC (start, NUMBER (buf)); 
>     END; 
> END GetChars; 
> ==== 
>  
>  
>  
 		 	   		  



More information about the M3devel mailing list