Latest webrev does it this way:

    for (i = 0; i < count; i++) {
        char *q = p + strcspn(p, ":");
        pathv[i] = (p == q) ? "." : p;
        *q = '\0';
        p = q + 1;
    }



On Thu, Mar 28, 2013 at 5:07 PM, Martin Buchholz <marti...@google.com>wrote:

> strsep is nice, but not standard enough to use in the JDK.
> OTOH, strcspn is already used in the JDK, but doesn't really  buy much:
>
>     for (i = 0; i < count; i++) {
>         int len = strcspn(p, ":");
>         pathv[i] = (len == 0) ? "." : p;
>         p[len] = '\0';
>         p += len + 1;
>     }
>
>
>
> On Thu, Mar 28, 2013 at 12:10 PM, Christos Zoulas <chris...@zoulas.com>wrote:
>
>>
>> +     for (i = 0; (pathv[i] = strsep(&p, ":")) != NULL; i++)
>> +       if (!pathv[i][0])
>> +               pathv[i] = ".";
>>
>> christos
>>
>
>

Reply via email to