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:
Code:
char *token;
void myfunc()
{
...
token = mystrtok(...);
...
}
Unless you strings are very different from standard C strings, perhaps you can replace this:
Code:
if (my_strlen(string)==0)
with a simple check to see
Code:
if (string[0] == 0) ...
On the other hand:
Code:
if (string[i]=='\0')
{
token=&string[i];
return NULL;
}
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.
Code:
for (j=0;j<my_strlen(delim);j++)
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.
--
Mats