コード例 #1
0
ファイル: breakp2.c プロジェクト: Anastien/ngspice
static char*
copynode(char *s)
{
    char *l, *r;
    char *ret = NULL;

    if (strstr(s, "("))
        s = stripWhiteSpacesInsideParens(s);
    else
        s = copy(s);

    l = strrchr(s, '(');
    if (!l)
        return s;

    r = strchr(s, ')');
    *r = '\0';
    if (*(l - 1) == 'i' || *(l - 1) == 'I')
        ret = tprintf("%s#branch", l + 1);
    else
        ret = copy(l + 1);

    tfree(s);
    return ret;
}
コード例 #2
0
ファイル: dotcards.c プロジェクト: Trussroads/RZE-ngspice
wordlist *
gettoks(char *s)
{
    char        *t, *s0;
    char        *l, *r, *c;     /* left, right, center/comma */
    wordlist    *wl, *list, **prevp;


    list = NULL;
    prevp = &list;

    /* stripWhite.... uses copy() to return a malloc'ed s, so we have to free it,
       using s0 as its starting address */
    if (strstr(s, "("))
        s0 = s = stripWhiteSpacesInsideParens(s);
    else
        s0 = s = copy(s);

    while ((t = gettok(&s)) != NULL) {
        if (*t == '(') {
            /* gettok uses copy() to return a malloc'ed t, so we have to free it */
            tfree(t);
            continue;
        }
        l = strrchr(t, '('/*)*/);
        if (!l) {
            wl = wl_cons(copy(t), NULL);
            *prevp = wl;
            prevp = &wl->wl_next;
            tfree(t);
            continue;
        }

        r = strchr(t, /*(*/')');

        c = strchr(t, ',');
        if (!c)
            c = r;

        if (c)
            *c = '\0';

        wl = wl_cons(NULL, NULL);
        *prevp = wl;
        prevp = &wl->wl_next;

        if (*(l - 1) == 'i' || *(l - 1) == 'I') {
            char buf[513];
            sprintf(buf, "%s#branch", l + 1);
            wl->wl_word = copy(buf);
            c = r = NULL;
        } else {
            wl->wl_word = copy(l + 1);
        }

        if (c != r) {
            *r = '\0';
            wl = wl_cons(copy(c + 1), NULL);
            *prevp = wl;
            prevp = &wl->wl_next;
        }
        tfree(t);
    }
    tfree(s0);
    return list;
}