Merge branch 'StefanSchippers:master' into master

This commit is contained in:
Rafmag Cabrera 2023-01-20 18:29:35 +00:00 committed by GitHub
commit 4814d10a67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 97 additions and 37 deletions

View File

@ -223,6 +223,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\src\actions.c" />
<ClCompile Include="..\src\cairo_jpg.c" />
<ClCompile Include="..\src\callback.c" />
<ClCompile Include="..\src\check.c" />
<ClCompile Include="..\src\clip.c" />
@ -257,6 +258,7 @@
<ClCompile Include="parselabel.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\cairo_jpg.h" />
<ClInclude Include="..\src\xschem.h" />
<ClInclude Include="config.h" />
<ClInclude Include="expandlabel.h" />

View File

@ -273,16 +273,16 @@ void new_xschem_process(const char *cell, int symbol)
fprintf(errfp, "new_xschem_process(): executable not found\n");
return;
}
fflush(NULL); /* flush all stdio streams before process forking */
/* double fork method to avoid zombies 20180925*/
if ( (pid1 = fork()) ) {
if ( (pid1 = fork()) > 0 ) {
/* parent process */
waitpid(pid1, &status, 0);
} else if (!pid1) {
} else if (pid1 == 0) {
/* child process */
if ( (pid2 = fork()) ) {
exit(0); /* --> child of child will be reparented to init */
} else if (!pid2) {
if ( (pid2 = fork()) > 0 ) {
_exit(0); /* --> child of child will be reparented to init */
} else if (pid2 == 0) {
/* child of child */
if(!cell || !cell[0]) {
if(!symbol)
@ -303,7 +303,7 @@ void new_xschem_process(const char *cell, int symbol)
} else {
/* error */
fprintf(errfp, "new_xschem_process(): fork error 1\n");
tcleval("exit");
_exit(1);
}
} else {
/* error */

View File

@ -3299,8 +3299,8 @@ void svg_embedded_graph(FILE *fd, xRect *r, double rx1, double ry1, double rx2,
rwi = (int) (rw * scale + 1.0);
rhi = (int) (rh * scale + 1.0);
save_restore_zoom(1);
set_viewport_size(rwi, rhi, 1.0);
zoom_box(rx1, ry1, rx2, ry2, 1.0);
set_viewport_size(rwi, rhi, xctx->lw);
zoom_box(rx1 - xctx->lw, ry1 - xctx->lw, rx2 + xctx->lw, ry2 + xctx->lw, 1.0);
resetwin(1, 1, 1, rwi, rhi);
save_draw_grid = tclgetboolvar("draw_grid");
tclsetvar("draw_grid", "0");

View File

@ -1501,6 +1501,13 @@ void edit_property(int x)
return;
} /* if((xctx->lastsel==0 ) */
/* set 'preserve unchanged properties if multiple selection */
if(xctx->lastsel > 1) {
tclsetvar("preserve_unchanged_attrs", "1");
} else {
tclsetvar("preserve_unchanged_attrs", "0");
}
switch(xctx->sel_array[0].type)
{
case ELEMENT:

View File

@ -108,6 +108,7 @@ static void check_opt(char *opt, char *optval, int type)
} else if( (type == SHORT && *opt == 'l') || (type == LONG && !strcmp("log", opt)) ) {
if(optval) {
errfp = fopen(optval, "w");
setvbuf(errfp, NULL, _IOLBF, 0); /* line (_IOLBF) or disable (_IONBF) buffering on error log */
if(!errfp) {
errfp=stderr;
dbg(0, "Problems opening log file: %s\n", optval);

View File

@ -142,22 +142,27 @@ void ps_drawPNG(xRect* r, double x1, double y1, double x2, double y2, int rot, i
size_t fileSize = 0;
int quality=100;
const char *quality_attr;
size_t image_data_len;
quality_attr = get_tok_value(r->prop_ptr, "jpeg_quality", 0);
if(quality_attr[0]) quality = atoi(quality_attr);
else {
quality_attr = get_tok_value(r->prop_ptr, "jpg_quality", 0);
if(quality_attr[0]) quality = atoi(quality_attr);
}
my_strdup(59, &filter, get_tok_value(r->prop_ptr, "filter", 0));
my_strdup2(1183, &image_data64_ptr, get_tok_value(r->prop_ptr, "image_data", 0));
image_data_len = my_strdup2(1183, &image_data64_ptr, get_tok_value(r->prop_ptr, "image_data", 0));
if (filter) {
size_t filtersize = 0;
char* filterdata = NULL;
closure.buffer = NULL;
filterdata = (char*)base64_decode(image_data64_ptr, strlen(image_data64_ptr), &filtersize);
filterdata = (char*)base64_decode(image_data64_ptr, image_data_len, &filtersize);
filter_data(filterdata, filtersize, (char**)&closure.buffer, &data_size, filter);
my_free(1661, &filterdata);
}
else {
closure.buffer = base64_decode(image_data64_ptr, strlen(image_data64_ptr), &data_size);
closure.buffer = base64_decode(image_data64_ptr, image_data_len, &data_size);
}
my_free(1664, &filter);
my_free(1184, &image_data64_ptr);
@ -220,7 +225,6 @@ void ps_drawPNG(xRect* r, double x1, double y1, double x2, double y2, int rot, i
if(rot==2) fprintf(fd, "180 rotate\n");
if(rot==3) fprintf(fd, "270 rotate\n");
fprintf(fd, "%g %g scale\n", (X_TO_PS(x2) - X_TO_PS(x1))*0.97, (Y_TO_PS(y2) - Y_TO_PS(y1))*0.97);
fprintf(fd, "%g\n", (double)png_size_x);
fprintf(fd, "%g\n", (double)png_size_y);
fprintf(fd, "8\n");
@ -275,6 +279,11 @@ void ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, double ry2)
quality_attr = get_tok_value(r->prop_ptr, "jpeg_quality", 0);
if(quality_attr[0]) quality = atoi(quality_attr);
else {
quality_attr = get_tok_value(r->prop_ptr, "jpg_quality", 0);
if(quality_attr[0]) quality = atoi(quality_attr);
}
if(quality_attr[0]) quality = atoi(quality_attr);
if (!has_x) return;
rw = fabs(rx2 - rx1);
rh = fabs(ry2 - ry1);
@ -288,8 +297,8 @@ void ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, double ry2)
rwi = (int)(rw * scale + 1.0);
rhi = (int)(rh * scale + 1.0);
save_restore_zoom(1);
set_viewport_size(rwi, rhi, 1.0);
zoom_box(rx1-2, ry1-2, rx2+2, ry2+2, 1.0);
set_viewport_size(rwi, rhi, xctx->lw);
zoom_box(rx1 - xctx->lw, ry1 - xctx->lw, rx2 + xctx->lw, ry2 + xctx->lw, 1.0);
resetwin(1, 1, 1, rwi, rhi);
save_draw_grid = tclgetboolvar("draw_grid");
tclsetvar("draw_grid", "0");

View File

@ -64,7 +64,7 @@ int filter_data(const char *din, const size_t ilen,
{
int p1[2]; /* parent -> child, 0: read, 1: write */
int p2[2]; /* child -> parent, 0: read, 1: write */
int ret = 0;
int ret = 0, wstatus;
pid_t pid;
size_t bufsize = 32768, oalloc = 0, n = 0;
@ -77,6 +77,13 @@ int filter_data(const char *din, const size_t ilen,
dbg(1, "filter_data(): ilen=%ld, cmd=%s\n", ilen, cmd);
pipe(p1);
pipe(p2);
dbg(1, "p1[0] = %d\n", p1[0]);
dbg(1, "p1[1] = %d\n", p1[1]);
dbg(1, "p2[0] = %d\n", p2[0]);
dbg(1, "p2[1] = %d\n", p2[1]);
signal(SIGPIPE, SIG_IGN); /* so attempting write/read a broken pipe won't kill program */
/*
* p2
@ -85,26 +92,40 @@ int filter_data(const char *din, const size_t ilen,
* ------------------- p1[1] ---------> p1[0] -------------------
* p1
*/
fflush(NULL); /* flush all stdio streams before process forking */
if( (pid = fork()) == 0) {
#if 1
char **av;
int ac;
#endif
/* child */
close(p1[1]); /* only read from p1 */
close(p2[0]); /* only write to p2 */
close(0); /* dup2(p1[0],0); */ /* connect read side of read pipe to stdin */
dup(p1[0]);
close(p1[0]);
close(1); /* dup2(p2[1],1); */ /* connect write side of write pipe to stdout */
dup(p2[1]);
close(p2[1]);
#if 1
av = parse_cmd_string(cmd, &ac);
if(execvp(av[0], av) == -1) {
#endif
#if 0
if(execl("/bin/sh", "sh", "-c", cmd, (char *) NULL) == -1) {
#endif
#if 0
if(system(cmd) == -1) {
#endif
fprintf(stderr, "error: conversion failed\n");
close(p1[0]);
close(p2[1]);
ret = 1;
}
exit(ret);
_exit(ret); /* childs should always use _exit() to avoid
* flushing open stdio streams and other unwanted side effects */
}
/* parent */
close(p1[0]); /*only write to p1 */
@ -139,9 +160,13 @@ int filter_data(const char *din, const size_t ilen,
fprintf(stderr, "no data read\n");
ret = 1;
}
waitpid(pid, NULL, 0); /* write for child process to finish and unzombie it */
waitpid(pid, &wstatus, 0); /* write for child process to finish and unzombie it */
close(p2[0]);
signal(SIGPIPE, SIG_DFL); /* restore default SIGPIPE signal action */
if(WIFEXITED(wstatus)) dbg(1, "Child exited normally\n");
dbg(1, "Child exit status=%d\n", WEXITSTATUS(wstatus));
if(WIFSIGNALED(wstatus))dbg(1, "Child was terminated by signal\n");
return ret;
}
#else /* anyone wanting to write a similar function for windows Welcome! */
@ -523,6 +548,7 @@ void free_rawfile(int dr)
int i;
int deleted = 0;
dbg(1, "free_rawfile(): clearing data\n");
if(xctx->graph_names) {
deleted = 1;
for(i = 0 ; i < xctx->graph_nvars; i++) {
@ -2391,12 +2417,13 @@ void push_undo(void)
#elif HAS_PIPE==1
my_snprintf(diff_name, S(diff_name), "%s/undo%d", xctx->undo_dirname, xctx->cur_undo_ptr%MAX_UNDO);
pipe(pd);
fflush(NULL); /* flush all stdio streams before process forking */
if((pid = fork()) ==0) { /* child process */
close(pd[1]); /* close write side of pipe */
if(!(diff_fd=freopen(diff_name,"w", stdout))) /* redirect stdout to file diff_name */
{
dbg(1, "push_undo(): problems opening file %s \n",diff_name);
tcleval("exit");
_exit(1);
}
/* the following 2 statements are a replacement for dup2() which is not c89
@ -2411,7 +2438,7 @@ void push_undo(void)
execlp("gzip", "gzip", "--fast", "-c", NULL); /* replace current process with comand */
/* never gets here */
fprintf(errfp, "push_undo(): problems with execlp\n");
tcleval("exit");
_exit(1);
}
close(pd[0]); /* close read side of pipe */
fd=fdopen(pd[1],"w");
@ -2491,12 +2518,13 @@ void pop_undo(int redo, int set_modify_status)
#elif HAS_PIPE==1
my_snprintf(diff_name, S(diff_name), "%s/undo%d", xctx->undo_dirname, xctx->cur_undo_ptr%MAX_UNDO);
pipe(pd);
fflush(NULL); /* flush all stdio streams before process forking */
if((pid = fork())==0) { /* child process */
close(pd[0]); /* close read side of pipe */
if(!(diff_fd=freopen(diff_name,"r", stdin))) /* redirect stdin from file name */
{
dbg(1, "pop_undo(): problems opening file %s \n",diff_name);
tcleval("exit");
_exit(1);
}
/* connect write side of pipe to stdout */
#if HAS_DUP2
@ -2508,7 +2536,7 @@ void pop_undo(int redo, int set_modify_status)
execlp("gzip", "gzip", "-d", "-c", NULL); /* replace current process with command */
/* never gets here */
dbg(1, "pop_undo(): problems with execlp\n");
tcleval("exit");
_exit(1);
}
close(pd[1]); /* close write side of pipe */
fd=fdopen(pd[0],"r");

View File

@ -1077,7 +1077,6 @@ extern Xschem_ctx *xctx;
extern void draw_image(int dr, xRect *r, double *x1, double *y1, double *x2, double *y2, int rot, int flip);
extern int filter_data(const char *din, const size_t ilen,
char **dout, size_t *olen, const char *cmd);
extern cairo_status_t png_reader(void* in_closure, unsigned char* out_data, unsigned int length);
extern int embed_rawfile(const char *rawfile);
extern int read_rawfile_from_attr(const char *b64s, size_t length, const char *type);
extern int raw_read_from_attr(const char *type);
@ -1170,6 +1169,7 @@ extern void hash_wire(int what, int n, int incremental);
extern void hash_instances(void); /* 20171203 insert instance bbox in spatial hash table */
#if HAS_CAIRO==1
extern cairo_status_t png_reader(void* in_closure, unsigned char* out_data, unsigned int length);
extern int text_bbox_nocairo(const char * str,double xscale, double yscale,
short rot, short flip, int hcenter, int vcenter,
double x1,double y1, double *rx1, double *ry1,

File diff suppressed because one or more lines are too long

View File

@ -64,7 +64,8 @@ x2=0.001
divx=8
node="panel
led" unitx=m
color="7 4"}
color="7 4"
jpeg_quality=20}
B 2 1260 -390 1680 -220 {flags=graph
y1 = 0
y2 = 6.7
@ -77,7 +78,8 @@ divx=8
color="7 4 6"
node="i(vpanel)
i(vled)
\\"R.Avg. I(vpanel); i(vpanel) 20u ravg()\\""}
\\"R.Avg. I(vpanel); i(vpanel) 20u ravg()\\""
jpeg_quality=20}
B 2 1260 -750 1680 -560 {flags=graph
y1 = -8.9e-05
y2 = 100
@ -93,7 +95,8 @@ node="\\"Panel power; i(vpanel) v(panel) *\\"
\\"Led power; i(vled) v(led) *\\"
\\"Avg.Pan. Pwr; i(vpanel) v(panel) * 20u ravg()\\"
\\"SUN %; sun 100 *\\""
hilight_wave=-1}
hilight_wave=-1
jpeg_quality=20}
B 2 1260 -940 1680 -750 {flags=graph
y1 = 0
y2 = 1
@ -110,7 +113,8 @@ level"
hilight_wave=-1
digital=0
ypos1=0.00261891
ypos2=0.51596}
ypos2=0.51596
jpeg_quality=20}
B 2 1260 -1140 1680 -950 {flags=graph
y1 = 0
y2 = 1
@ -128,7 +132,8 @@ digital=0
ypos1=0.00261891
ypos2=0.51596
color=8
node="\\"CTRL1 Duty cycle; ctrl1 20u ravg()\\""}
node="\\"CTRL1 Duty cycle; ctrl1 20u ravg()\\""
jpeg_quality=20}
B 18 85 -840 340 -655 {}
A 5 340 -840 5.590169943749475 243.434948822922 360 {fill=true}
P 7 6 415 -655 360 -811.25 355 -825 342.5 -840 330 -845 85 -855 {}