[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Strange behaivor of get method of handle class



At 7.38 -0500 2000.03.29, Chris Nandor wrote:
>At 11.53 +0900 2000.03.16, Tetsuro Kurita wrote:
>>$target = 'Macintosh HD:Encode URL ?:Encode URL';
>>
>>$RF = OpenResFile($target);$temp_handle = Get1Resource('aete', 0);
>>
>>$aete_handle = new Handle $temp_handle->get;CloseResFile($RF);print
>>$aete_handle->get(29, 0);ReleaseResource($aete_handle)
>>
>>The output to STDOUT is '[syso'.  0 length to read data is given to get
>>method of handle class. But 5 byte data is returned.When 0 length is given,
>>get method of handle class sometimes returns unexpected results. Does 0
>>length have special meaning in get method ?
>
>I have duplicated the error, and will try to fix it when I get a chance to
>(hopefully in the next week or so).

Hm, maybe I spoke too soon.  My fix before was if the handle size actually
WAS 0.  It looks like if 0 is passed as the length, then the default (-1)
is used, which gets the rest of the handle.  So it looks like it does just
that, getting everything up to the end of the handle.  I am not sure of a
way around this; I am no expert in XS.  How does one distinguish between no
value being passed, and a 0 being passed?

Why would you need to pass a 0 length, though?  You would expect to get no
data back, right?  I suppose a reasonable workaround would be:

  if ($length != 0) {
    print $handle->get($offset, $length);
  }

-- 
Chris Nandor       |     pudge@pobox.com      |     http://pudge.net/
Andover.Net        | chris.nandor@andover.net | http://slashcode.com/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org