ons 2006-04-26 klockan 10:08 +1000 skrev Robert Collins:
> On Tue, 2006-04-25 at 14:06 +0200, Guido Serassio wrote:
> > Hi Robert,
> > 
> > At 13.52 25/04/2006, Robert Collins wrote:
> > 
> > >So, I did some more today, courtesy of ANZAC day. Hopefully next weekend
> > >I'll get another chance to cut some code. I'm thinking of changing
> > >strtok -> strtok_r in the parser.
> > >
> > >How portable is strtok_r ? Specifically is it available on mingw, BSD
> > >systems ?
> > 
> > Not available on MinGW and VisualStudio 2005, available on Cygwin.
> > 
> > Looking with google, the code don't seem to be complex, so, it should 
> > not be a problem include into the windows specific library.
> 
> Cool. Can I just use it then [are you happy to make the compatability
> library ?]

Here is one suggestion:


#include <string.h>

char *strtok_r(char *str, const char *delim, char **saveptr)
{
    char *token;
    if (str)
        *saveptr = str;
    token = *saveptr;

    if (!token)
        return NULL;

    token += strspn(token, delim);
    *saveptr = strpbrk(token, delim);
    if (*saveptr)
        *(*saveptr)++ = '\0';

    return *token ? token : NULL;
}

Regards
Henrik

Attachment: signature.asc
Description: Detta är en digitalt signerad meddelandedel

Reply via email to