From dd8929457e11cd1eb273dcadb9371c19806739b2 Mon Sep 17 00:00:00 2001 From: pnenzi Date: Wed, 6 Aug 2003 18:37:51 +0000 Subject: [PATCH] Code cleaning. --- src/frontend/com_let.c | 4 +- src/frontend/postsc.c | 950 +++++++++++++++--------------- src/frontend/spiceif.c | 9 +- src/misc/string.c | 8 +- src/misc/stringutil.h | 2 +- src/spicelib/analysis/Makefile.am | 2 +- src/spicelib/analysis/ckt.h | 2 +- src/spicelib/analysis/cktdest.c | 3 +- src/spicelib/analysis/cktdojob.c | 4 +- src/spicelib/analysis/cktfbran.c | 1 - src/spicelib/analysis/cktic.c | 2 + src/spicelib/analysis/cktload.c | 5 +- src/spicelib/analysis/cktmask.c | 2 + src/spicelib/analysis/cktmpar.c | 3 + src/spicelib/analysis/cktparam.c | 1 + src/spicelib/analysis/cktpname.c | 1 + src/spicelib/analysis/cktpzld.c | 1 + src/spicelib/analysis/cktpzset.c | 2 +- src/spicelib/analysis/cktsens.c | 1 + src/spicelib/analysis/cktsetup.c | 1 + src/spicelib/analysis/cktsgen.c | 3 +- src/spicelib/analysis/cktsopt.c | 3 +- src/spicelib/analysis/ckttemp.c | 2 + src/spicelib/analysis/ckttroub.c | 2 + src/spicelib/analysis/ckttrunc.c | 1 + src/spicelib/analysis/distoan.c | 12 +- src/spicelib/analysis/noisean.c | 2 +- src/spicelib/analysis/pzan.c | 4 +- src/spicelib/analysis/tfanal.c | 2 +- src/spicelib/parser/inp2r.c | 3 +- src/spicelib/parser/inpfindl.c | 6 +- src/spicelib/parser/inppas2.c | 2 +- 32 files changed, 536 insertions(+), 510 deletions(-) diff --git a/src/frontend/com_let.c b/src/frontend/com_let.c index 22df936f3..ebf256b86 100644 --- a/src/frontend/com_let.c +++ b/src/frontend/com_let.c @@ -88,7 +88,7 @@ com_let(wordlist *wl) /* sanity check */ if (eq(p, "all") ||strchr(p, '@')) { fprintf(cp_err, "Error: bad variable name %s\n", p); - tfree(p); + tfree(p); return; } @@ -104,7 +104,7 @@ com_let(wordlist *wl) if (!t) { fprintf(cp_err, "Error: Can't evaluate %s\n", rhs); free_pnode(nn); - tfree(p); + tfree(p); return; } diff --git a/src/frontend/postsc.c b/src/frontend/postsc.c index 5046dc0b0..abb974d53 100644 --- a/src/frontend/postsc.c +++ b/src/frontend/postsc.c @@ -1,472 +1,478 @@ -/********** - Copyright 1990 Regents of the University of California. All rights reserved. - Author: 1988 Jeffrey M. Hsu -**********/ - -/* - Postscript driver -*/ - -#include "ngspice.h" -#include "cpdefs.h" -#include "graph.h" -#include "ftedbgra.h" -#include "ftedev.h" -#include "fteinput.h" - -#include "postsc.h" -#include "variable.h" - -#define RAD_TO_DEG (180.0 / M_PI) -#define DEVDEP(g) (*((PSdevdep *) (g)->devdep)) -#define MAX_PS_LINES 1000 -#define SOLID 0 -#define DOTTED 1 - -#define gtype graph->grid.gridtype -#define xoff dispdev->minx -#define yoff dispdev->miny -#define XOFF 48 /* printer left margin */ -#define YOFF 48 /* printer bottom margin */ -#define XTADJ 0 /* printer text adjustment x */ -#define YTADJ 4 /* printer text adjustment y */ - -#define GRIDSIZE 420 /* printer gridsize divisible by 10, [7-2] */ -#define GRIDSIZES 360 /* printer gridsize divisible by [10-8], [6-2] */ - -#define FONTSIZE 10 /* printer default fontsize */ -#define FONTWIDTH 6 /* printer default fontwidth */ -#define FONTHEIGHT 14 /* printer default fontheight */ - -typedef struct { - int lastlinestyle, lastcolor; /* initial invalid value */ - int lastx, lasty, linecount; -} PSdevdep; - -static char *linestyle[] = { - "[]", /* solid */ - "[1 2]", /* dotted */ - "[7 7]", /* longdashed */ - "[3 3]", /* shortdashed */ - "[7 2 2 2]", /* longdotdashed */ - "[3 2 1 2]", /* shortdotdashed */ - "[8 3 2 3]", - "[14 2]", - "[3 5 1 5]" /* dotdashed */ -}; - -static FILE *plotfile; -char psfont[128], psfontsize[32], psscale[32], pscolor[32]; -static int fontsize = FONTSIZE; -static int fontwidth = FONTWIDTH; -static int fontheight = FONTHEIGHT; -static int screenflag = 0; -static int colorflag = 0; -static double scale; /* Used for fine tuning */ -static int xtadj; /* text adjustment x */ -static int ytadj; /* text adjustment y */ -static int hcopygraphid; - - -extern int DestroyGraph (int id); -extern void internalerror (char *message); -void PS_LinestyleColor(int linestyleid, int colorid); -void PS_SelectColor(int colorid); -void PS_Stroke(void); - -int -PS_Init(void) -{ - char pswidth[30], psheight[30]; - - if (!cp_getvar("hcopyscale", VT_STRING, psscale)) { - scale = 1.0; - } else { - sscanf(psscale, "%lf", &scale); - if ((scale <= 0) || (scale > 10)) - scale = 1.0; - } - - if (!cp_getvar("hcopypscolor", VT_STRING, pscolor)) { - colorflag = 0; - dispdev->numcolors = 2; - dispdev->numlinestyles = NUMELEMS(linestyle); - } else { - colorflag = 1; - dispdev->numcolors = 18; /* don't know what the maximum should be */ - dispdev->numlinestyles = 1; - } - pscolor[0]='\0'; - - if (!cp_getvar("hcopywidth", VT_STRING, pswidth)) { - dispdev->width = 7.75 * 72.0 * scale; /* (8 1/2 - 3/4) * 72 */ - } else { - sscanf(pswidth, "%d", &(dispdev->width)); - if (dispdev->width <= 100) - dispdev->width = 100; - if (dispdev->width >= 10000) - dispdev->width = 10000; - } - if (!cp_getvar("hcopyheight", VT_STRING, psheight)) { - dispdev->height = dispdev->width; - } else { - sscanf(psheight, "%d", &(dispdev->height)); - if (dispdev->height <= 100) - dispdev->height = 100; - if (dispdev->height >= 10000) - dispdev->height = 10000; - } - - /* The following side effects have to be considered - * when the printer is called by com_hardcopy ! - * gr_init: - * viewportxoff = 8 * fontwidth - * viewportyoff = 4 * fontheight - * gr_resize_internal: - * viewport.width = absolute.width - 2 * viewportxoff - * viewport.height = absolute.height - 2 * viewportyoff - */ - - if (!cp_getvar("hcopyfont", VT_STRING, psfont)) - strcpy(psfont, "Helvetica"); - if (!cp_getvar("hcopyfontsize", VT_STRING, psfontsize)) { - fontsize = 10; - fontwidth = 6; - fontheight = 14; - xtadj = XTADJ * scale; - ytadj = YTADJ * scale; - } else { - sscanf(psfontsize, "%d", &fontsize); - if ((fontsize < 10) || (fontsize > 14)) - fontsize = 10; - fontwidth = 0.5 + 0.6 * fontsize; - fontheight = 2.5 + 1.2 * fontsize; - xtadj = XTADJ * scale * fontsize / 10; - ytadj = YTADJ * scale * fontsize / 10; - } - - screenflag = 0; - dispdev->minx = XOFF / scale; - dispdev->miny = YOFF / scale; - return(0); -} - -/* devdep initially contains name of output file */ -int -PS_NewViewport(GRAPH *graph) -{ - int x1,x2,y1,y2; - hcopygraphid = graph->graphid; - - if (!(plotfile = fopen(graph->devdep, "w"))) { - perror(graph->devdep); - graph->devdep = (char *) NULL; - return(1); - } - - if (graph->absolute.width) { - /* hardcopying from the screen */ - - screenflag = 1; - } - - /* reasonable values, used in gr_ for placement */ - graph->fontwidth = fontwidth * scale; /* was 12, p.w.h. */ - graph->fontheight = fontheight * scale; /* was 24, p.w.h. */ - - graph->absolute.width = dispdev->width; - graph->absolute.height = dispdev->height; - /* Also done in gr_init, if called . . . */ - graph->viewportxoff = 8 * fontwidth; - graph->viewportyoff = 4 * fontheight; - - xoff = scale * XOFF; - yoff = scale * YOFF; - - x1 = 0.75 * 72; - y1 = x1; - x2 = graph->absolute.width + .75 * 72; - y2 = graph->absolute.height + .75 * 72; - /* start file off with a % */ - fprintf(plotfile, "%%!PS-Adobe-3.0 EPSF-3.0\n"); - fprintf(plotfile, "%%%%Creator: nutmeg\n"); - fprintf(plotfile, "%%%%BoundingBox: %d %d %d %d\n",x1,y1,x2,y2); - - fprintf(plotfile, "%g %g scale\n", 1.0 / scale, 1.0 / scale); - - if (colorflag == 1){ /* set the background to color0 */ - PS_SelectColor(0); - fprintf(plotfile,"%s setrgbcolor\n",pscolor); - fprintf(plotfile,"newpath\n"); - fprintf(plotfile,"%d %d moveto %d %d lineto\n",x1,y1,x2,y1); - fprintf(plotfile,"%d %d lineto %d %d lineto\n",x2,y2,x1,y2); - fprintf(plotfile,"closepath fill\n"); - } - - /* set up a reasonable font */ - fprintf(plotfile, "/%s findfont %d scalefont setfont\n\n", - psfont, (int) (fontsize * scale)); - - graph->devdep = tmalloc(sizeof(PSdevdep)); - DEVDEP(graph).lastlinestyle = -1; - DEVDEP(graph).lastcolor = -1; - DEVDEP(graph).lastx = -1; - DEVDEP(graph).lasty = -1; - DEVDEP(graph).linecount = 0; - PS_SelectColor(0); - graph->linestyle = -1; - - return 0; -} - -void -PS_Close(void) -{ - /* in case PS_Close is called as part of an abort, - w/o having reached PS_NewViewport */ - if (plotfile){ - PS_Stroke(); - fprintf(plotfile, "showpage\n%%%%EOF\n"); - fclose(plotfile); - plotfile = NULL; - } - - /* In case of hardcopy command destroy the hardcopy graph - * and reset currentgraph to graphid 1, if possible - */ - if (!screenflag) { - DestroyGraph(hcopygraphid); - currentgraph = FindGraph(1); - } -} - -void -PS_Clear(void) -{ - /* do nothing */ -} - -void -PS_DrawLine(int x1, int y1, int x2, int y2) -{ - /* note: this is not extendible to more than one graph - => will have to give NewViewport a writeable graph XXX */ - - if (DEVDEP(currentgraph).linecount > MAX_PS_LINES - || DEVDEP(currentgraph).linecount == 0 - || x1 != DEVDEP(currentgraph).lastx - || y1 != DEVDEP(currentgraph).lasty){ - PS_Stroke(); - fprintf(plotfile, "newpath\n"); - fprintf(plotfile, "%d %d moveto\n", x1 + xoff, y1 + yoff); - DEVDEP(currentgraph).linecount += 1; - } - if (x1 != x2 || y1 != y2) { - fprintf(plotfile, "%d %d lineto\n", x2 + xoff, y2 + yoff); - DEVDEP(currentgraph).linecount += 1; - } - - DEVDEP(currentgraph).lastx = x2; - DEVDEP(currentgraph).lasty = y2; -} - -void -PS_Arc(int x0, int y0, int r, double theta1, double theta2) -{ - double x1, y1; - double angle1, angle2; - PS_Stroke(); - while (theta1 >= theta2) - theta2 += 2 * M_PI; - - angle1 = (double) (RAD_TO_DEG * theta1); - angle2 = (double) (RAD_TO_DEG * theta2); - x1 = (double) x0 + r * cos(theta1); - y1 = (double) y0 + r * sin(theta1); - - fprintf(plotfile, "%f %f moveto ", x1+(double)xoff, y1+(double)yoff); - fprintf(plotfile, "%d %d %d %f %f arc\n", x0+xoff, y0+yoff, r, - angle1, angle2); - fprintf(plotfile, "stroke\n"); - - DEVDEP(currentgraph).linecount = 0; -} - -void -PS_Text(char *text, int x, int y) -{ - int savedlstyle, savedcolor; - - /* set linestyle to solid - or may get funny color text on some plotters */ - savedlstyle = currentgraph->linestyle; - savedcolor = currentgraph->currentcolor; - - PS_SetLinestyle(SOLID); - PS_SetColor(1); - - /* stroke the path if there's an open one */ - PS_Stroke(); - /* move to (x, y) */ - fprintf(plotfile, "%d %d moveto\n", x + xoff + xtadj, y + yoff + ytadj); - fprintf(plotfile, "(%s) show\n", text); - - DEVDEP(currentgraph).lastx = -1; - DEVDEP(currentgraph).lasty = -1; - - /* restore old linestyle */ - - PS_SetColor(savedcolor); - PS_SetLinestyle(savedlstyle); -} - -/* PS_DefineColor */ -/* PS_DefineLinestyle */ - -int -PS_SetLinestyle(int linestyleid) -{ - /* special case - get it when PS_Text restores a -1 linestyle */ - if (linestyleid == -1) { - currentgraph->linestyle = -1; - return 0; - } - if (linestyleid < 0 || linestyleid > dispdev->numlinestyles) { - internalerror("bad linestyleid inside PS_SetLinestyle"); - return 0; - } - PS_LinestyleColor(linestyleid, currentgraph->currentcolor); - return 0; -} - -void -PS_SetColor(int colorid) -{ - PS_LinestyleColor(currentgraph->linestyle, colorid); -} - -void -PS_Update(void) -{ - fflush(plotfile); -} - -/**************** PRIVAT FUNCTIONS OF PS FRONTEND *****************************/ - -void -PS_SelectColor(int colorid) /* should be replaced by PS_DefineColor */ -{ - char colorN[30]="", colorstring[30]=""; - char rgb[30], s_red[30]="0x", s_green[30]="0x", s_blue[30]="0x"; - long red=0, green=0, blue=0, scale=1; - int i; - typedef struct { int red, green, blue;} COLOR; - /* duplicated colors from src/frontend/plotting/x11.c in rgb-style */ - const COLOR colors[]= {{ 0, 0, 0}, /*0: black */ - {255, 255, 255}, /*1: white */ - {255, 0, 0}, /*2: red */ - { 0, 0, 255}, /*3: blue */ - {255, 165, 0}, /*4: orange */ - { 0, 255, 0}, /*5: green */ - {255, 192, 203}, /*6: pink */ - {165, 42, 42}, /*7: brown */ - {240, 230, 140}, /*8: khaki */ - {221, 160, 221}, /*9: plum */ - {218, 112, 214}, /*10: orchid */ - {238, 130, 238}, /*11: violet */ - {176, 48, 96}, /*12: maroon */ - { 64, 224, 208}, /*13: turqoise */ - {160, 82, 45}, /*14: sienna */ - {255, 127, 80}, /*15: coral */ - { 0, 255, 255}, /*16: cyan */ - {255, 0, 255}, /*17: magenta */ - /*{255, 215, 0}, 18: gold */ - { 96, 96, 96}, /*18: gray for smith grid */ - /*{255, 255, 0}, 19: yello */ - {150, 150, 150}, /*19: gray for smith grid */ - {128, 128, 128}}; /*20: gray for normal grid */ - - /* Extract the rgbcolor, format is: "rgb://" */ - sprintf(colorN, "color%d",colorid); - if (cp_getvar(colorN, VT_STRING, colorstring)){ - for (i=0; colorstring[i]; i++) - if (colorstring[i] == '/' || colorstring[i] == ':') - colorstring[i] = ' '; - - sscanf(colorstring,"%s %s %s %s",rgb, &(s_red[2]), &(s_green[2]), &(s_blue[2])); - - if ((strlen(s_blue) == strlen(s_red) && strlen(s_green) == strlen(s_red)) - && (strlen(s_blue) > 2) && (strlen(s_blue) < 7)){ - sscanf(s_red,"%lx",&red); - sscanf(s_green,"%lx",&green); - sscanf(s_blue,"%lx",&blue); - scale= (1 << (strlen(s_blue) - 2) * 4) - 1; - sprintf(colorstring,"%1.3f %1.3f %1.3f", - (float) red/scale, (float) green/scale, (float) blue/scale); - strcpy(pscolor, colorstring); - } - } - if (colorid < 0 || colorid > 20) { - internalerror("bad colorid inside PS_SelectColor"); - }else if (scale == 1){ /* colorN is not an rgbstring, use default color */ - sprintf(colorstring,"%1.3f %1.3f %1.3f",colors[colorid].red/255.0, - colors[colorid].green/255.0, colors[colorid].blue/255.0) ; - strcpy(pscolor, colorstring); - } -} - -void -PS_LinestyleColor(int linestyleid, int colorid) -{ - /* we have some different linestyles and colors: - - color and linestyle we got via function call - - color and linestyle we used last time for drawing - - generated color and linestyle we'll use for drawing this time */ - /* these are the rules: - DOTTED and colored ps -> color20 (used for grid) and SOLID - color18 or 19 and black-white -> linestyle is DOTTED */ - - int gencolor=0,genstyle=0; - - if (colorflag == 1){ - genstyle = SOLID; - if (linestyleid==DOTTED) - gencolor = 20; - else - gencolor = colorid; - } else { /* colorflag == 0 -> mono*/ - if ((colorid == 18) || (colorid == 19)) - genstyle=DOTTED; - else - genstyle=linestyleid; - } - - /* change color if nessecary */ - if (colorflag == 1 && gencolor != DEVDEP(currentgraph).lastcolor){ - PS_SelectColor(gencolor); - PS_Stroke(); - fprintf(plotfile,"%s setrgbcolor\n",pscolor); - DEVDEP(currentgraph).lastcolor = gencolor; - } - currentgraph->currentcolor = colorid; - - /* change linestyle if nessecary */ - if (colorflag == 0 && genstyle != DEVDEP(currentgraph).lastlinestyle){ - PS_Stroke(); - fprintf(plotfile, "%s 0 setdash\n", linestyle[genstyle]); - DEVDEP(currentgraph).lastlinestyle= genstyle; - } - currentgraph->linestyle = linestyleid; -} - -void -PS_Stroke(void) -{ - /* strokes an open path */ - if (DEVDEP(currentgraph).linecount > 0) { - fprintf(plotfile, "stroke\n"); - DEVDEP(currentgraph).linecount = 0; - } -} - +/********** +Copyright 1990 Regents of the University of California. All rights reserved. +Author: 1988 Jeffrey M. Hsu +**********/ + +/* + Postscript driver +*/ + +#include "ngspice.h" +#include "cpdefs.h" +#include "graph.h" +#include "ftedbgra.h" +#include "ftedev.h" +#include "fteinput.h" + +#include "postsc.h" +#include "variable.h" + +#define RAD_TO_DEG (180.0 / M_PI) +#define DEVDEP(g) (*((PSdevdep *) (g)->devdep)) +#define MAX_PS_LINES 1000 +#define SOLID 0 +#define DOTTED 1 + +#define gtype graph->grid.gridtype +#define xoff dispdev->minx +#define yoff dispdev->miny +#define XOFF 48 /* printer left margin */ +#define YOFF 48 /* printer bottom margin */ +#define XTADJ 0 /* printer text adjustment x */ +#define YTADJ 4 /* printer text adjustment y */ + +#define GRIDSIZE 420 /* printer gridsize divisible by 10, [7-2] */ +#define GRIDSIZES 360 /* printer gridsize divisible by [10-8], [6-2] */ + +#define FONTSIZE 10 /* printer default fontsize */ +#define FONTWIDTH 6 /* printer default fontwidth */ +#define FONTHEIGHT 14 /* printer default fontheight */ + +typedef struct { + int lastlinestyle, lastcolor; /* initial invalid value */ + int lastx, lasty, linecount; +} PSdevdep; + +static char *linestyle[] = { + "[]", /* solid */ + "[1 2]", /* dotted */ + "[7 7]", /* longdashed */ + "[3 3]", /* shortdashed */ + "[7 2 2 2]", /* longdotdashed */ + "[3 2 1 2]", /* shortdotdashed */ + "[8 3 2 3]", + "[14 2]", + "[3 5 1 5]" /* dotdashed */ + }; + +static FILE *plotfile; +char psfont[128], psfontsize[32], psscale[32], pscolor[32]; +static int fontsize = FONTSIZE; +static int fontwidth = FONTWIDTH; +static int fontheight = FONTHEIGHT; +static int screenflag = 0; +static int colorflag = 0; +static double scale; /* Used for fine tuning */ +static int xtadj; /* text adjustment x */ +static int ytadj; /* text adjustment y */ +static int hcopygraphid; + + +extern int DestroyGraph (int id); +extern void internalerror (char *message); +void PS_LinestyleColor(int linestyleid, int colorid); +void PS_SelectColor(int colorid); +void PS_Stroke(void); + +int +PS_Init(void) +{ + char pswidth[30], psheight[30]; + + if (!cp_getvar("hcopyscale", VT_STRING, psscale)) { + scale = 1.0; + } else { + sscanf(psscale, "%lf", &scale); + if ((scale <= 0) || (scale > 10)) + scale = 1.0; + } + + if (!cp_getvar("hcopypscolor", VT_STRING, pscolor)) { + colorflag = 0; + dispdev->numcolors = 2; + dispdev->numlinestyles = NUMELEMS(linestyle); + } else { + colorflag = 1; + dispdev->numcolors = 18; /* don't know what the maximum should be */ + dispdev->numlinestyles = 1; + } + pscolor[0]='\0'; + + if (!cp_getvar("hcopywidth", VT_STRING, pswidth)) { + dispdev->width = 7.75 * 72.0 * scale; /* (8 1/2 - 3/4) * 72 */ + } else { + sscanf(pswidth, "%d", &(dispdev->width)); + if (dispdev->width <= 100) + dispdev->width = 100; + if (dispdev->width >= 10000) + dispdev->width = 10000; + } + if (!cp_getvar("hcopyheight", VT_STRING, psheight)) { + dispdev->height = dispdev->width; + } else { + sscanf(psheight, "%d", &(dispdev->height)); + if (dispdev->height <= 100) + dispdev->height = 100; + if (dispdev->height >= 10000) + dispdev->height = 10000; + } + + /* The following side effects have to be considered + * when the printer is called by com_hardcopy ! + * gr_init: + * viewportxoff = 8 * fontwidth + * viewportyoff = 4 * fontheight + * gr_resize_internal: + * viewport.width = absolute.width - 2 * viewportxoff + * viewport.height = absolute.height - 2 * viewportyoff + */ + + if (!cp_getvar("hcopyfont", VT_STRING, psfont)) + strcpy(psfont, "Helvetica"); + if (!cp_getvar("hcopyfontsize", VT_STRING, psfontsize)) { + fontsize = 10; + fontwidth = 6; + fontheight = 14; + xtadj = XTADJ * scale; + ytadj = YTADJ * scale; + } else { + sscanf(psfontsize, "%d", &fontsize); + if ((fontsize < 10) || (fontsize > 14)) + fontsize = 10; + fontwidth = 0.5 + 0.6 * fontsize; + fontheight = 2.5 + 1.2 * fontsize; + xtadj = XTADJ * scale * fontsize / 10; + ytadj = YTADJ * scale * fontsize / 10; + } + + screenflag = 0; + dispdev->minx = XOFF / scale; + dispdev->miny = YOFF / scale; + + return(0); + +} + +/* devdep initially contains name of output file */ +int +PS_NewViewport(GRAPH *graph) +{ + int x1,x2,y1,y2; + hcopygraphid = graph->graphid; + + if (!(plotfile = fopen(graph->devdep, "w"))) { + perror(graph->devdep); + graph->devdep = (char *) NULL; + return(1); + } + + if (graph->absolute.width) { + /* hardcopying from the screen */ + + screenflag = 1; + } + + /* reasonable values, used in gr_ for placement */ + graph->fontwidth = fontwidth * scale; /* was 12, p.w.h. */ + graph->fontheight = fontheight * scale; /* was 24, p.w.h. */ + + graph->absolute.width = dispdev->width; + graph->absolute.height = dispdev->height; + /* Also done in gr_init, if called . . . */ + graph->viewportxoff = 8 * fontwidth; + graph->viewportyoff = 4 * fontheight; + + xoff = scale * XOFF; + yoff = scale * YOFF; + + x1 = 0.75 * 72; + y1 = x1; + x2 = graph->absolute.width + .75 * 72; + y2 = graph->absolute.height + .75 * 72; + /* start file off with a % */ + fprintf(plotfile, "%%!PS-Adobe-3.0 EPSF-3.0\n"); + fprintf(plotfile, "%%%%Creator: nutmeg\n"); + fprintf(plotfile, "%%%%BoundingBox: %d %d %d %d\n",x1,y1,x2,y2); + + fprintf(plotfile, "%g %g scale\n", 1.0 / scale, 1.0 / scale); + + if (colorflag == 1){ /* set the background to color0 */ + PS_SelectColor(0); + fprintf(plotfile,"%s setrgbcolor\n",pscolor); + fprintf(plotfile,"newpath\n"); + fprintf(plotfile,"%d %d moveto %d %d lineto\n",x1,y1,x2,y1); + fprintf(plotfile,"%d %d lineto %d %d lineto\n",x2,y2,x1,y2); + fprintf(plotfile,"closepath fill\n"); + } + + /* set up a reasonable font */ + fprintf(plotfile, "/%s findfont %d scalefont setfont\n\n", + psfont, (int) (fontsize * scale)); + + graph->devdep = tmalloc(sizeof(PSdevdep)); + DEVDEP(graph).lastlinestyle = -1; + DEVDEP(graph).lastcolor = -1; + DEVDEP(graph).lastx = -1; + DEVDEP(graph).lasty = -1; + DEVDEP(graph).linecount = 0; + PS_SelectColor(0); + graph->linestyle = -1; + + return 0; +} + +void +PS_Close(void) +{ + + /* in case PS_Close is called as part of an abort, + w/o having reached PS_NewViewport */ + if (plotfile) { + PS_Stroke(); + fprintf(plotfile, "showpage\n%%%%EOF\n"); + fclose(plotfile); + plotfile = NULL; + } + /* In case of hardcopy command destroy the hardcopy graph + * and reset currentgraph to graphid 1, if possible + */ + if (!screenflag) { + DestroyGraph(hcopygraphid); + currentgraph = FindGraph(1); + } +} + +void +PS_Clear(void) +{ + + /* do nothing */ + +} + +void +PS_DrawLine(int x1, int y1, int x2, int y2) +{ + + /* note: this is not extendible to more than one graph + => will have to give NewViewport a writeable graph XXX */ + + if (DEVDEP(currentgraph).linecount > MAX_PS_LINES + || DEVDEP(currentgraph).linecount == 0 + || x1 != DEVDEP(currentgraph).lastx + || y1 != DEVDEP(currentgraph).lasty){ + PS_Stroke(); + fprintf(plotfile, "newpath\n"); + fprintf(plotfile, "%d %d moveto\n", x1 + xoff, y1 + yoff); + DEVDEP(currentgraph).linecount += 1; + } + if (x1 != x2 || y1 != y2) { + fprintf(plotfile, "%d %d lineto\n", x2 + xoff, y2 + yoff); + DEVDEP(currentgraph).linecount += 1; + } + + DEVDEP(currentgraph).lastx = x2; + DEVDEP(currentgraph).lasty = y2; +} + +void +PS_Arc(int x0, int y0, int r, double theta1, double theta2) +{ + double x1, y1; + double angle1, angle2; + PS_Stroke(); + while (theta1 >= theta2) + theta2 += 2 * M_PI; + + angle1 = (double) (RAD_TO_DEG * theta1); + angle2 = (double) (RAD_TO_DEG * theta2); + x1 = (double) x0 + r * cos(theta1); + y1 = (double) y0 + r * sin(theta1); + + fprintf(plotfile, "%f %f moveto ", x1+(double)xoff, y1+(double)yoff); + fprintf(plotfile, "%d %d %d %f %f arc\n", x0+xoff, y0+yoff, r, + angle1, angle2); + fprintf(plotfile, "stroke\n"); + + DEVDEP(currentgraph).linecount = 0; +} + +void +PS_Text(char *text, int x, int y) +{ + int savedlstyle, savedcolor; + + /* set linestyle to solid + or may get funny color text on some plotters */ + savedlstyle = currentgraph->linestyle; + savedcolor = currentgraph->currentcolor; + + PS_SetLinestyle(SOLID); + PS_SetColor(1); + + /* stroke the path if there's an open one */ + PS_Stroke(); + /* move to (x, y) */ + fprintf(plotfile, "%d %d moveto\n", x + xoff + xtadj, y + yoff + ytadj); + fprintf(plotfile, "(%s) show\n", text); + + DEVDEP(currentgraph).lastx = -1; + DEVDEP(currentgraph).lasty = -1; + + /* restore old linestyle */ + + PS_SetColor(savedcolor); + PS_SetLinestyle(savedlstyle); +} + +/* PS_DefineColor */ +/* PS_DefineLinestyle */ + +int +PS_SetLinestyle(int linestyleid) +{ + + /* special case + get it when PS_Text restores a -1 linestyle */ + if (linestyleid == -1) { + currentgraph->linestyle = -1; + return 0; + } + if (linestyleid < 0 || linestyleid > dispdev->numlinestyles) { + internalerror("bad linestyleid inside PS_SetLinestyle"); + return 0; + } + PS_LinestyleColor(linestyleid, currentgraph->currentcolor); + return 0; + } + +void +PS_SetColor(int colorid) +{ + PS_LinestyleColor(currentgraph->linestyle, colorid); +} + +void +PS_Update(void) +{ + fflush(plotfile); +} + +/**************** PRIVAT FUNCTIONS OF PS FRONTEND *****************************/ + +void +PS_SelectColor(int colorid) /* should be replaced by PS_DefineColor */ +{ + char colorN[30]="", colorstring[30]=""; + char rgb[30], s_red[30]="0x", s_green[30]="0x", s_blue[30]="0x"; + long red=0, green=0, blue=0, scale=1; + int i; + typedef struct { int red, green, blue;} COLOR; + /* duplicated colors from src/frontend/plotting/x11.c in rgb-style */ + const COLOR colors[]= {{ 0, 0, 0}, /*0: black */ + {255, 255, 255}, /*1: white */ + {255, 0, 0}, /*2: red */ + { 0, 0, 255}, /*3: blue */ + {255, 165, 0}, /*4: orange */ + { 0, 255, 0}, /*5: green */ + {255, 192, 203}, /*6: pink */ + {165, 42, 42}, /*7: brown */ + {240, 230, 140}, /*8: khaki */ + {221, 160, 221}, /*9: plum */ + {218, 112, 214}, /*10: orchid */ + {238, 130, 238}, /*11: violet */ + {176, 48, 96}, /*12: maroon */ + { 64, 224, 208}, /*13: turqoise */ + {160, 82, 45}, /*14: sienna */ + {255, 127, 80}, /*15: coral */ + { 0, 255, 255}, /*16: cyan */ + {255, 0, 255}, /*17: magenta */ + /*{255, 215, 0}, 18: gold */ + { 96, 96, 96}, /*18: gray for smith grid */ + /*{255, 255, 0}, 19: yello */ + {150, 150, 150}, /*19: gray for smith grid */ + {128, 128, 128}}; /*20: gray for normal grid */ + + /* Extract the rgbcolor, format is: "rgb://" */ + sprintf(colorN, "color%d",colorid); + if (cp_getvar(colorN, VT_STRING, colorstring)){ + for (i=0; colorstring[i]; i++) + if (colorstring[i] == '/' || colorstring[i] == ':') + colorstring[i] = ' '; + + sscanf(colorstring,"%s %s %s %s",rgb, &(s_red[2]), &(s_green[2]), &(s_blue[2])); + + if ((strlen(s_blue) == strlen(s_red) && strlen(s_green) == strlen(s_red)) + && (strlen(s_blue) > 2) && (strlen(s_blue) < 7)){ + sscanf(s_red,"%lx",&red); + sscanf(s_green,"%lx",&green); + sscanf(s_blue,"%lx",&blue); + scale= (1 << (strlen(s_blue) - 2) * 4) - 1; + sprintf(colorstring,"%1.3f %1.3f %1.3f", + (float) red/scale, (float) green/scale, (float) blue/scale); + strcpy(pscolor, colorstring); + } + } + if (colorid < 0 || colorid > 20) { + internalerror("bad colorid inside PS_SelectColor"); + }else if (scale == 1){ /* colorN is not an rgbstring, use default color */ + sprintf(colorstring,"%1.3f %1.3f %1.3f",colors[colorid].red/255.0, + colors[colorid].green/255.0, colors[colorid].blue/255.0) ; + strcpy(pscolor, colorstring); + } + } + +void +PS_LinestyleColor(int linestyleid, int colorid) +{ + /* we have some different linestyles and colors: + - color and linestyle we got via function call + - color and linestyle we used last time for drawing + - generated color and linestyle we'll use for drawing this time */ + /* these are the rules: + DOTTED and colored ps -> color20 (used for grid) and SOLID + color18 or 19 and black-white -> linestyle is DOTTED */ + + int gencolor=0,genstyle=0; + + if (colorflag == 1){ + genstyle = SOLID; + if (linestyleid==DOTTED) + gencolor = 20; + else + gencolor = colorid; + } else { /* colorflag == 0 -> mono*/ + if ((colorid == 18) || (colorid == 19)) + genstyle=DOTTED; + else + genstyle=linestyleid; + } + + /* change color if nessecary */ + if (colorflag == 1 && gencolor != DEVDEP(currentgraph).lastcolor){ + PS_SelectColor(gencolor); + PS_Stroke(); + fprintf(plotfile,"%s setrgbcolor\n",pscolor); + DEVDEP(currentgraph).lastcolor = gencolor; + } + currentgraph->currentcolor = colorid; + + /* change linestyle if nessecary */ + if (colorflag == 0 && genstyle != DEVDEP(currentgraph).lastlinestyle){ + PS_Stroke(); + fprintf(plotfile, "%s 0 setdash\n", linestyle[genstyle]); + DEVDEP(currentgraph).lastlinestyle= genstyle; + } + currentgraph->linestyle = linestyleid; +} + +void +PS_Stroke(void) +{ + /* strokes an open path */ + if (DEVDEP(currentgraph).linecount > 0) { + fprintf(plotfile, "stroke\n"); + DEVDEP(currentgraph).linecount = 0; + } +} + diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 412eabc64..162daa5d3 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -284,9 +284,10 @@ if_run(char *t, char *what, wordlist *args, char *tab) /* -- A bug fix suggested by Cecil Aswell (aswell@netcom.com) to let */ /* -- the interactive analysis commands get the current temperature */ /* -- and other options. */ -/*dw Hiermit wird auf der Eingabezeile mit "run" die letzte Simulation - wiederholt, sowie die letzte gültige Temperatur genutzt. (Warum die - in defOpt drin steht, steht in den Sternen!) */ + +/* dw With this the last simulation will be repeated on the input line, and the +last valid temperature is used. (Why is the  temperature is within defOpt?!) +*/ if( eq(what,"run") ) { ft_curckt->ci_curTask = ft_curckt->ci_defTask; ft_curckt->ci_curOpt = ft_curckt->ci_defOpt; @@ -305,7 +306,7 @@ if_run(char *t, char *what, wordlist *args, char *tab) ||(eq(what, "sens")) ||(eq(what,"tf")) ||(eq(what, "run")) ) { -/*dw Nutzung der letzten gültigen Temperatur, z.B. nach "set temp" s.o. */ +/*dw Nutzung der letzten gültigen Temperatur, z.B. nach "set temp" s.o. */ ft_curckt->ci_curOpt = ft_curckt->ci_defOpt; if ((err = (*(ft_sim->doAnalyses))(ckt, 1, ft_curckt->ci_curTask))!=OK){ ft_sperror(err, "doAnalyses"); diff --git a/src/misc/string.c b/src/misc/string.c index d0a6c34c1..3c74d39b2 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -235,10 +235,10 @@ get_r_paren(char **s) #ifndef bcopy void -bcopy(const void *vfrom, void *vto, size_t num) +bcopy(const void *vfrom, void *vto, size_t num) { - register const char *from = vfrom; - register char *to = vto; + register const char *from=vfrom; + register char *to=vto; while (num-- > 0) *to++ = *from++; return; @@ -248,7 +248,7 @@ bcopy(const void *vfrom, void *vto, size_t num) #ifndef bzero /* can't declare void here, because we've already used it in this file */ /* and haven't declared it void before the use */ -void +void bzero(void *vptr, size_t num) { register char *ptr=vptr; diff --git a/src/misc/stringutil.h b/src/misc/stringutil.h index c41ac754b..759a1cd39 100644 --- a/src/misc/stringutil.h +++ b/src/misc/stringutil.h @@ -25,7 +25,7 @@ char * rindex(register char *s,register char c ); #ifndef HAVE_BCOPY -void bcopy(const void *from, void *to, size_t num); +void bcopy(const void *from, void *to, size_t num); void bzero(void *ptr, size_t num); #endif /* HAVE_BCOPY */ diff --git a/src/spicelib/analysis/Makefile.am b/src/spicelib/analysis/Makefile.am index f9a49c0c9..d828f2b24 100644 --- a/src/spicelib/analysis/Makefile.am +++ b/src/spicelib/analysis/Makefile.am @@ -97,7 +97,7 @@ libckt_a_SOURCES = \ traninit.c \ transetp.c \ cluster.c \ - ckt.h + ckt.h INCLUDES = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/spicelib/devices diff --git a/src/spicelib/analysis/ckt.h b/src/spicelib/analysis/ckt.h index 013dacedf..3a26f12bb 100644 --- a/src/spicelib/analysis/ckt.h +++ b/src/spicelib/analysis/ckt.h @@ -90,7 +90,7 @@ int DCOaskQuest( CKTcircuit *, void *, int , IFvalue *); int DCOsetParm( CKTcircuit *, void *, int , IFvalue *); int DCTaskQuest( CKTcircuit *, void *, int , IFvalue *); int DCTsetParm( CKTcircuit *, void *, int , IFvalue *); -int DCop( CKTcircuit *, int); +int DCop( CKTcircuit *, int ); int DCtrCurv( CKTcircuit *, int ); int DCtran( CKTcircuit *, int ); int DISTOan(CKTcircuit *, int); diff --git a/src/spicelib/analysis/cktdest.c b/src/spicelib/analysis/cktdest.c index 5a3ccf728..3e87fee42 100644 --- a/src/spicelib/analysis/cktdest.c +++ b/src/spicelib/analysis/cktdest.c @@ -19,8 +19,9 @@ Author: 1985 Thomas L. Quarles #include "sperror.h" - extern SPICEdev **DEVices; + + int CKTdestroy(void *inCkt) { diff --git a/src/spicelib/analysis/cktdojob.c b/src/spicelib/analysis/cktdojob.c index 693a79e9c..71e2857f4 100644 --- a/src/spicelib/analysis/cktdojob.c +++ b/src/spicelib/analysis/cktdojob.c @@ -156,9 +156,9 @@ printf("Doing analysis at TEMP = %f and TNOM = %f\n", return(error); } /* gtri - end - 6/10/91 - wbk - Setup event-driven data */ -#endif +#endif error = (*(analInfo[i]->an_func))(ckt, reset); - } + } if (error) error2 = error; } diff --git a/src/spicelib/analysis/cktfbran.c b/src/spicelib/analysis/cktfbran.c index 15e7ff646..518462be7 100644 --- a/src/spicelib/analysis/cktfbran.c +++ b/src/spicelib/analysis/cktfbran.c @@ -22,7 +22,6 @@ int CKTfndBranch(CKTcircuit *ckt, IFuid name) { extern SPICEdev **DEVices; - int i; int j; diff --git a/src/spicelib/analysis/cktic.c b/src/spicelib/analysis/cktic.c index f70a9c21f..8fbb70c66 100644 --- a/src/spicelib/analysis/cktic.c +++ b/src/spicelib/analysis/cktic.c @@ -12,8 +12,10 @@ Author: 1985 Thomas L. Quarles + extern SPICEdev **DEVices; + int CKTic(CKTcircuit *ckt) { diff --git a/src/spicelib/analysis/cktload.c b/src/spicelib/analysis/cktload.c index dd76317cb..e86bec724 100644 --- a/src/spicelib/analysis/cktload.c +++ b/src/spicelib/analysis/cktload.c @@ -83,7 +83,7 @@ CKTload(CKTcircuit *ckt) #endif /* PARALLEL_ARCH */ } } - + /* gtri - add - wbk - 11/26/90 - reset the MIF init flags */ #ifdef XSPICE /* init is set by CKTinit and should be true only for first load call */ @@ -107,7 +107,8 @@ CKTload(CKTcircuit *ckt) } #endif /* gtri - end - Put resistors to ground at all nodes */ - + + if(ckt->CKTmode & MODEDC) { /* consider doing nodeset & ic assignments */ if(ckt->CKTmode & (MODEINITJCT | MODEINITFIX)) { diff --git a/src/spicelib/analysis/cktmask.c b/src/spicelib/analysis/cktmask.c index 95147576c..d2659037e 100644 --- a/src/spicelib/analysis/cktmask.c +++ b/src/spicelib/analysis/cktmask.c @@ -17,6 +17,8 @@ Author: 1985 Thomas L. Quarles extern SPICEdev **DEVices; + + /* ARGSUSED */ int CKTmodAsk(void *ckt, void *modfast, int which, IFvalue *value, IFvalue *selector) diff --git a/src/spicelib/analysis/cktmpar.c b/src/spicelib/analysis/cktmpar.c index 96e3b159d..192aadbe1 100644 --- a/src/spicelib/analysis/cktmpar.c +++ b/src/spicelib/analysis/cktmpar.c @@ -15,8 +15,11 @@ Author: 1985 Thomas L. Quarles #include "sperror.h" + extern SPICEdev **DEVices; + + /* ARGSUSED */ int CKTmodParam(void *ckt, void *modfast, int param, IFvalue *val, IFvalue *selector) diff --git a/src/spicelib/analysis/cktparam.c b/src/spicelib/analysis/cktparam.c index f274e0f0a..b77e57daa 100644 --- a/src/spicelib/analysis/cktparam.c +++ b/src/spicelib/analysis/cktparam.c @@ -18,6 +18,7 @@ Author: 1985 Thomas L. Quarles extern SPICEdev **DEVices; + /* ARGSUSED */ int CKTparam(void *ckt, void *fast, int param, IFvalue *val, IFvalue *selector) diff --git a/src/spicelib/analysis/cktpname.c b/src/spicelib/analysis/cktpname.c index b35310149..6be5178c3 100644 --- a/src/spicelib/analysis/cktpname.c +++ b/src/spicelib/analysis/cktpname.c @@ -23,6 +23,7 @@ Author: 1985 Thomas L. Quarles extern SPICEdev **DEVices; + /* ARGSUSED */ int CKTpName(char *parm, IFvalue *val, CKTcircuit *ckt, int dev, char *name, GENinstance **fast) diff --git a/src/spicelib/analysis/cktpzld.c b/src/spicelib/analysis/cktpzld.c index 0de8e283c..090561166 100644 --- a/src/spicelib/analysis/cktpzld.c +++ b/src/spicelib/analysis/cktpzld.c @@ -14,6 +14,7 @@ Copyright 1990 Regents of the University of California. All rights reserved. extern SPICEdev **DEVices; + int CKTpzLoad(CKTcircuit *ckt, SPcomplex *s) { diff --git a/src/spicelib/analysis/cktpzset.c b/src/spicelib/analysis/cktpzset.c index cce41cd51..c091fce54 100644 --- a/src/spicelib/analysis/cktpzset.c +++ b/src/spicelib/analysis/cktpzset.c @@ -19,7 +19,7 @@ Copyright 1990 Regents of the University of California. All rights reserved. int CKTpzSetup(CKTcircuit *ckt, int type) { - extern SPICEdev **DEVices; + extern SPICEdev **DEVices; PZAN *pzan = (PZAN *) ckt->CKTcurJob; SMPmatrix *matrix; int error; diff --git a/src/spicelib/analysis/cktsens.c b/src/spicelib/analysis/cktsens.c index 928f47ac8..2422231d7 100644 --- a/src/spicelib/analysis/cktsens.c +++ b/src/spicelib/analysis/cktsens.c @@ -35,6 +35,7 @@ static double inc_freq(double freq, int type, double step_size); extern SPICEdev **DEVices; + /* * Procedure: * diff --git a/src/spicelib/analysis/cktsetup.c b/src/spicelib/analysis/cktsetup.c index 963bf40ab..d5f05c021 100644 --- a/src/spicelib/analysis/cktsetup.c +++ b/src/spicelib/analysis/cktsetup.c @@ -25,6 +25,7 @@ Author: 1985 Thomas L. Quarles extern SPICEdev **DEVices; + int CKTsetup(CKTcircuit *ckt) { diff --git a/src/spicelib/analysis/cktsgen.c b/src/spicelib/analysis/cktsgen.c index 4760a2ff3..a208a559b 100644 --- a/src/spicelib/analysis/cktsgen.c +++ b/src/spicelib/analysis/cktsgen.c @@ -11,7 +11,8 @@ Copyright 1991 Regents of the University of California. All rights reserved. #include extern SPICEdev **DEVices; - /* XXX */ + + /* XXX */ extern char *Sfilter; sgen * diff --git a/src/spicelib/analysis/cktsopt.c b/src/spicelib/analysis/cktsopt.c index f7cb8ab1c..3a963bf53 100644 --- a/src/spicelib/analysis/cktsopt.c +++ b/src/spicelib/analysis/cktsopt.c @@ -27,7 +27,6 @@ Modified: 2000 AlansFixes /* gtri - end - wbk - add includes */ #endif - /* ARGSUSED */ int CKTsetOpt(void *ckt, void *anal, int opt, IFvalue *val) @@ -195,7 +194,7 @@ CKTsetOpt(void *ckt, void *anal, int opt, IFvalue *val) } break; #endif -/* gtri - end - wbk - add new options */ +/* gtri - end - wbk - add new options */ default: return(-1); } diff --git a/src/spicelib/analysis/ckttemp.c b/src/spicelib/analysis/ckttemp.c index 680943878..a21877ce0 100644 --- a/src/spicelib/analysis/ckttemp.c +++ b/src/spicelib/analysis/ckttemp.c @@ -21,6 +21,8 @@ Author: 1985 Thomas L. Quarles extern SPICEdev **DEVices; + + int CKTtemp(CKTcircuit *ckt) { diff --git a/src/spicelib/analysis/ckttroub.c b/src/spicelib/analysis/ckttroub.c index 23902b1d6..dfa892731 100644 --- a/src/spicelib/analysis/ckttroub.c +++ b/src/spicelib/analysis/ckttroub.c @@ -14,6 +14,8 @@ Copyright 1990 Regents of the University of California. All rights reserved. #include "analysis.h" extern SPICEdev **DEVices; + + extern SPICEanalysis *analInfo[]; char * diff --git a/src/spicelib/analysis/ckttrunc.c b/src/spicelib/analysis/ckttrunc.c index d10872af2..23ef03afa 100644 --- a/src/spicelib/analysis/ckttrunc.c +++ b/src/spicelib/analysis/ckttrunc.c @@ -20,6 +20,7 @@ Author: 1985 Thomas L. Quarles extern SPICEdev **DEVices; + int CKTtrunc(CKTcircuit *ckt, double *timeStep) { diff --git a/src/spicelib/analysis/distoan.c b/src/spicelib/analysis/distoan.c index 3fea7804c..a14b015b9 100644 --- a/src/spicelib/analysis/distoan.c +++ b/src/spicelib/analysis/distoan.c @@ -120,7 +120,7 @@ time1 = (*(SPfrontEnd->IFseconds))(); if(error) return(error); CKTdump(ckt,(double)0,acPlot); (*(SPfrontEnd->OUTendPlot))(acPlot); - acPlot=NULL; + acPlot = NULL; } #ifdef D_DBG_BLOCKTIMES @@ -541,7 +541,7 @@ time1 = (*(SPfrontEnd->IFseconds))(); if(error) return(error); } (*(SPfrontEnd->OUTendPlot))(acPlot); - acPlot=NULL; + acPlot = NULL; error = CKTnames(ckt,&numNames,&nameList); if(error) return(error); @@ -560,7 +560,7 @@ time1 = (*(SPfrontEnd->IFseconds))(); error = CKTacDump(ckt,ckt->CKTrhsOld[0],acPlot); } (*(SPfrontEnd->OUTendPlot))(acPlot); - acPlot=NULL; + acPlot = NULL; } else { @@ -583,7 +583,7 @@ time1 = (*(SPfrontEnd->IFseconds))(); if(error) return(error); } (*(SPfrontEnd->OUTendPlot))(acPlot); - acPlot=NULL; + acPlot = NULL; error = CKTnames(ckt,&numNames,&nameList); if(error) return(error); @@ -604,7 +604,7 @@ time1 = (*(SPfrontEnd->IFseconds))(); if(error) return(error); } (*(SPfrontEnd->OUTendPlot))(acPlot); - acPlot=NULL; + acPlot = NULL; error = CKTnames(ckt,&numNames,&nameList); if(error) return(error); @@ -625,7 +625,7 @@ time1 = (*(SPfrontEnd->IFseconds))(); if(error) return(error); } (*(SPfrontEnd->OUTendPlot))(acPlot); - acPlot=NULL; + acPlot = NULL; } FREE(job->r1H1ptr); diff --git a/src/spicelib/analysis/noisean.c b/src/spicelib/analysis/noisean.c index 368f76da1..45bbd6f06 100644 --- a/src/spicelib/analysis/noisean.c +++ b/src/spicelib/analysis/noisean.c @@ -169,7 +169,7 @@ NOISEan (CKTcircuit *ckt, int restart) "Noise Spectral Density Curves - (V^2 or A^2)/Hz", freqUid,IF_REAL,666,data->namelist,666, &(data->NplotPtr)); - /*saj*/ + /*saj*/ } switch (job->NstpType) { diff --git a/src/spicelib/analysis/pzan.c b/src/spicelib/analysis/pzan.c index 0e7c7db6a..1a2e5ebd8 100644 --- a/src/spicelib/analysis/pzan.c +++ b/src/spicelib/analysis/pzan.c @@ -22,7 +22,7 @@ PZan(CKTcircuit *ckt, int reset) int error; int numNames; IFuid *nameList; - void *plot=NULL; + void *plot = NULL; error = PZinit(ckt); if (error != OK) return error; @@ -123,7 +123,7 @@ int PZpost(CKTcircuit *ckt) { PZAN *pzan = (PZAN *) ckt->CKTcurJob; - void *pzPlotPtr=NULL; /* the plot pointer for front end */ + void *pzPlotPtr = NULL; /* the plot pointer for front end */ IFcomplex *out_list; IFvalue outData; /* output variable (points to out_list) */ IFuid *namelist; diff --git a/src/spicelib/analysis/tfanal.c b/src/spicelib/analysis/tfanal.c index b92a315bf..24b27681f 100644 --- a/src/spicelib/analysis/tfanal.c +++ b/src/spicelib/analysis/tfanal.c @@ -29,7 +29,7 @@ TFanal(CKTcircuit *ckt, int restart) int error; int converged; int i; - void *plotptr=NULL; /* pointer to out plot */ + void *plotptr = NULL; /* pointer to out plot */ void *ptr = NULL; IFuid uids[3]; int Itype; diff --git a/src/spicelib/parser/inp2r.c b/src/spicelib/parser/inp2r.c index 131e9d097..fe9a686d0 100644 --- a/src/spicelib/parser/inp2r.c +++ b/src/spicelib/parser/inp2r.c @@ -79,8 +79,8 @@ void INP2R(void *ckt, INPtables * tab, card * current) type = thismodel->INPmodType; } } else { - /* It is not a model */ tfree(model); + /* It is not a model */ line = saveline; /* go back */ type = mytype; if (!tab->defRmod) { /* create default R model */ @@ -92,6 +92,7 @@ void INP2R(void *ckt, INPtables * tab, card * current) } IFC(newInstance, (ckt, mdfast, &fast, name)); } else { + tfree(model); /* The token is null and a default model will be created */ type = mytype; if (!tab->defRmod) { diff --git a/src/spicelib/parser/inpfindl.c b/src/spicelib/parser/inpfindl.c index f6a049521..e3c8baead 100644 --- a/src/spicelib/parser/inpfindl.c +++ b/src/spicelib/parser/inpfindl.c @@ -20,9 +20,9 @@ char *INPfindLev(char *line, int *level) { char *where; - /* - * where = line; - */ + /* + *where = line; + */ where = strstr(line, "level"); diff --git a/src/spicelib/parser/inppas2.c b/src/spicelib/parser/inppas2.c index 041fe5dea..11c58c3df 100644 --- a/src/spicelib/parser/inppas2.c +++ b/src/spicelib/parser/inppas2.c @@ -75,7 +75,7 @@ void INPpas2(void *ckt, card * data, INPtables * tab, void *task) /* gtri - end - wbk - 10/23/90 */ #endif - + case 'R': /* Rname [][][w=][l=] */ INP2R(ckt, tab, current);