On Sun, Dec 12, 2021 at 07:33 AM, Dave Mitchell wrote:
I seem to have stumbled on a bug in the way the parse instruction works in BREXX? specifically when a pattern is used. Here's a sample exec;
/* test parse */?
? trest = '() trial 1'
? say 'test of () trial 1'
? s = dotell(trest)
? trest = '(1) trial 2'
? say 'test of (1) trial 2'
? s = dotell(trest)
? trest = '(1 3) trial3'
? say 'test of (1 3) trial 3'
? s = dotell(trest)
? exit
?
dotell:
? parse arg with '(' in1 in2 ')' outer
? say 'in1 = /'in1'/'
? say 'in2 = /'in2'/'
? say 'outer=/'outer'/'
? return 0
only the third test works as it should, setting 'in1' to '1', 'in2' to '3' and 'outer' to 'trial 3'. The other two cases set 'in1' to ')' and '1) respectively, 'in2' to 'trial 1' and 'trial 2' and 'outer' to a null string.
With the replacement of the GCCLIB segment, I tried this again, and the results are the same.
I've been looking at the REXX syntax definitions, and Mike's definitive book, trying to understand what the C code should be doing.
That said, the definition for parsing using the PARSE ARG, or ARG commands does not appear to identify the right parenthesis as a special character, as it identifies the left parenthesis.
What did not exist in VM/SP 6, and prior was the 'WITH' parameter. I'm guessing, for lack of documentation and knowledge, this was added to resolve the challenge Dave is talking about.
type davemtst exec a?/* test parse */? trest = '() trial 1'? say 'test of () trial 1'? s = dotell(trest)? trest = '(1) trial 2'? say 'test of (1) trial 2'? s = dotell(trest)? trest = '(1 3) trial3'? say 'test of (1 3) trial 3'? s = dotell(trest)? exit?dotell:? parse arg with '(' in1 in2 ')' outer? say 'in1 = /'in1'/'? say 'in2 = /'in2'/'? say 'outer=/'outer'/'? return 0?Ready; T=0.01/0.01 09:55:08davemtsttest of () trial 1in1 = /)/in2 = /trial 1/outer=//test of (1) trial 2in1 = /1)/in2 = /trial 2/outer=//test of (1 3) trial 3in1 = /1/in2 = /3/outer=/ trial3/Ready; T=0.04/0.05 09:55:15?... Mark S.
This ... and $5.00, might get you a cup of coffee. I'm old enough to remember 25 cents, but not a nickel, for a cup.