Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356120

Summary: StrLib.getNextToken not returning the correct result
Product: z_Archived Reporter: broy2
Component: EDTAssignee: Project Inbox <edt.javagen-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: mheitz
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description broy2 CLA 2011-08-29 16:23:49 EDT
Build Identifier: 20110829 Nightly build

Run the following program.  The returned token is garbage.  It also looks like the index is based on characters rather than bytes.  

program pgm type BasicProgram {}
    commandLine STRING = "CALL PROG1 arg1,arg2";
    delimiters STRING = " ,"; // space and comma delimiters
    i INT = 1;
    max INT;
    token STRING? = "";
    function main()
	max = 40;
        while( i < max) // i is updated below
	       token = StrLib.getNextToken(commandLine, i, delimiters);
	       SysLib.writeStdout(token);
	       SysLib.writeStdout(i);
        end // while
    end
end
In EDT, I get:
5
[B@12ac982
11
[B@1389e4
16
[B@c20e24
21
egl.lang.InvalidIndexException
egl.lang.InvalidIndexException

In RBD, I get:
CALL
9
PROG1
21
arg1
31
arg2
41

Reproducible: Always

Steps to Reproduce:
1.See above
2.
3.
Comment 1 Matt Heitz CLA 2011-08-29 20:52:10 EDT
There were problems in several places, but they're all fixed now.

The getNextToken in eglx.lang.StringLib (formerly StrLib) does use a character index not a byte index.

The getNextToken in eglx.rbd.StrLib uses a byte index not a character index because that's the way RBD's StrLib works.
Comment 2 broy2 CLA 2011-08-30 13:14:33 EDT
Verified 20110830