I think tabstop is right. Either that, or i-1 is less than zero.
Make that a static local variable (or at the very least a static global) - it avoids someone writing the following getting nasty surprises:
Unless you strings are very different from standard C strings, perhaps you can replace this:
token = mystrtok(...);
with a simple check to see
On the other hand:
if (string == 0) ...
will do the same thing for i = 0, aside from setting token to the last character in the string - which I think is pretty meaningless, as you'll never find anything at that point, so token can be set to NULL just as well.
NEVER EVER call strlen() as a loop control [unless the string length changes during the code of course] - make a local variable of the length before the loop and compare with that.
Some places, you have inconsistent use of empty lines (e.g. the return NULL code above is different from the otherwise identical bit in the second while-loop.