Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356120 - StrLib.getNextToken not returning the correct result
Summary: StrLib.getNextToken not returning the correct result
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-29 16:23 EDT by broy2 CLA
Modified: 2017-02-23 14:17 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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