Issue 88 in teyjus: incorrect size of substring

0 views
Skip to first unread message

tey...@googlecode.com

unread,
Jun 28, 2014, 1:28:04 PM6/28/14
to teyjus...@googlegroups.com
Status: New
Owner: ----

New issue 88 by alf42...@gmail.com: incorrect size of substring
http://code.google.com/p/teyjus/issues/detail?id=88

Those steps will reproduce the problem:
1. start tjsim
2. Enter the following query:
X is substring "12345" 2 3, Y is size X.

You will get the following output:
The answer substitution:
Y = 4
X = "345"

The expected output is:
Y = 3
X = "345"

The size of the substring should always be the length of the substring
without the terminating '\0' character.

Version of the simulator:
Teyjus version 2.0-b2
on Ubuntu 12.04.4 LTS

To fix this, you could apply the following patch to the function
MCSTR_subString in the file source/simulator/mcstring.c. Most tests seem to
be okay after applying the patch except for exportdef.t, but maybe that's
another issue.


$ svn diff
Index: mcstring.c
===================================================================
--- mcstring.c (revision 1136)
+++ mcstring.c (working copy)
@@ -84,7 +84,7 @@
char* fromPtr = ((char*)(str + 1))+startPos;
char* toPtr = (char*)(loc + 1);

- *((int *)loc) = (length + 1);
+ *((int *)loc) = length;
while (length > 0) {
*toPtr++ = *fromPtr++;
length--;




--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

tey...@googlecode.com

unread,
Jul 16, 2014, 11:27:17 AM7/16/14
to teyjus...@googlegroups.com
Updates:
Status: Fixed
Labels: Usability Priority-High

Comment #1 on issue 88 by fafo...@gmail.com: incorrect size of substring
http://code.google.com/p/teyjus/issues/detail?id=88

Thanks, it's fixed!

The failure for exportdef.t is unrelated (I added the test case but I don't
know how to fix it).
Reply all
Reply to author
Forward
0 new messages