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--;
Original issue reported on code.google.com by alf42...@gmail.com on 28 Jun 2014 at 5:27
Original issue reported on code.google.com by
alf42...@gmail.com
on 28 Jun 2014 at 5:27