diff --git a/src/draw.c b/src/draw.c index 5c3096b6..6f5656c0 100644 --- a/src/draw.c +++ b/src/draw.c @@ -56,13 +56,13 @@ void print_image() if(!has_x) return ; if(!lastdir[0]) my_strncpy(lastdir, pwd_dir, S(lastdir)); - if(!plotfile[0]) { + if(!xctx->plotfile[0]) { Tcl_VarEval(interp, "tk_getSaveFile -title {Select destination file} -initialfile ", get_cell(xctx->sch[xctx->currsch], 0) , ".png -initialdir ", lastdir, NULL); r = tclresult(); if(r[0]) { - my_strncpy(plotfile, r, S(plotfile)); - Tcl_VarEval(interp, "file dirname ", plotfile, NULL); + my_strncpy(xctx->plotfile, r, S(xctx->plotfile)); + Tcl_VarEval(interp, "file dirname ", xctx->plotfile, NULL); my_strncpy(lastdir, tclresult(), S(lastdir)); } else return; @@ -81,19 +81,19 @@ void print_image() #ifdef __unix__ XpmWriteFileFromPixmap(display, "plot.xpm", xctx->save_pixmap,0, NULL ); /* .gz ???? */ dbg(1, "print_image(): Window image saved\n"); - if(plotfile[0]) { - my_snprintf(cmd, S(cmd), "convert_to_png plot.xpm {%s}", plotfile); + if(xctx->plotfile[0]) { + my_snprintf(cmd, S(cmd), "convert_to_png plot.xpm {%s}", xctx->plotfile); tcleval(cmd); } else tcleval( "convert_to_png plot.xpm plot.png"); #else char *psfile=NULL; create_ps(&psfile, 7); - if(plotfile[0]) { - my_snprintf(cmd, S(cmd), "convert_to_png {%s} {%s}", psfile, plotfile); + if(xctx->plotfile[0]) { + my_snprintf(cmd, S(cmd), "convert_to_png {%s} {%s}", psfile, xctx->plotfile); tcleval(cmd); } else tcleval( "convert_to_png {%s} plot.png", psfile); #endif - my_strncpy(plotfile,"", S(plotfile)); + my_strncpy(xctx->plotfile,"", S(xctx->plotfile)); draw_grid=save_draw_grid; draw_pixmap=1; } diff --git a/src/globals.c b/src/globals.c index 05d92b97..06b5d2a2 100644 --- a/src/globals.c +++ b/src/globals.c @@ -177,7 +177,6 @@ const char fopen_read_mode[] = "rb"; const char fopen_read_mode[] = "r"; #endif int load_initfile=1; -char plotfile[PATH_MAX] = {'\0'}; char rcfile[PATH_MAX] = {'\0'}; char *tcl_command = NULL; char tcl_script[PATH_MAX] = {'\0'}; diff --git a/src/options.c b/src/options.c index e34dc441..74521281 100644 --- a/src/options.c +++ b/src/options.c @@ -59,7 +59,7 @@ void check_opt(char *opt, char *optval, int type) } else if( (type == LONG && !strcmp("plotfile", opt)) ) { dbg(1, "process_options(): user plotfile specified: %s\n", optval ? optval : "NULL"); - if(optval) my_strncpy(plotfile, optval, S(plotfile)); + if(optval) my_strncpy(xctx->plotfile, optval, S(xctx->plotfile)); } else if( (type == LONG && !strcmp("rcfile", opt)) ) { dbg(1, "process_options(): user rcfile specified: %s\n", optval ? optval : "NULL"); diff --git a/src/psprint.c b/src/psprint.c index 83cea831..20f5f484 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -861,7 +861,7 @@ void create_ps(char **psfile, int what) } } - dbg(1, "ps_draw(): INT_WIDTH(lw)=%d plotfile=%s\n",INT_WIDTH(xctx->lw), plotfile); + dbg(1, "ps_draw(): INT_WIDTH(lw)=%d plotfile=%s\n",INT_WIDTH(xctx->lw), xctx->plotfile); fprintf(fd, "showpage\n\n"); } if(what & 4) { /* trailer */ @@ -883,13 +883,13 @@ int ps_draw(int what) if(what & 1) { /* prolog */ if(!lastdir[0]) my_strncpy(lastdir, pwd_dir, S(lastdir)); - if(!plotfile[0]) { + if(!xctx->plotfile[0]) { Tcl_VarEval(interp, "tk_getSaveFile -title {Select destination file} -initialfile ", get_cell(xctx->sch[xctx->currsch], 0) , ".pdf -initialdir ", lastdir, NULL); r = tclresult(); if(r[0]) { - my_strncpy(plotfile, r, S(plotfile)); - Tcl_VarEval(interp, "file dirname ", plotfile, NULL); + my_strncpy(xctx->plotfile, r, S(xctx->plotfile)); + Tcl_VarEval(interp, "file dirname ", xctx->plotfile, NULL); my_strncpy(lastdir, tclresult(), S(lastdir)); } else return 0; @@ -897,12 +897,12 @@ int ps_draw(int what) } create_ps(&psfile, what); if(what & 4) { /* trailer */ - if(plotfile[0]) { - my_snprintf(tmp, S(tmp), "convert_to_pdf {%s} {%s}", psfile, plotfile); + if(xctx->plotfile[0]) { + my_snprintf(tmp, S(tmp), "convert_to_pdf {%s} {%s}", psfile, xctx->plotfile); } else { my_snprintf(tmp, S(tmp), "convert_to_pdf {%s} plot.pdf", psfile); } - my_strncpy(plotfile,"", S(plotfile)); + my_strncpy(xctx->plotfile,"", S(xctx->plotfile)); tcleval( tmp); Tcl_SetResult(interp,"",TCL_STATIC); } diff --git a/src/scheduler.c b/src/scheduler.c index f2753a35..2bc99fa7 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1716,7 +1716,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } if(argc >= 4) { Tcl_VarEval(interp, "file normalize \"", argv[3], "\"", NULL); - my_strncpy(plotfile, Tcl_GetStringResult(interp), S(plotfile)); + my_strncpy(xctx->plotfile, Tcl_GetStringResult(interp), S(xctx->plotfile)); } if(!strcmp(argv[2],"pdf") || !strcmp(argv[2],"ps")) { diff --git a/src/svgdraw.c b/src/svgdraw.c index 9367927d..00a093b0 100644 --- a/src/svgdraw.c +++ b/src/svgdraw.c @@ -562,13 +562,13 @@ void svg_draw(void) struct hilight_hashentry *entry; if(!lastdir[0]) my_strncpy(lastdir, pwd_dir, S(lastdir)); - if(!plotfile[0]) { + if(!xctx->plotfile[0]) { Tcl_VarEval(interp, "tk_getSaveFile -title {Select destination file} -initialfile ", get_cell(xctx->sch[xctx->currsch], 0) , ".svg -initialdir ", lastdir, NULL); r = tclresult(); if(r[0]) { - my_strncpy(plotfile, r, S(plotfile)); - Tcl_VarEval(interp, "file dirname ", plotfile, NULL); + my_strncpy(xctx->plotfile, r, S(xctx->plotfile)); + Tcl_VarEval(interp, "file dirname ", xctx->plotfile, NULL); my_strncpy(lastdir, tclresult(), S(lastdir)); } else return; @@ -585,10 +585,10 @@ void svg_draw(void) dy=xctx->xschem_h; dbg(1, "svg_draw(): dx=%g dy=%g\n", dx, dy); - if(plotfile[0]) { - fd=fopen(plotfile, "w"); + if(xctx->plotfile[0]) { + fd=fopen(xctx->plotfile, "w"); if(!fd) { - dbg(0, "can not open file: %s\n", plotfile); + dbg(0, "can not open file: %s\n", xctx->plotfile); return; } } else { @@ -598,7 +598,7 @@ void svg_draw(void) return; } } - my_strncpy(plotfile,"", S(plotfile)); + my_strncpy(xctx->plotfile,"", S(xctx->plotfile)); unused_layer = my_calloc(873, cadlayers, sizeof(int)); #if 0 diff --git a/src/xinit.c b/src/xinit.c index 232c63bd..724b061a 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -416,6 +416,7 @@ void alloc_xschem_data() xctx->get_tok_size = 0; xctx->get_tok_value_size = 0; xctx->netlist_name[0] = '\0'; + xctx->plotfile[0] = '\0'; xctx->netlist_unconn_cnt = 0; /* unique count of unconnected pins while netlisting */ xctx->current_dirname[0] = '\0'; for(i = 0; i < NBOXES; i++) { diff --git a/src/xschem.h b/src/xschem.h index 2b06e6fc..06aac1a8 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -624,6 +624,7 @@ typedef struct { int nl_sel, nl_sem; XSegment *biggridpoint; XPoint *gridpoint; + char plotfile[PATH_MAX]; } Xschem_ctx; struct Lcc { /* used for symbols containing schematics as instances (LCC, Local Custom Cell) */ @@ -723,7 +724,6 @@ extern int load_initfile; extern char rcfile[PATH_MAX]; extern char *tcl_command; extern char tcl_script[PATH_MAX]; -extern char plotfile[PATH_MAX]; extern int persistent_command; extern int autotrim_wires; extern int dis_uniq_names;