Richard Frith-Macdonald schrieb:
> 
> On 12 Aug 2006, at 01:35, David Ayers wrote:
> 
>> /* Note that we have _flags.wide but default encoding != internal
>> encoding.  I'm not sure whether this shoulr be fixed here or in
>> getCString_c. */
>>       getCString_c((GSStr)self, buffer, maxLength, aRange, 
>> leftoverRange);
>>     }
>> }
> 
> 
> It's getCString_c assuming that internal and external encodings are  the
> same.
> I've hacked in a quick fix to convert to unicode and use getCString_u 
> in that situation ... should solve the problem as long as  getCString_u
> is working properly.
> I bet it's possible to write it more efficiently, but that would be 
> time consuming ... and I'm not sure it's worth it for a deprecated  method.
> 

Agreed.

This failure:

base/NSString/NSString_custom.m:
FAIL: -getCString:maxLength:range:remainingRange: works

is due too:
#0  GSFromUnicode (dst=0xbffff234, size=0xbffff23c, src=0xbffff242, slen=1,
    enc=NSUTF8StringEncoding, zone=0x0, options=0) at Unicode.m:1994
#1  0x4021d0c6 in encode_unitochar (u=65, enc=NSUTF8StringEncoding)
    at Unicode.m:860
#2  0x4019fc58 in -[NSString getCString:maxLength:range:remainingRange:] (
    self=0x80aa318, _cmd=0x804c698, buffer=0xbffff320 "", maxLength=1,
aRange=
      {location = 0, length = 3}, leftoverRange=0xbffff318) at
NSString.m:2636
#3  0x08049c04 in test_getCString_maxLength_range_remainingRange ()
    at NSString_tests.h:202
#4  0x0804a8a1 in TestNSStringClass (aStringClass=0x804c5e0)
    at NSString_tests.h:309
#5  0x0804ab7f in main (argc=1, argv=0xbffff4d4) at NSString_custom.m:78

While trying to convert the 'A' already eventhough u1 is correctly set
to 65:

(gdb) p dpos
$24 = 0
(gdb) p sl
$25 = 1
(gdb) p bsize
$26 = 1
(gdb)

so:
              /* make sure we have enough space for it */
=>            while (dpos + sl >= bsize)
                {
                  GROW();
                }
evalutates to true and since encode_unitochar cannot provide a zone, the
GROW macro fails.  I'm not sure why we need to grow on unichar 65, yet
even if that is fixed, we would fail once we processed the next
character which is non-ASCII.  So I would suppose that we need to
replace the encode_unitochar call with GSFromUnicode in in NSSting.m:
- (void) getCString: (char*)buffer
          maxLength: (unsigned int)maxLength
              range: (NSRange)aRange
     remainingRange: (NSRange*)leftoverRange

Cheers,
David

_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to