Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug: String Slicing (*solved*)
#6
britlion Wrote:Erm. Um. :?:

Okay. Hopefully you can grab this file: <!-- m --><a class="postlink" href="http://britlion.googlepages.com/test.tzx">http://britlion.googlepages.com/test.tzx</a><!-- m -->

Is this working on your emulator? Because in Spectaculator 7.00 it loads, scrolls for a few seconds, and crashes!

This file effectively crashes. However, are you sure this file is the compilation of the above Source Code? It seems it is not.
The way it crashed might suggest a Stack Overflow. Are you using GOSUB or function calls in that code?

Update: Confusedhock: Believe it or not, I have download again the 2nd example, compiled it and now it CRASH :?: :?:
So I now have something to test. Wink

Update2: Fixed. The problem are lines 70 & 80. They should read:
Code:
70 IF fin>=LEN a$ THEN LET fin=0  : END IF
80 IF start>=LEN a$ THEN LET start=0 : END IF
This is because when fin == LEN a$, a$(fin) is beyond end of a$ (should be fin-1). Anyway, the program should not crash: I put some overflow checking to avoid this.

I will put some more checking, but since this will slowdown array/string accesses. I think It could be a good idea to put some compiler option to enable/disable array/strings boundary checks. Once the program is debugged, you can recompile disabling it.

Another fix could be to enable a flag like:
Code:
zxb --string-base=1
The same as "array-base" flag. So, for maximum compatibility:
Code:
zxb --string-base=1 --array-base=1
or better
Code:
zxb --sinclair
What do you think?

Note: --sinclair already exists, but does not change string-base
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)