void lex_FreeBuffer(SLexerBuffer* buffer) { if (buffer) { if (buffer->buffer) { mem_Free(buffer->buffer); } else { internalerror("buf->pBufferStart not initialized"); } mem_Free(buffer); } else { internalerror("Argument must not be NULL"); } }
void sect_OutputConst32(uint32_t value) { assert(g_pConfiguration->eMinimumWordSize <= MINSIZE_32BIT); if(sect_CheckAvailableSpace(4)) { switch(sect_GetCurrentType()) { case GROUP_TEXT: { switch(g_pOptions->Endian) { case ASM_LITTLE_ENDIAN: { pCurrentSection->pData[pCurrentSection->UsedSpace++] = (uint8_t)(value); pCurrentSection->pData[pCurrentSection->UsedSpace++] = (uint8_t)(value >> 8); pCurrentSection->pData[pCurrentSection->UsedSpace++] = (uint8_t)(value >> 16); pCurrentSection->pData[pCurrentSection->UsedSpace++] = (uint8_t)(value >> 24); break; } case ASM_BIG_ENDIAN: { pCurrentSection->pData[pCurrentSection->UsedSpace++] = (uint8_t)(value >> 24); pCurrentSection->pData[pCurrentSection->UsedSpace++] = (uint8_t)(value >> 16); pCurrentSection->pData[pCurrentSection->UsedSpace++] = (uint8_t)(value >> 8); pCurrentSection->pData[pCurrentSection->UsedSpace++] = (uint8_t)(value); break; } default: { internalerror("Unknown endianness"); break; } } pCurrentSection->FreeSpace -= 4; pCurrentSection->PC += 4 / g_pConfiguration->eMinimumWordSize; break; } case GROUP_BSS: { prj_Error(ERROR_SECTION_DATA); break; } default: { internalerror("Unknown GROUP type"); break; } } } }
static EGroupType sect_GetCurrentType(void) { if(pCurrentSection == NULL) internalerror("No SECTION defined"); if(pCurrentSection->pGroup == NULL) internalerror("No GROUP defined for SECTION"); if(pCurrentSection->pGroup->eType == SYM_GROUP) return pCurrentSection->pGroup->Value.GroupType; else internalerror("SECTION's GROUP symbol is not of type SYM_GROUP"); return -1; }
void sect_OutputReloc8(SExpression* expr) { assert(g_pConfiguration->eMinimumWordSize <= MINSIZE_8BIT); if(sect_CheckAvailableSpace(1)) { switch(sect_GetCurrentType()) { case GROUP_TEXT: { patch_Create(pCurrentSection, pCurrentSection->UsedSpace, expr, PATCH_BYTE); pCurrentSection->PC += 1; pCurrentSection->UsedSpace += 1; pCurrentSection->FreeSpace -= 1; break; } case GROUP_BSS: { prj_Error(ERROR_SECTION_DATA); sect_SkipBytes(1); break; } default: { internalerror("Unknown GROUP type"); break; } } } }
void sect_OutputConst8(uint8_t value) { assert(g_pConfiguration->eMinimumWordSize <= MINSIZE_8BIT); if(sect_CheckAvailableSpace(1)) { switch(sect_GetCurrentType()) { case GROUP_TEXT: { pCurrentSection->FreeSpace -= 1; pCurrentSection->pData[pCurrentSection->UsedSpace++] = value; pCurrentSection->PC += 1; break; } case GROUP_BSS: { prj_Error(ERROR_SECTION_DATA); break; } default: { internalerror("Unknown GROUP type"); break; } } } }
bool_t sect_SwitchTo_ORG_BANK(char* sectname, SSymbol* group, int32_t org, int32_t bank) { SSection* sect; if(!g_pConfiguration->bSupportBanks) internalerror("Banks not supported"); if(sect = sect_Find(sectname, group)) { if(sect->Flags == (SECTF_BANKFIXED | SECTF_ORGFIXED) && sect->Bank == bank && sect->BasePC == org) { pCurrentSection = sect; return true; } prj_Fail(ERROR_SECT_EXISTS_BANK_ORG); return false; } if(sect = sect_Create(sectname)) { sect->pGroup = group; sect->Flags = SECTF_BANKFIXED | SECTF_ORGFIXED; sect->Bank = bank; sect->BasePC = org; sect->Position = org * g_pConfiguration->eMinimumWordSize; } pCurrentSection = sect; return sect != NULL; }
GRAPH * NewGraph(void) { GRAPH *pgraph; LISTGRAPH *list; int BucketId = RunningId % NUMGBUCKETS; if ((list = TMALLOC(LISTGRAPH, 1)) == NULL) { internalerror("can't allocate a listgraph"); return (NULL); } pgraph = &list->graph; SETGRAPH(pgraph, RunningId); if (!GBucket[BucketId].list) { GBucket[BucketId].list = list; } else { /* insert at front of current list */ list->next = GBucket[BucketId].list; GBucket[BucketId].list = list; } RunningId++; return (pgraph); }
void sect_SkipBytes(int32_t count) { assert(g_pConfiguration->eMinimumWordSize <= count); if(sect_CheckAvailableSpace(count)) { //printf("*DEBUG* skipping %d bytes\n", count); switch(sect_GetCurrentType()) { case GROUP_TEXT: { if(g_pOptions->UninitChar!=-1) { while(count--) sect_OutputConst8((uint8_t)g_pOptions->UninitChar); return; } // Fall through to GROUP_BSS } case GROUP_BSS: { pCurrentSection->FreeSpace -= count; pCurrentSection->UsedSpace += count; pCurrentSection->PC += count / g_pConfiguration->eMinimumWordSize; break; } default: { internalerror("Unknown GROUP type"); } } } }
void sect_OutputRel32(SExpression* expr) { assert(g_pConfiguration->eMinimumWordSize <= MINSIZE_32BIT); if(sect_CheckAvailableSpace(4)) { switch(sect_GetCurrentType()) { case GROUP_TEXT: { patch_Create(pCurrentSection, pCurrentSection->UsedSpace, expr, g_pOptions->Endian == ASM_LITTLE_ENDIAN ? PATCH_LLONG : PATCH_BLONG); pCurrentSection->FreeSpace -= 4; pCurrentSection->PC += 4 / g_pConfiguration->eMinimumWordSize; pCurrentSection->UsedSpace += 4; break; } case GROUP_BSS: { prj_Error(ERROR_SECTION_DATA); sect_SkipBytes(4); break; } default: { internalerror("Unknown GROUP type"); break; } } } }
bool_t sect_SwitchTo_BANK(char* sectname, SSymbol* group, int32_t bank) { SSection* sect; if(!g_pConfiguration->bSupportBanks) internalerror("Banks not supported"); sect = sect_Find(sectname, group); if(sect) { if(sect->Flags == SECTF_BANKFIXED && sect->Bank == bank) { pCurrentSection = sect; return true; } prj_Fail(ERROR_SECT_EXISTS_BANK); return false; } sect = sect_Create(sectname); if(sect) { sect->pGroup = group; sect->Flags = SECTF_BANKFIXED; sect->Bank = bank; } pCurrentSection = sect; return sect != NULL; }
void lex_SetBuffer(SLexerBuffer* buffer) { if (buffer) { g_currentBuffer = buffer; } else { internalerror("Argument must not be NULL"); } }
void lex_SetState(ELexerState state) { if (g_currentBuffer) { g_currentBuffer->state = state; } else { internalerror("g_pCurrentBuffer not initialized"); } }
void sect_OutputBinaryFile(string* pFile) { /* TODO: Handle minimum word size. * Pad file if necessary. * Read words and output in chosen endianness */ FILE* f; if((pFile = fstk_FindFile(pFile)) != NULL && (f = fopen(str_String(pFile), "rb")) != NULL) { uint32_t size; fseek(f, 0, SEEK_END); size = ftell(f); fseek(f, 0, SEEK_SET); if(sect_CheckAvailableSpace(size)) { switch(sect_GetCurrentType()) { case GROUP_TEXT: { size_t read; read = fread(&pCurrentSection->pData[pCurrentSection->UsedSpace], sizeof(uint8_t), size, f); pCurrentSection->FreeSpace -= size; pCurrentSection->UsedSpace += size; pCurrentSection->PC += size / g_pConfiguration->eMinimumWordSize; if(read != size) { prj_Fail(ERROR_READ); } break; } case GROUP_BSS: { prj_Error(ERROR_SECTION_DATA); break; } default: { internalerror("Unknown GROUP type"); break; } } } fclose(f); } else { prj_Fail(ERROR_NO_FILE); } str_Free(pFile); }
int X11_DefineLinestyle(int linestyleid, int mask) { NG_IGNORE(mask); NG_IGNORE(linestyleid); internalerror("X11_DefineLinestyle not implemented."); return 0; }
int X11_DefineColor(int colorid, double red, double green, double blue) { NG_IGNORE(blue); NG_IGNORE(green); NG_IGNORE(red); NG_IGNORE(colorid); internalerror("X11_DefineColor not implemented."); return 0; }
void installopnames(tnode * tptr) { tnode * oplist = tptr; tnode * lptr; if (curropcalldepth++ > MAXOPCODEDEPTH) { printf("Error: Recursive opcalls involving opcode %s.\n\n", tptr->val); showerrorplace(tptr->optr->down->linenum, tptr->optr->down->filename); } while (tptr != NULL) { tptr->optr->sptr = tptr->sptr = opcodelink(tptr); if ((tptr->sptr == NULL) && (!coreopcodename(tptr))) { printf("Error: opcode %s not defined.\n", tptr->val); showerrorplace(tptr->optr->down->linenum, tptr->optr->down->filename); } if (tptr->sptr == NULL) { tptr->optr->sptr = coreopcodeadd(tptr, &(tptr->sptr)); coreopcodevarargs(tptr); hascoreopcode(tptr,1); } if (tptr->sptr == NULL) internalerror("oclone.c","installopnames"); /* updates tptr->ibus to point to cloned declaration */ if ((tptr->ttype == S_OPARRAYCALL)) { lptr = oplist; while ((lptr != NULL) && (lptr->ttype == S_OPARRAYDECL) && (strcmp(lptr->val,tptr->val) != 0)) lptr = lptr->next; if ((lptr == NULL) || (lptr->opwidth == 0)) { printf("Error: Undeclared oparray call %s.\n\n", tptr->val); showerrorplace(tptr->optr->down->linenum, tptr->optr->down->filename); } tptr->ibus = lptr; } tptr = tptr->next; } curropcalldepth--; }
static void sect_GrowCurrent(int32_t count) { assert(g_pConfiguration->eMinimumWordSize <= count); if(count + pCurrentSection->UsedSpace > pCurrentSection->AllocatedSpace) { int32_t allocate; allocate = (count + pCurrentSection->UsedSpace + CHUNKSIZE - 1) & -CHUNKSIZE; if((pCurrentSection->pData = mem_Realloc(pCurrentSection->pData,allocate)) != NULL) { pCurrentSection->AllocatedSpace = allocate; } else { internalerror("Out of memory!"); } } }
size_t lex_SkipBytes(size_t count) { size_t linesSkipped = 0; if (g_currentBuffer) { for (size_t i = 0; i < count; ++i) { char ch = lex_GetChar(); if (ch == 0) { break; } else if (ch == '\n') { linesSkipped += 1; } } } else { internalerror("g_pCurrentBuffer not initialized"); } return linesSkipped; }
bool lex_GetNextToken(void) { switch (g_currentBuffer->state) { case LEX_STATE_NORMAL: { return stateNormal(); } case LEX_STATE_MACRO_ARGUMENT0: { g_currentBuffer->state = LEX_STATE_MACRO_ARGUMENT; if (stateMacroArgument0()) return true; // fall through } case LEX_STATE_MACRO_ARGUMENT: { return stateMacroArguments(); } } internalerror("Abnormal error encountered"); return 0; }
int GL_SetLinestyle(int linestyleid) { /* special case get it when GL_Text restores a -1 linestyle */ if (linestyleid == -1) { currentgraph->linestyle = -1; return 0; } if (linestyleid < 0 || linestyleid > dispdev->numlinestyles) { internalerror("bad linestyleid"); return 0; } if (currentgraph->linestyle != linestyleid) { fprintf(plotfile, "LT %s ;", linestyle[linestyleid]); currentgraph->linestyle = linestyleid; } return 0; }
int X11_Input(REQUEST *request, RESPONSE *response) { XEvent ev; int nfds; fd_set rfds; switch (request->option) { case char_option: nfds = ConnectionNumber(display) > fileno(request->fp) ? ConnectionNumber(display) : fileno(request->fp); for (;;) { /* first read off the queue before doing the select */ while (XtPending()) { XtNextEvent(&ev); XtDispatchEvent(&ev); } /* block on ConnectionNumber and request->fp */ /* PN: added fd_set * casting */ FD_ZERO(&rfds); FD_SET(fileno(request->fp), &rfds); FD_SET(ConnectionNumber(display), &rfds); select (nfds + 1, &rfds, NULL, NULL, NULL); /* handle X events first */ if (FD_ISSET (ConnectionNumber(display), &rfds)) /* handle ALL X events */ while (XtPending()) { XtNextEvent(&ev); XtDispatchEvent(&ev); } if (FD_ISSET (fileno(request->fp), &rfds)) goto out; } break; case click_option: /* let's fake this */ response->reply.graph = lasthardcopy; break; case button_option: /* sit and handle events until get a button selection */ internalerror("button_option not implemented"); response->option = error_option; return 1; break; case checkup_option: /* first read off the queue before doing the select */ while (XtPending()) { XtNextEvent(&ev); XtDispatchEvent(&ev); } break; default: internalerror("unrecognized input type"); response->option = error_option; return 1; break; } out: if (response) response->option = request->option; return 0; }
int X11_DefineColor(int colorid, double red, double green, double blue) { internalerror("X11_DefineColor not implemented."); return 0; }
/* NewViewport is responsible for filling in graph->viewport */ int X11_NewViewport(GRAPH *graph) { char fontname[513]; /* who knows . . . */ char *p, *q; Cursor cursor; XSetWindowAttributes w_attrs; XGCValues gcvalues; static Arg formargs[ ] = { { XtNleft, (XtArgVal) XtChainLeft }, { XtNresizable, (XtArgVal) TRUE } }; static Arg bboxargs[ ] = { { XtNfromHoriz, (XtArgVal) NULL }, { XtNbottom, (XtArgVal) XtChainTop }, { XtNtop, (XtArgVal) XtChainTop }, { XtNleft, (XtArgVal) XtChainRight }, { XtNright, (XtArgVal) XtChainRight } }; static Arg buttonargs[ ] = { { XtNlabel, (XtArgVal) NULL }, { XtNfromVert, (XtArgVal) NULL }, { XtNbottom, (XtArgVal) XtChainTop }, { XtNtop, (XtArgVal) XtChainTop }, { XtNleft, (XtArgVal) XtRubber }, { XtNright, (XtArgVal) XtRubber }, { XtNresizable, (XtArgVal) TRUE } }; static Arg viewargs[] = { { XtNresizable, (XtArgVal) TRUE }, { XtNwidth, (XtArgVal) 300 }, { XtNheight, (XtArgVal) 300 }, { XtNright, (XtArgVal) XtChainRight } }; int trys; graph->devdep = TMALLOC(X11devdep, 1); /* set up new shell */ DEVDEP(graph).shell = XtCreateApplicationShell ("shell", topLevelShellWidgetClass, NULL, 0); XtVaSetValues(DEVDEP(graph).shell, XtNtitle, graph->plotname, NULL); /* set up form widget */ DEVDEP(graph).form = XtCreateManagedWidget ("form", formWidgetClass, DEVDEP(graph).shell, formargs, XtNumber(formargs)); /* set up viewport */ DEVDEP(graph).view = XtCreateManagedWidget ("viewport", widgetClass, DEVDEP(graph).form, viewargs, XtNumber(viewargs)); XtAddEventHandler(DEVDEP(graph).view, ButtonPressMask, FALSE, handlebuttonev, graph); XtAddEventHandler(DEVDEP(graph).view, KeyPressMask, FALSE, handlekeypressed, graph); XtAddEventHandler(DEVDEP(graph).view, StructureNotifyMask, FALSE, resize, graph); XtAddEventHandler(DEVDEP(graph).view, ExposureMask, FALSE, redraw, graph); /* set up button box */ XtSetArg(bboxargs[1], XtNfromHoriz, DEVDEP(graph).view); DEVDEP(graph).buttonbox = XtCreateManagedWidget ("buttonbox", boxWidgetClass, DEVDEP(graph).form, bboxargs, XtNumber(bboxargs)); /* set up buttons */ XtSetArg(buttonargs[0], XtNlabel, "quit"); XtSetArg(bboxargs[1], XtNfromVert, NULL); DEVDEP(graph).buttons[0] = XtCreateManagedWidget ("quit", commandWidgetClass, DEVDEP(graph).buttonbox, buttonargs, 1); XtAddCallback(DEVDEP(graph).buttons[0], XtNcallback, killwin, graph); XtSetArg(buttonargs[0], XtNlabel, "hardcopy"); XtSetArg(bboxargs[1], XtNfromVert, DEVDEP(graph).buttons[0]); DEVDEP(graph).buttons[1] = XtCreateManagedWidget ("hardcopy", commandWidgetClass, DEVDEP(graph).buttonbox, buttonargs, 1); XtAddCallback(DEVDEP(graph).buttons[1], XtNcallback, hardcopy, graph); /* set up fonts */ if (!cp_getvar("font", CP_STRING, fontname)) (void) strcpy(fontname, DEF_FONT); for (p = fontname; *p && *p <= ' '; p++) ; if (p != fontname) { for (q = fontname; *p; *q++ = *p++) ; *q = 0; } trys = 1; while (!(DEVDEP(graph).font = XLoadQueryFont(display, fontname))) { sprintf(ErrorMessage, "can't open font %s", fontname); strcpy(fontname, "fixed"); if (trys > 1) { internalerror(ErrorMessage); RECOVERNEWVIEWPORT(); return (1); } trys += 1; } graph->fontwidth = DEVDEP(graph).font->max_bounds.rbearing - DEVDEP(graph).font->min_bounds.lbearing + 1; graph->fontheight = DEVDEP(graph).font->max_bounds.ascent + DEVDEP(graph).font->max_bounds.descent + 1; XtRealizeWidget(DEVDEP(graph).shell); DEVDEP(graph).window = XtWindow(DEVDEP(graph).view); DEVDEP(graph).isopen = 0; w_attrs.bit_gravity = ForgetGravity; XChangeWindowAttributes(display, DEVDEP(graph).window, CWBitGravity, &w_attrs); /* have to note font and set mask GCFont in XCreateGC, p.w.h. */ gcvalues.font = DEVDEP(graph).font->fid; gcvalues.line_width = MW_LINEWIDTH; gcvalues.cap_style = CapNotLast; gcvalues.function = GXcopy; DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window, GCFont | GCLineWidth | GCCapStyle | GCFunction, &gcvalues); /* should absolute.positions really be shell.pos? */ graph->absolute.xpos = DEVDEP(graph).view->core.x; graph->absolute.ypos = DEVDEP(graph).view->core.y; graph->absolute.width = DEVDEP(graph).view->core.width; graph->absolute.height = DEVDEP(graph).view->core.height; initlinestyles(); initcolors(graph); /* set up cursor */ cursor = XCreateFontCursor(display, XC_left_ptr); XDefineCursor(display, DEVDEP(graph).window, cursor); /* WM_DELETE_WINDOW protocol */ atom_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False); atom_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False); XtAddEventHandler(DEVDEP(graph).shell, NoEventMask, True, handle_wm_messages, graph); XSetWMProtocols(display, XtWindow(DEVDEP(graph).shell), &atom_wm_delete_window, 1); return (0); }
int X11_Init(void) { char buf[512]; char *displayname; XGCValues gcvalues; /* grrr, Xtk forced contortions */ char *argv[2]; int argc = 2; if (cp_getvar("display", CP_STRING, buf)) { displayname = buf; } else if (!(displayname = getenv("DISPLAY"))) { internalerror("Can't open X display."); return (1); } # ifdef DEBUG _Xdebug = 1; # endif argv[0] = "ngspice"; argv[1] = displayname; /* argv[2] = "-geometry"; argv[3] = "=1x1+2+2"; */ /* initialize X toolkit */ toplevel = XtInitialize("ngspice", "Nutmeg", NULL, 0, &argc, argv); display = XtDisplay(toplevel); X11_Open = 1; /* "invert" works better than "xor" for B&W */ /* xor gc should be a function of the pixels that are written on */ /* gcvalues.function = GXxor; */ /* this patch makes lines visible on true color displays Guenther Roehrich 22-Jan-99 */ gcvalues.function = GXinvert; gcvalues.line_width = 1; gcvalues.foreground = 1; gcvalues.background = 0; xorgc = XCreateGC(display, DefaultRootWindow(display), GCLineWidth | GCFunction | GCForeground | GCBackground, &gcvalues); /* set correct information */ dispdev->numlinestyles = NUMLINESTYLES; dispdev->numcolors = NUMCOLORS; dispdev->width = DisplayWidth(display, DefaultScreen(display)); dispdev->height = DisplayHeight(display, DefaultScreen(display)); /* we don't want non-fatal X errors to call exit */ XSetErrorHandler(errorhandler); numdispplanes = DisplayPlanes(display, DefaultScreen(display)); return (0); }
int X11_DefineLinestyle(int linestyleid, int mask) { internalerror("X11_DefineLinestyle not implemented."); return 0; }
int DestroyGraph(int id) { LISTGRAPH *list, *lastlist; struct _keyed *k, *nextk; struct dveclist *d, *nextd; struct dbcomm *db; list = GBucket[id % NUMGBUCKETS].list; lastlist = NULL; while (list) { if (list->graph.graphid == id) { /* found it */ /* Fix the iplot/trace dbs list */ for (db = dbs; db && db->db_graphid != id; db = db->db_next) ; if (db && (db->db_type == DB_IPLOT || db->db_type == DB_IPLOTALL)) { db->db_type = DB_DEADIPLOT; /* Delete this later */ return (0); } /* adjust bucket pointers */ if (lastlist) lastlist->next = list->next; else GBucket[id % NUMGBUCKETS].list = list->next; /* run through and de-allocate dynamically allocated keyed list */ k = list->graph.keyed; while (k) { nextk = k->next; tfree(k->text); tfree(k); k = nextk; } /* de-allocate dveclist */ d = list->graph.plotdata; while (d) { nextd = d->next; dvec_free(d->vector); tfree(d); d = nextd; } tfree(list->graph.commandline); tfree(list->graph.plotname); /* If device dependent space allocated, free it. */ if (list->graph.devdep) tfree(list->graph.devdep); tfree(list); return (1); } lastlist = list; list = list->next; } internalerror("tried to destroy non-existent graph"); return (0); }
int gr_init(double *xlims, double *ylims, /* The size of the screen. */ char *xname, char *plotname, /* What to label things. */ char *hcopy, /* The raster file. */ int nplots, /* How many plots there will be. */ double xdelta, double ydelta, /* Line increments for the scale. */ GRIDTYPE gridtype, /* The grid type */ PLOTTYPE plottype, /* and the plot type. */ char *xlabel, char *ylabel, /* Labels for axes. */ int xtype, int ytype, /* The types of the data graphed. */ char *pname, char *commandline) /* For xi_zoomdata() */ { GRAPH *graph; wordlist *wl; char *comb_title; NG_IGNORE(nplots); if ((graph = NewGraph()) == NULL) return (FALSE); /* The global currentgraph will always be the current graph. */ SetGraphContext(graph->graphid); graph->onevalue = (xname ? FALSE : TRUE); /* communicate filename to plot 5 driver */ if (hcopy) graph->devdep = hcopy; cur.plotno = 0; /* note: should do only once, maybe in gr_init_once */ if (!cp_getvar("pointchars", CP_STRING, pointchars, sizeof(pointchars))) (void) strcpy(pointchars, DEFPOINTCHARS); if (!cp_getvar("ticmarks", CP_NUM, &graph->ticmarks, 0)) { if (cp_getvar("ticmarks", CP_BOOL, NULL, 0)) graph->ticmarks = 10; else graph->ticmarks = 0; } if (cp_getvar("ticlist", CP_LIST, ticlist, 0)) { wl = vareval("ticlist"); ticlist = wl_flatten(wl); graph->ticdata = readtics(ticlist); } else { graph->ticdata = NULL; } if (!xlims || !ylims) { internalerror("gr_init: no range specified"); return (FALSE); } /* save upper and lower limits */ graph->data.xmin = xlims[0]; graph->data.xmax = xlims[1]; graph->data.ymin = ylims[0]; graph->data.ymax = ylims[1]; /* get title into plot window */ if (!pname) pname = "(unknown)"; if (!plotname) plotname = "(unknown)"; comb_title = tprintf("%s: %s", pname, plotname); graph->plotname = comb_title; /* note: have enum here or some better convention */ if (NewViewport(graph) == 1) { /* note: where is the error message generated? */ /* note: undo tmallocs */ fprintf(cp_err, "Can't open viewport for graphics.\n"); return (FALSE); } /* layout decisions */ /* note: have to do before gr_fixgrid and after NewViewport */ graph->viewportxoff = graph->fontwidth * 8; /* 8 lines on left */ graph->viewportyoff = graph->fontheight * 4; /* 4 on bottom */ DevClear(); graph->grid.gridtype = gridtype; graph->plottype = plottype; graph->grid.xdatatype = xtype; graph->grid.ydatatype = ytype; graph->grid.xdelta = xdelta; graph->grid.ydelta = ydelta; graph->grid.ysized = 0; graph->grid.xsized = 0; if (!graph->onevalue) { if (xlabel) graph->grid.xlabel = xlabel; else graph->grid.xlabel = xname; if (ylabel) graph->grid.ylabel = ylabel; } else { if (xlabel) graph->grid.xlabel = xlabel; else graph->grid.xlabel = "real"; if (ylabel) graph->grid.ylabel = ylabel; else graph->grid.ylabel = "imag"; } gr_resize_internal(graph); gr_redrawgrid(graph); /* Set up colors and line styles. */ if (dispdev->numlinestyles == 1) cur.linestyle = 0; /* Use the same one all the time. */ else cur.linestyle = 1; /* XXX Special exception for SMITH */ if (dispdev->numcolors > 2 && (graph->grid.gridtype == GRID_SMITH || graph->grid.gridtype == GRID_SMITHGRID)) { cur.color = 3; } else { cur.color = 1; } graph->commandline = copy(commandline); return (TRUE); }