From 02173373cbe2e1c4f0618b6c8d4f2a6a9d18abc4 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Thu, 2 Dec 2021 13:28:40 +0100 Subject: [PATCH] some little optimizations, redundant code removed, better formatting in globals.c --- src/actions.c | 8 +-- src/globals.c | 153 ++++++++++++++++++++++++++++-------------------- src/netlist.c | 4 +- src/save.c | 2 +- src/scheduler.c | 12 ++++ src/token.c | 17 +++--- src/xinit.c | 16 ++--- 7 files changed, 123 insertions(+), 89 deletions(-) diff --git a/src/actions.c b/src/actions.c index 6e26cede..c6abf662 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1130,7 +1130,7 @@ void go_back(int confirm) /* 20171006 add confirm */ if(from_embedded_sym) xctx->modified=save_modified; /* to force ask save embedded sym in parent schematic */ if(xctx->hilight_nets) { - if(prev_sch_type != CAD_SYMBOL_ATTRS) hilight_parent_pins(); + if(prev_sch_type != CAD_SYMBOL_ATTRS) hilight_parent_pins(); propagate_hilights(1, 0, XINSERT_NOREPLACE); } xctx->xorigin=xctx->zoom_array[xctx->currsch].x; @@ -1632,10 +1632,8 @@ void new_wire(int what, double mx_snap, double my_snap) * this clears both xctx->prep_hi_structs and xctx->prep_net_structs. */ if(!big) { bbox(START , 0.0 , 0.0 , 0.0 , 0.0); - if(s_pnetname || xctx->hilight_nets) { - int_hash_lookup(xctx->node_redraw_table, xctx->wire[xctx->wires-1].node, 0, XINSERT_NOREPLACE); - find_inst_to_be_redrawn(); - } + int_hash_lookup(xctx->node_redraw_table, xctx->wire[xctx->wires-1].node, 0, XINSERT_NOREPLACE); + find_inst_to_be_redrawn(1); bbox(SET , 0.0 , 0.0 , 0.0 , 0.0); } draw(); diff --git a/src/globals.c b/src/globals.c index 5d3a61c6..d5948b56 100644 --- a/src/globals.c +++ b/src/globals.c @@ -30,71 +30,94 @@ Display *display; Colormap colormap; unsigned char **pixdata; unsigned char pixdata_init[22][32]={ /* fill patterns... indexed by laynumb. */ -{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,/*0 */ - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, -{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,/*1 */ - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, -{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*2 */ -{/*3 */ - 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00 -}, -{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,/*4 */ - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, -{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,/*5 */ - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, -{/*6 */ - 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}, -{/*7 */ - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 -}, -{/*8 */ - 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}, -{/*9 */ - 0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x41, 0x10, 0x00, 0x00, - 0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x41, 0x10, 0x00, 0x00, - 0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00 -}, -{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,/*10 */ - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, -{/*11 */ - 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, - 0x44, 0x44, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00 -}, -{/*12 */ - 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, - 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, - 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08 -}, -{/*13 */ - 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88, 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88, - 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88, 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88 -}, -{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*14 */ -{/*15 */ - 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}, -{ 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,/*16 */ - 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}, -{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*17 */ -{0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,/*18 */ - 0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa}, -{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*19 */ -{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*20 */ -{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}/*21 */ + { /* 0 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }, + { /* 1 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }, + { /* 2 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { /* 3 */ + 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00 + }, + { /* 4 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }, + { /* 5 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }, + { /* 6 */ + 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { /* 7 */ + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 + }, + { /* 8 */ + 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { /* 9 */ + 0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x41, 0x10, 0x00, 0x00, 0x04, 0x41, 0x00, 0x00, + 0x10, 0x04, 0x00, 0x00, 0x41, 0x10, 0x00, 0x00, 0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00 + }, + { /* 10 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }, + { /* 11 */ + 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, + 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00 + }, + { /* 12 */ + 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, + 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08 + }, + { /*13 */ + 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88, 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88, + 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88, 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88 + }, + { /* 14 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { /* 15 */ + 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { /* 16 */ + 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { /* 17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { /* 18 */ + 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, + 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa + }, + { /* 19 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { /* 20 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { /* 21 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + } }; int screen_number; int screendepth; diff --git a/src/netlist.c b/src/netlist.c index 740c3bae..5c17f822 100644 --- a/src/netlist.c +++ b/src/netlist.c @@ -654,8 +654,8 @@ void prepare_netlist_structs(int for_netlist) * a second prepare_netlist_structs() is called to name unnamed nets, in this second call * print_erc must be set to 0 to avoid double erc printing */ - print_erc = xctx->netlist_count == 0 || startlevel < xctx->currsch; - if (for_netlist>0) { + print_erc = (xctx->netlist_count == 0 || startlevel < xctx->currsch) && for_netlist; + if (for_netlist) { my_snprintf(nn, S(nn), "-----------%s", xctx->sch[xctx->currsch]); statusmsg(nn,2); } diff --git a/src/save.c b/src/save.c index b3199a99..476f1bbd 100644 --- a/src/save.c +++ b/src/save.c @@ -1469,7 +1469,7 @@ static void align_sch_pins_with_sym(const char *name, int pos) if ((ptr = strrchr(name, '.')) && !strcmp(ptr, ".sch")) { my_strncpy(symname, add_ext(name, ".sym"), S(symname)); - for(i = 0; i < HASHSIZE; i++) pintable[i] = NULL; + memset(pintable, 0, HASHSIZE * sizeof(struct int_hashentry *)); /* hash all symbol pins with their position into pintable hash*/ get_sym_type(symname, &symtype, pintable, NULL, &sym_n_pins); if(symtype[0]) { /* found a .sym for current .sch LCC instance */ diff --git a/src/scheduler.c b/src/scheduler.c index 9a02f18f..0450da8f 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -140,6 +140,8 @@ void xschem_cmd_help(int argc, const char **argv) " topwindow\n", " version\n", " wirelayer\n", + " xorigin\n", + " yorigin\n", "get_tok\n", "get_tok_size\n", "getprop\n", @@ -901,6 +903,16 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg my_snprintf(s, S(s), "%d",WIRELAYER); Tcl_SetResult(interp, s,TCL_VOLATILE); } + else if(!strcmp(argv[2],"xorigin")) { + char s[128]; + my_snprintf(s, S(s), "%.16g", xctx->xorigin); + Tcl_SetResult(interp, s,TCL_VOLATILE); + } + else if(!strcmp(argv[2],"yorigin")) { + char s[128]; + my_snprintf(s, S(s), "%.16g", xctx->yorigin); + Tcl_SetResult(interp, s,TCL_VOLATILE); + } else { fprintf(errfp, "xschem get %s: invalid command.\n", argv[2]); } diff --git a/src/token.c b/src/token.c index 23985c95..ab6e3588 100644 --- a/src/token.c +++ b/src/token.c @@ -2875,19 +2875,20 @@ const char *translate(int inst, const char* s) } if(n>=0 && pin_attr[0] && n < (xctx->inst[inst].ptr+ xctx->sym)->rects[PINLAYER]) { char *pin_attr_value = NULL; - + int is_net_name = !strcmp(pin_attr, "net_name"); /* get pin_attr value from instance: "pinnumber(ENABLE)=5" --> return 5, attr "pinnumber" of pin "ENABLE" * "pinnumber(3)=6 --> return 6, attr "pinnumber" of 4th pin */ - if(!pin_attr_value) pin_attr_value = get_pin_attr_from_inst(inst, n, pin_attr); - /* get pin_attr from instance pin attribute string */ - if(!pin_attr_value) { - my_strdup(499, &pin_attr_value, - get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->rect[PINLAYER][n].prop_ptr, pin_attr, 0)); + if(!is_net_name) { + pin_attr_value = get_pin_attr_from_inst(inst, n, pin_attr); + /* get pin_attr from instance pin attribute string */ + if(!pin_attr_value) { + my_strdup(499, &pin_attr_value, + get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->rect[PINLAYER][n].prop_ptr, pin_attr, 0)); + } } - /* @#n:net_name attribute (n = pin number or name) will translate to net name attached to pin * if 'net_name=true' attribute is set in instance or symbol */ - if( !pin_attr_value && !strcmp(pin_attr, "net_name")) { + if(!pin_attr_value && is_net_name) { char *instprop = xctx->inst[inst].prop_ptr; char *symprop = (xctx->inst[inst].ptr + xctx->sym)->prop_ptr; if(s_pnetname && (!strcmp(get_tok_value(instprop, "net_name", 0), "true") || diff --git a/src/xinit.c b/src/xinit.c index 7b718882..a40faccc 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -76,7 +76,7 @@ static int client_msg(Display *disp, Window win, char *msg, /* {{{ */ int window_state (Display *disp, Window win, char *arg) {/*{{{*/ - static char *arg_copy=NULL; + char arg_copy[256]; /* overflow safe */ unsigned long action; int i; Atom prop1 = 0; @@ -85,18 +85,17 @@ int window_state (Display *disp, Window win, char *arg) {/*{{{*/ const char *argerr = "expects a list of comma separated parameters: " "\"(remove|add|toggle),[,]\"\n"; + char tmp_prop1[256], tmp1[256]; /* overflow safe */ + char tmp_prop2[256], tmp2[256]; /* overflow safe */ - my_strdup(604, &arg_copy, arg); - dbg(1,"window_state() , win=0x%x arg_copy=%s\n", - (int)win,arg_copy); - if (!arg_copy || strlen(arg_copy) == 0) { + if (!arg || strlen(arg) == 0) { fputs(argerr, errfp); return EXIT_FAILURE; } - + dbg(1,"window_state() , win=0x%x arg=%s\n", (int)win, arg); + my_strncpy(arg_copy, arg, S(arg_copy)); if ((p1 = strchr(arg_copy, ','))) { - static char tmp_prop1[1024], tmp1[1024]; /* overflow safe 20161122 */ *p1 = '\0'; @@ -118,7 +117,6 @@ int window_state (Display *disp, Window win, char *arg) {/*{{{*/ /* the second property */ if ((p2 = strchr(p1, ','))) { - static char tmp_prop2[1024], tmp2[1024]; /* overflow safe */ *p2 = '\0'; p2++; if (strlen(p2) == 0) { @@ -126,6 +124,7 @@ int window_state (Display *disp, Window win, char *arg) {/*{{{*/ return EXIT_FAILURE; } for( i = 0; p2[i]; i++) tmp2[i] = toupper( p2[i] ); + tmp2[i] = '\0'; my_snprintf(tmp_prop2, S(tmp_prop2), "_NET_WM_STATE_%s", tmp2); prop2 = XInternAtom(disp, tmp_prop2, False); } @@ -136,6 +135,7 @@ int window_state (Display *disp, Window win, char *arg) {/*{{{*/ return EXIT_FAILURE; } for( i = 0; p1[i]; i++) tmp1[i] = toupper( p1[i] ); + tmp1[i] = '\0'; my_snprintf(tmp_prop1, S(tmp_prop1), "_NET_WM_STATE_%s", tmp1); prop1 = XInternAtom(disp, tmp_prop1, False);