From: SourceForge.net <no...@so...> - 2010-05-21 20:56:37
|
Bugs item #3005462, was opened at 2010-05-21 20:36 Message generated for change (Comment added) made by orexx You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=684730&aid=3005462&group_id=119701 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: APIs Group: v4.0.1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Rony G. Flatscher (orexx) Assigned to: Nobody/Anonymous (nobody) Summary: StringLength() not returning correct string length, if Initial Comment: This is a very subtle error (took me a lot of time to trace down and finally finding the cause). If a RexxStringObject has a numeric value like "5" or "80", then StringLength() returns the numeric value of the Rexx string instead of the length of the strings (1 and 2 respectively). Sending the message "length" to the same RexxStringObject will return the correct string lengths: ... cut ... size_t len=context->StringLength(rso); // get length int32_t tmpLength=0; logical_t res=context->ObjectToInt32(context->SendMessage0(rso, "LENGTH"), &tmpLength); ... cut ... RexxStringObjects having the string value "5" or "80" will yield a value for "len" of 5 or 80, for "tmpLength" the correct values of 1 and 2, respectively. Again, quite a subtle problem (using StringLength in quite a few places in the external function package BSF4ooRexx and will have to change the code to switch to the message form if running on ooRexx 4.0.1 comparing REXX_CURRENT_INTERPRETER_VERSION against REXX_INTERPRETER_4_0_1). ---------------------------------------------------------------------- >Comment By: Rony G. Flatscher (orexx) Date: 2010-05-21 22:56 Message: It takes the Rexx objects off the ARGLIST array, which it iterates: RexxRoutine1(RexxObjectPtr, BSF, ARGLIST, argArray) {...} >From REXXPG.PDF, p. 112: "ARGLIST A RexxArrayObject containing all arguments passed to the routine. This is equivalent to using Arg(1, ’A’) from Rexx code. The returned array contains all of the routine arguments that were specified in the original call. Omitted arguments are empty slots in the returned array. In addition, if a routine has an ARGLIST argument specified, the normal check for the maximum number of arguments is bypassed. This makes possible routines with an open-ended number of arguments. ARGLIST is not valid as a return value." Although not explicitly specified I would now assume that RexxObjectPtr are assumed and not RexxStringObjects (even though from the ooRexx side they all appear to be RexxStringObjects). ---------------------------------------------------------------------- Comment By: Rick McGuire (bigrixx) Date: 2010-05-21 21:10 Message: The key question is how was the argument specified in the signature. If the argument signature is RexxStringObject and you did not receive a real string object as the value, then this is a bug. If the argument signature is RexxObjectPtr and you used a cast to convert this to a RexxStringObject, then error is in your code. ---------------------------------------------------------------------- Comment By: Rony G. Flatscher (orexx) Date: 2010-05-21 21:06 Message: It was obtained via an argument. Hmm, will have to go through the code first to see where I need to use ObjectToString() instead of a cast into a RexxStringObject (there should be a lot of places). ---------------------------------------------------------------------- Comment By: Rick McGuire (bigrixx) Date: 2010-05-21 20:55 Message: How was the RexxStringObject obtained? If you obtained it via an argument and it was not a real string object, then this is an error in the argument passing. If you obtained it via another means, then you need to ensure you have a real string object rather than an instance of some other type (such as an Integer instance). It is not sufficient to case a RexxObjectPtr to a RexxStringObject unconditionally. The ObjectToString() API is the only safe way to convert a RexxObjectPtr into a RexxStringObject. ---------------------------------------------------------------------- Comment By: Rony G. Flatscher (orexx) Date: 2010-05-21 20:42 Message: Sorry, forgot to mention: this bug does not occur with other numeric values (or it may be the case that it only surfaces, if in a particular state; in that case please let me know and I will create a debug version of BSF4ooRexx and a package containing it for you to recreate the error). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=684730&aid=3005462&group_id=119701 |