some little optimizations, redundant code removed, better formatting in globals.c

This commit is contained in:
Stefan Frederik 2021-12-02 13:28:40 +01:00
parent cb8ffce9cf
commit 02173373cb
7 changed files with 123 additions and 89 deletions

View File

@ -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. */ * this clears both xctx->prep_hi_structs and xctx->prep_net_structs. */
if(!big) { if(!big) {
bbox(START , 0.0 , 0.0 , 0.0 , 0.0); 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);
int_hash_lookup(xctx->node_redraw_table, xctx->wire[xctx->wires-1].node, 0, XINSERT_NOREPLACE); find_inst_to_be_redrawn(1);
find_inst_to_be_redrawn();
}
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0); bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
} }
draw(); draw();

View File

@ -30,71 +30,94 @@ Display *display;
Colormap colormap; Colormap colormap;
unsigned char **pixdata; unsigned char **pixdata;
unsigned char pixdata_init[22][32]={ /* fill patterns... indexed by laynumb. */ 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 */ { /* 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,
{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}, },
{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 */ { /* 1 */
{/*3 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
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
0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00 },
}, { /* 2 */
{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,/*4 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
{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}, { /* 3 */
{/*6 */ 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 { /* 4 */
}, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
{/*7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, { /* 5 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 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
{/*8 */ },
0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, { /* 6 */
0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}, },
{/*9 */ { /* 7 */
0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x41, 0x10, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x41, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00 },
}, { /* 8 */
{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,/*10 */ 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
{/*11 */ },
0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, { /* 9 */
0x44, 0x44, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x41, 0x10, 0x00, 0x00, 0x04, 0x41, 0x00, 0x00,
0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00 0x10, 0x04, 0x00, 0x00, 0x41, 0x10, 0x00, 0x00, 0x04, 0x41, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00
}, },
{/*12 */ { /* 10 */
0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08 },
}, { /* 11 */
{/*13 */ 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00,
0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88, 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88, 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00
0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88, 0x11, 0x11, 0x22, 0x22, 0x44, 0x44, 0x88, 0x88 },
}, { /* 12 */
{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 */ 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08,
{/*15 */ 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08
0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, },
0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, { /*13 */
0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 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
{ 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, { /* 14 */
0x88, 0x88, 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, 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 */ { /* 15 */
0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa}, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 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},/*19 */ 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 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},/*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 */ { /* 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 screen_number;
int screendepth; int screendepth;

View File

@ -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 * 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 must be set to 0 to avoid double erc printing
*/ */
print_erc = xctx->netlist_count == 0 || startlevel < xctx->currsch; print_erc = (xctx->netlist_count == 0 || startlevel < xctx->currsch) && for_netlist;
if (for_netlist>0) { if (for_netlist) {
my_snprintf(nn, S(nn), "-----------%s", xctx->sch[xctx->currsch]); my_snprintf(nn, S(nn), "-----------%s", xctx->sch[xctx->currsch]);
statusmsg(nn,2); statusmsg(nn,2);
} }

View File

@ -1469,7 +1469,7 @@ static void align_sch_pins_with_sym(const char *name, int pos)
if ((ptr = strrchr(name, '.')) && !strcmp(ptr, ".sch")) { if ((ptr = strrchr(name, '.')) && !strcmp(ptr, ".sch")) {
my_strncpy(symname, add_ext(name, ".sym"), S(symname)); 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*/ /* hash all symbol pins with their position into pintable hash*/
get_sym_type(symname, &symtype, pintable, NULL, &sym_n_pins); get_sym_type(symname, &symtype, pintable, NULL, &sym_n_pins);
if(symtype[0]) { /* found a .sym for current .sch LCC instance */ if(symtype[0]) { /* found a .sym for current .sch LCC instance */

View File

@ -140,6 +140,8 @@ void xschem_cmd_help(int argc, const char **argv)
" topwindow\n", " topwindow\n",
" version\n", " version\n",
" wirelayer\n", " wirelayer\n",
" xorigin\n",
" yorigin\n",
"get_tok\n", "get_tok\n",
"get_tok_size\n", "get_tok_size\n",
"getprop\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); my_snprintf(s, S(s), "%d",WIRELAYER);
Tcl_SetResult(interp, s,TCL_VOLATILE); 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 { else {
fprintf(errfp, "xschem get %s: invalid command.\n", argv[2]); fprintf(errfp, "xschem get %s: invalid command.\n", argv[2]);
} }

View File

@ -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]) { if(n>=0 && pin_attr[0] && n < (xctx->inst[inst].ptr+ xctx->sym)->rects[PINLAYER]) {
char *pin_attr_value = NULL; 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" /* 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 */ * "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); if(!is_net_name) {
/* get pin_attr from instance pin attribute string */ pin_attr_value = get_pin_attr_from_inst(inst, n, pin_attr);
if(!pin_attr_value) { /* get pin_attr from instance pin attribute string */
my_strdup(499, &pin_attr_value, if(!pin_attr_value) {
get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->rect[PINLAYER][n].prop_ptr, pin_attr, 0)); 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 /* @#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 '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 *instprop = xctx->inst[inst].prop_ptr;
char *symprop = (xctx->inst[inst].ptr + xctx->sym)->prop_ptr; char *symprop = (xctx->inst[inst].ptr + xctx->sym)->prop_ptr;
if(s_pnetname && (!strcmp(get_tok_value(instprop, "net_name", 0), "true") || if(s_pnetname && (!strcmp(get_tok_value(instprop, "net_name", 0), "true") ||

View File

@ -76,7 +76,7 @@ static int client_msg(Display *disp, Window win, char *msg, /* {{{ */
int window_state (Display *disp, Window win, char *arg) {/*{{{*/ int window_state (Display *disp, Window win, char *arg) {/*{{{*/
static char *arg_copy=NULL; char arg_copy[256]; /* overflow safe */
unsigned long action; unsigned long action;
int i; int i;
Atom prop1 = 0; 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: " const char *argerr = "expects a list of comma separated parameters: "
"\"(remove|add|toggle),<PROP1>[,<PROP2>]\"\n"; "\"(remove|add|toggle),<PROP1>[,<PROP2>]\"\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", if (!arg || strlen(arg) == 0) {
(int)win,arg_copy);
if (!arg_copy || strlen(arg_copy) == 0) {
fputs(argerr, errfp); fputs(argerr, errfp);
return EXIT_FAILURE; 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, ','))) { if ((p1 = strchr(arg_copy, ','))) {
static char tmp_prop1[1024], tmp1[1024]; /* overflow safe 20161122 */
*p1 = '\0'; *p1 = '\0';
@ -118,7 +117,6 @@ int window_state (Display *disp, Window win, char *arg) {/*{{{*/
/* the second property */ /* the second property */
if ((p2 = strchr(p1, ','))) { if ((p2 = strchr(p1, ','))) {
static char tmp_prop2[1024], tmp2[1024]; /* overflow safe */
*p2 = '\0'; *p2 = '\0';
p2++; p2++;
if (strlen(p2) == 0) { if (strlen(p2) == 0) {
@ -126,6 +124,7 @@ int window_state (Display *disp, Window win, char *arg) {/*{{{*/
return EXIT_FAILURE; return EXIT_FAILURE;
} }
for( i = 0; p2[i]; i++) tmp2[i] = toupper( p2[i] ); 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); my_snprintf(tmp_prop2, S(tmp_prop2), "_NET_WM_STATE_%s", tmp2);
prop2 = XInternAtom(disp, tmp_prop2, False); prop2 = XInternAtom(disp, tmp_prop2, False);
} }
@ -136,6 +135,7 @@ int window_state (Display *disp, Window win, char *arg) {/*{{{*/
return EXIT_FAILURE; return EXIT_FAILURE;
} }
for( i = 0; p1[i]; i++) tmp1[i] = toupper( p1[i] ); 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); my_snprintf(tmp_prop1, S(tmp_prop1), "_NET_WM_STATE_%s", tmp1);
prop1 = XInternAtom(disp, tmp_prop1, False); prop1 = XInternAtom(disp, tmp_prop1, False);