lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev a working LYstrsep()


From: Bela Lubkin
Subject: lynx-dev a working LYstrsep()
Date: Tue, 4 Aug 1998 00:40:03 -0700

This goes in src/LYStrings.c.  It should fix the problems various people
are having with the HTML options code.

>Bela<

/*
 *  A replacement for 'strsep()'
 */
PUBLIC char *LYstrsep ARGS2(
        char **,        stringp,
        CONST char *,   delim)
{
    char *tmp, *out;

    if (!stringp || !*stringp)          /* nothing to do? */
        return 0;                       /* then don't fall on our faces */

    if (!**stringp) {                   /* empty string: */
        *stringp = 0;                   /* let caller see he's done; */
        return 0;                       /* no tokens in an empty string */
    }

    out = *stringp;                     /* save the start of the string */
    tmp = strpbrk(*stringp, delim);
    if (tmp) {
        *tmp = '\0';                    /* terminate the substring with \0 */
        *stringp = ++tmp;               /* point at the next substring */
    }
    else *stringp = 0;                  /* this was the last substring: */
                                        /* let caller see he's done */
    return out;
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]