⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dotcards.c

📁 spice中支持多层次元件模型仿真的可单独运行的插件源码
💻 C
📖 第 1 页 / 共 2 页
字号:
nocmds:    /* Now the node table */    if (ft_nodesprint)        ;        /* The options */    if (ft_optsprint) {        fprintf(cp_err, "Options:\n\n");        cp_vprint();        (void) putc('\n', cp_out);    }    /* And finally the accounting info. */    if (ft_acctprint) {        static wordlist ww = { "everything", NULL, NULL } ;        com_rusage(&ww);    } else        com_rusage((wordlist *) NULL);    (void) putc('\n', cp_out);    return 0;bad:    fprintf(cp_err, "Internal Error: ft_cktcoms: bad commands\n");    return 1;}/* These routines make sure that the arguments to .plot and .print in * spice2 decks are acceptable to spice3. The things we look for are: *  trailing (a,b) in .plot -> xlimit a b *  vm(x) -> mag(v(x)) *  vp(x) -> ph(v(x)) *  v(x,0) -> v(x) *  v(0,x) -> -v(x) */static voidfixdotplot(wl)    wordlist *wl;{    char buf[BSIZE_SP], *s;    double *d, d1, d2;    while (wl) {        wl->wl_word = fixem(wl->wl_word);        /* Is this a trailing (a,b) ? Note that we require it to be         * one word.         */        if (!wl->wl_next && (*wl->wl_word == '(')) /*)*/ {            s = wl->wl_word + 1;            d = ft_numparse(&s, false);            if (*s != ',') {                fprintf(cp_err, "Error: bad limits \"%s\"\n",                        wl->wl_word);                    return;            }            d1 = *d;            s++;            d = ft_numparse(&s, false);            if ((*s != /*(*/ ')') || s[1]) {                fprintf(cp_err, "Error: bad limits \"%s\"\n",                        wl->wl_word);                    return;            }            d2 = *d;            tfree(wl->wl_word);            wl->wl_word = copy("xlimit");            wl->wl_next = alloc(struct wordlist);            wl->wl_next->wl_prev = wl;            wl = wl->wl_next;            (void) strcpy(buf, printnum(d1));            wl->wl_word = copy(buf);            wl->wl_next = alloc(struct wordlist);            wl->wl_next->wl_prev = wl;            wl = wl->wl_next;            (void) strcpy(buf, printnum(d2));            wl->wl_word = copy(buf);        }        wl = wl->wl_next;    }    return;}static voidfixdotprint(wl)    wordlist *wl;{    while (wl) {        wl->wl_word = fixem(wl->wl_word);        wl = wl->wl_next;    }    return;}static char *fixem(string)    char *string;{    char buf[BSIZE_SP], *s, *t, *ss = string;    if (ciprefix("v(", string) && index(string, ',')) {        for (s = string; *s && (*s != ','); s++)            ;        *s++ = '\0';        for (t = s; *t && (*t != ')'); t++)            ;        *t = '\0';        if (eq(s, "0"))            (void) sprintf(buf, "v(%s)", string + 2);        else if (eq(string + 2, "0"))            (void) sprintf(buf, "-v(%s)", s);        else            (void) sprintf(buf, "v(%s)-v(%s)", string + 2, s);        tfree(ss);        string = copy(buf);    } else if (ciprefix("vm(", string)) {        for (s = string; *s && (*s != ')'); s++)            ;        *s = '\0';        (void) sprintf(buf, "mag(v(%s))", string + 3);        tfree(ss);        string = copy(buf);    } else if (ciprefix("vp(", string)) {        for (s = string; *s && (*s != ')'); s++)            ;        *s = '\0';        (void) sprintf(buf, "ph(v(%s))", string + 3);        tfree(ss);        string = copy(buf);    } else if (ciprefix("vi(", string)) {        for (s = string; *s && (*s != ')'); s++)            ;        *s = '\0';        (void) sprintf(buf, "imag(v(%s))", string + 3);        tfree(ss);        string = copy(buf);    } else if (ciprefix("vr(", string)) {        for (s = string; *s && (*s != ')'); s++)            ;        *s = '\0';        (void) sprintf(buf, "real(v(%s))", string + 3);        tfree(ss);        string = copy(buf);    } else if (ciprefix("vdb(", string)) {        for (s = string; *s && (*s != ')'); s++)            ;        *s = '\0';        (void) sprintf(buf, "db(v(%s))", string + 4);        tfree(ss);        string = copy(buf);    } else if (ciprefix("i(", string)) {        for (s = string; *s && (*s != ')'); s++)            ;        *s = '\0';        string += 2;        (void) sprintf(buf, "%s#branch", string);        tfree(ss);        string = copy(buf);    }    return (string);}/* Don't bother with ccom strangeness here. */static boolsetcplot(name)    char *name;{    struct plot *pl;    for (pl = plot_list; pl; pl = pl->pl_next) {        if (ciprefix(name, pl->pl_typename)) {            plot_cur = pl;            return (true);        }    }    return (false);}#ifdef notdefstatic wordlist *gettoks(s)    char *s;{    char *t, *r, buf[64];    wordlist *wl = NULL, *end = NULL;    bool iflag;    while (t = gettok(&s)) {        if (*t == '(' /* ) */) {            /* This is a (upper, lower) thing -- ignore. */            continue;        } else if (!index(t, '(' /*)*/ )) {            if (end) {                end->wl_next = alloc(struct wordlist);                end->wl_next->wl_prev = end;                end = end->wl_next;            } else                wl = end = alloc(struct wordlist);            end->wl_word = copy(t);        } else if (!index(t, ',')) {            iflag = ((*t == 'i') || (*t == 'I')) ? true : false;            while (*t != '(' /*)*/)                t++;            t++;            for (r = t; *r && *r != /*(*/ ')'; r++)                ;            *r = '\0';            if (end) {                end->wl_next = alloc(struct wordlist);                end->wl_next->wl_prev = end;                end = end->wl_next;            } else                wl = end = alloc(struct wordlist);            if (iflag) {                (void) sprintf(buf, "%s#branch", t);                t = buf;            }            end->wl_word = copy(t);        } else {            /* The painful case */            while (*t != '(' /*)*/)                t++;            t++;            for (r = t; *r && *r != ','; r++)                ;            *r = '\0';            if (end) {                end->wl_next = alloc(struct wordlist);                end->wl_next->wl_prev = end;                end = end->wl_next;            } else                wl = end = alloc(struct wordlist);            end->wl_word = copy(t);            t = r + 1;            for (r = t; *r && *r != /*(*/ ')'; r++)                ;            *r = '\0';            if (end) {                end->wl_next = alloc(struct wordlist);                end->wl_next->wl_prev = end;                end = end->wl_next;            } else                wl = end = alloc(struct wordlist);            end->wl_word = copy(t);        }    }    return (wl);}#endifstatic wordlist *gettoks(s)	char *s;{    char	*t;    char	*l, *r, *c;	/* left, right, center/comma */    wordlist	*wl, *list, **prevp;    list = NULL;    prevp = &list;    while (t = gettok(&s)) {	if (*t == '(')	    continue;	l = rindex(t, '('/*)*/);	if (!l) {	    wl = alloc(struct wordlist);	    wl->wl_word = copy(t);	    *prevp = wl;	    prevp = &wl->wl_next;	    continue;	}	r = index(t, /*(*/')');	c = index(t, ',');	if (!c)	    c = r;	if (c)	    *c = 0;	wl = alloc(struct wordlist);	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);	*prevp = wl;	prevp = &wl->wl_next;	if (c != r) {	    *r = 0;	    wl = alloc(struct wordlist);	    wl->wl_word = copy(c + 1);	    *prevp = wl;	    prevp = &wl->wl_next;	}    }    return list;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -