some code refactoring, more usage of tclgetboolvar()
This commit is contained in:
parent
b613d65fd9
commit
3ed97b3df2
|
|
@ -947,12 +947,12 @@ void enable_layers(void)
|
|||
{
|
||||
int i;
|
||||
char tmp[50];
|
||||
const char *en;
|
||||
int en;
|
||||
xctx->n_active_layers = 0;
|
||||
for(i = 0; i< cadlayers; ++i) {
|
||||
my_snprintf(tmp, S(tmp), "enable_layer(%d)",i);
|
||||
en = tclgetvar(tmp);
|
||||
if(!en || en[0] == '0') xctx->enable_layer[i] = 0;
|
||||
en = tclgetboolvar(tmp);
|
||||
if(!en) xctx->enable_layer[i] = 0;
|
||||
else {
|
||||
xctx->enable_layer[i] = 1;
|
||||
if(i>=7) {
|
||||
|
|
@ -1229,14 +1229,14 @@ void attach_labels_to_inst(int interactive) /* offloaded from callback.c 201710
|
|||
tclsetvar("do_all_inst", "1");
|
||||
tclsetvar("rotated_text", "0");
|
||||
}
|
||||
use_label_prefix = atoi(tclgetvar("use_label_prefix"));
|
||||
use_label_prefix = tclgetboolvar("use_label_prefix");
|
||||
rot_txt = tclgetvar("rotated_text");
|
||||
if(strcmp(rot_txt,"")) rotated_text=atoi(rot_txt);
|
||||
my_strdup(_ALLOC_ID_, &type,(xctx->inst[xctx->sel_array[j].n].ptr+ xctx->sym)->type);
|
||||
if( type && IS_LABEL_OR_PIN(type) ) {
|
||||
continue;
|
||||
}
|
||||
if(!do_all_inst && !strcmp(tclgetvar("do_all_inst"),"1")) do_all_inst=1;
|
||||
if(!do_all_inst && tclgetboolvar("do_all_inst")) do_all_inst=1;
|
||||
dbg(1, "attach_labels_to_inst(): 1--> %s %.16g %.16g %s\n",
|
||||
xctx->inst[xctx->sel_array[j].n].name,
|
||||
xctx->inst[xctx->sel_array[j].n].x0,
|
||||
|
|
@ -1310,7 +1310,7 @@ void attach_labels_to_inst(int interactive) /* offloaded from callback.c 201710
|
|||
} else {
|
||||
rot1=(short)((rot+rotated_text)%4); /* 20111103 20171208 text_rotation */
|
||||
}
|
||||
if(!strcmp(tclgetvar("use_lab_wire"),"0")) {
|
||||
if(!tclgetboolvar("use_lab_wire")) {
|
||||
place_symbol(-1,symname_pin, pinx0, piny0, rot1, dir, prop, 2, first_call, 1/*to_push_undo*/);
|
||||
} else {
|
||||
place_symbol(-1,symname_wire, pinx0, piny0, rot1, dir, prop, 2, first_call, 1/*to_push_undo*/);
|
||||
|
|
@ -2149,8 +2149,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected)
|
|||
boundbox->y2=100;
|
||||
if(selected != 2) for(c=0;c<cadlayers; ++c)
|
||||
{
|
||||
const char *tmp = tclgetvar("hide_empty_graphs");
|
||||
int hide_graphs = (tmp && tmp[0] == '1') ? 1 : 0;
|
||||
int hide_graphs = tclgetboolvar("hide_empty_graphs");
|
||||
int waves = (sch_waves_loaded() >= 0);
|
||||
|
||||
for(i=0;i<xctx->lines[c]; ++i)
|
||||
|
|
|
|||
|
|
@ -2059,7 +2059,7 @@ int rstate; /* (reduced state, without ShiftMask) */
|
|||
xctx->enable_drill = 0;
|
||||
if(exists) {
|
||||
if(!tool) {
|
||||
tool = atoi(tclgetvar("sim(spicewave,default)"));
|
||||
tool = tclgetintvar("sim(spicewave,default)");
|
||||
my_snprintf(str, S(str), "sim(spicewave,%d,name)", tool);
|
||||
my_strdup(_ALLOC_ID_, &tool_name, tclgetvar(str));
|
||||
dbg(1,"callback(): tool_name=%s\n", tool_name);
|
||||
|
|
@ -2727,9 +2727,9 @@ int rstate; /* (reduced state, without ShiftMask) */
|
|||
} else if(tcleval("winfo exists .dialog.txt")[0] == '1') { /* proc enter_text */
|
||||
tcleval(".dialog.buttons.ok invoke");
|
||||
break;
|
||||
} else if(button==Button1 && state==0 && tclgetvar("edit_symbol_prop_new_sel")[0]) {
|
||||
} else if(button==Button1 && state==0 && tclgetboolvar("edit_symbol_prop_new_sel")) {
|
||||
tcleval("set edit_symbol_prop_new_sel 1; .dialog.f1.b1 invoke"); /* invoke 'OK' of edit prop dialog */
|
||||
} else if(button==Button1 && (state & ShiftMask) && tclgetvar("edit_symbol_prop_new_sel")[0]) {
|
||||
} else if(button==Button1 && (state & ShiftMask) && tclgetboolvar("edit_symbol_prop_new_sel")) {
|
||||
select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
|
||||
rebuild_selected_array();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -818,7 +818,7 @@ static int edit_rect_property(int x)
|
|||
}
|
||||
else if(x==2) tcleval("viewdata $::retval");
|
||||
else tcleval("edit_vi_prop {Text:}"); /* x == 1 */
|
||||
preserve = atoi(tclgetvar("preserve_unchanged_attrs"));
|
||||
preserve = tclgetboolvar("preserve_unchanged_attrs");
|
||||
if(strcmp(tclgetvar("rcode"),"") )
|
||||
{
|
||||
xctx->push_undo();
|
||||
|
|
@ -885,7 +885,7 @@ static int edit_line_property(void)
|
|||
xctx->semaphore++;
|
||||
tcleval("text_line {Input property:} 0 normal");
|
||||
xctx->semaphore--;
|
||||
preserve = atoi(tclgetvar("preserve_unchanged_attrs"));
|
||||
preserve = tclgetboolvar("preserve_unchanged_attrs");
|
||||
if(strcmp(tclgetvar("rcode"),"") )
|
||||
{
|
||||
double y1, y2;
|
||||
|
|
@ -941,7 +941,7 @@ static int edit_wire_property(void)
|
|||
xctx->semaphore++;
|
||||
tcleval("text_line {Input property:} 0 normal");
|
||||
xctx->semaphore--;
|
||||
preserve = atoi(tclgetvar("preserve_unchanged_attrs"));
|
||||
preserve = tclgetboolvar("preserve_unchanged_attrs");
|
||||
if(strcmp(tclgetvar("rcode"),"") )
|
||||
{
|
||||
xctx->push_undo();
|
||||
|
|
@ -1006,7 +1006,7 @@ static int edit_arc_property(void)
|
|||
xctx->semaphore++;
|
||||
tcleval("text_line {Input property:} 0 normal");
|
||||
xctx->semaphore--;
|
||||
preserve = atoi(tclgetvar("preserve_unchanged_attrs"));
|
||||
preserve = tclgetboolvar("preserve_unchanged_attrs");
|
||||
if(strcmp(tclgetvar("rcode"),"") )
|
||||
{
|
||||
xctx->push_undo();
|
||||
|
|
@ -1076,7 +1076,7 @@ static int edit_polygon_property(void)
|
|||
xctx->semaphore++;
|
||||
tcleval("text_line {Input property:} 0 normal");
|
||||
xctx->semaphore--;
|
||||
preserve = atoi(tclgetvar("preserve_unchanged_attrs"));
|
||||
preserve = tclgetboolvar("preserve_unchanged_attrs");
|
||||
if(strcmp(tclgetvar("rcode"),"") )
|
||||
{
|
||||
xctx->push_undo();
|
||||
|
|
@ -1175,7 +1175,7 @@ static int edit_text_property(int x)
|
|||
}
|
||||
else if(x==2) tcleval("viewdata $::retval");
|
||||
else tcleval("edit_vi_prop {Text:}"); /* x == 1 */
|
||||
preserve = atoi(tclgetvar("preserve_unchanged_attrs"));
|
||||
preserve = tclgetboolvar("preserve_unchanged_attrs");
|
||||
if(x == 0 || x == 1) {
|
||||
if(strcmp(xctx->text[sel].txt_ptr, tclgetvar("retval") ) ) {
|
||||
dbg(1, "edit_text_property(): x=%d, text_changed=1\n", x);
|
||||
|
|
@ -1331,9 +1331,9 @@ static int update_symbol(const char *result, int x, int first_sel)
|
|||
my_strncpy(symbol, (char *) tclgetvar("symbol") , S(symbol));
|
||||
generator = is_generator(symbol);
|
||||
dbg(1, "update_symbol(): symbol=%s\n", symbol);
|
||||
no_change_props=atoi(tclgetvar("no_change_attrs") );
|
||||
only_different=atoi(tclgetvar("preserve_unchanged_attrs") );
|
||||
copy_cell=atoi(tclgetvar("user_wants_copy_cell") );
|
||||
no_change_props=tclgetboolvar("no_change_attrs");
|
||||
only_different=tclgetboolvar("preserve_unchanged_attrs");
|
||||
copy_cell=tclgetboolvar("user_wants_copy_cell");
|
||||
/* if there are floaters or generators (dynamic symbols, pCells) do not collect
|
||||
* list of things to redraw, just redraw all screen */
|
||||
floaters = there_are_floaters() || generator;
|
||||
|
|
@ -1782,7 +1782,7 @@ void edit_property(int x)
|
|||
{
|
||||
case ELEMENT:
|
||||
modified |= edit_symbol_property(x, j);
|
||||
while( x == 0 && tclgetvar("edit_symbol_prop_new_sel")[0] == '1' ) {
|
||||
while( x == 0 && tclgetboolvar("edit_symbol_prop_new_sel")) {
|
||||
unselect_all(1);
|
||||
select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
|
||||
rebuild_selected_array();
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ void create_plot_cmd(void)
|
|||
if(tclresult()[0] == '1') exists = 1;
|
||||
xctx->enable_drill = 0;
|
||||
if(exists) {
|
||||
viewer = atoi(tclgetvar("sim(spicewave,default)"));
|
||||
viewer = tclgetintvar("sim(spicewave,default)");
|
||||
my_snprintf(tcl_str, S(tcl_str), "sim(spicewave,%d,name)", viewer);
|
||||
my_strdup(_ALLOC_ID_, &viewer_name, tclgetvar(tcl_str));
|
||||
dbg(1,"create_plot_cmd(): viewer_name=%s\n", viewer_name);
|
||||
|
|
|
|||
|
|
@ -4890,13 +4890,18 @@ int tclgetintvar(const char *s)
|
|||
|
||||
int tclgetboolvar(const char *s)
|
||||
{
|
||||
int res;
|
||||
const char *p;
|
||||
p = Tcl_GetVar(interp, s, TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG);
|
||||
if(!p) {
|
||||
dbg(0, "%s\n", tclresult());
|
||||
return 0;
|
||||
}
|
||||
return p[0] == '1' ? 1 : 0;
|
||||
if(Tcl_GetBoolean(interp, p, &res) == TCL_ERROR) {
|
||||
dbg(0, "%s\n", tclresult());
|
||||
return 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
const char *tclgetvar(const char *s)
|
||||
|
|
|
|||
289
src/token.c
289
src/token.c
|
|
@ -54,68 +54,6 @@ void floater_hash_all_names(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* if inst == -1 hash all instance names, else do only given instance
|
||||
* action can be XINSERT or XDELETE to insert or remove items */
|
||||
void hash_names(int inst, int action)
|
||||
{
|
||||
int i, mult, start, stop;
|
||||
char *upinst = NULL;
|
||||
char *upinst_ptr, *upinst_state, *single_name;
|
||||
dbg(1, "hash_names(): inst=%d, action=%d\n", inst, action);
|
||||
if(inst == -1) {
|
||||
int_hash_free(&xctx->inst_name_table);
|
||||
int_hash_init(&xctx->inst_name_table, HASHSIZE);
|
||||
}
|
||||
if(inst == -1) {
|
||||
start = 0;
|
||||
stop = xctx->instances;
|
||||
} else {
|
||||
start = inst;
|
||||
stop = inst + 1;
|
||||
}
|
||||
if(inst != -1) dbg(1, "hash_names(): start=%d, stop=%d, instname=%s\n",
|
||||
start, stop, xctx->inst[inst].instname? xctx->inst[inst].instname : "NULL");
|
||||
for(i = start; i < stop; ++i) {
|
||||
if(xctx->inst[i].instname && xctx->inst[i].instname[0]) {
|
||||
my_strdup(_ALLOC_ID_, &upinst, expandlabel(xctx->inst[i].instname, &mult));
|
||||
strtoupper(upinst);
|
||||
|
||||
upinst_ptr = upinst;
|
||||
while( (single_name = my_strtok_r(upinst_ptr, ",", "", &upinst_state)) ) {
|
||||
upinst_ptr = NULL;
|
||||
dbg(1, "hash_names(): inst %d, name %s --> %d\n", i, single_name, action);
|
||||
int_hash_lookup(&xctx->inst_name_table, single_name, i, action);
|
||||
dbg(1, "hash_names(): hashing %s from %s\n", single_name, xctx->inst[i].instname);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(upinst) my_free(_ALLOC_ID_, &upinst);
|
||||
}
|
||||
|
||||
|
||||
/* return -1 if name is not used, else return instance number with same name found */
|
||||
int name_is_used(char *name)
|
||||
{
|
||||
int mult, used = -1;
|
||||
char *upinst = NULL;
|
||||
char *upinst_ptr, *upinst_state, *single_name;
|
||||
Int_hashentry *entry;
|
||||
my_strdup(_ALLOC_ID_, &upinst, expandlabel(name, &mult));
|
||||
strtoupper(upinst);
|
||||
upinst_ptr = upinst;
|
||||
while( (single_name = my_strtok_r(upinst_ptr, ",", "", &upinst_state)) ) {
|
||||
upinst_ptr = NULL;
|
||||
entry = int_hash_lookup(&xctx->inst_name_table, single_name, 1, XLOOKUP);
|
||||
if(entry) {
|
||||
used = entry->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
my_free(_ALLOC_ID_, &upinst);
|
||||
dbg(1, "name_is_used(%s): return inst %d\n", name, used);
|
||||
return used;
|
||||
}
|
||||
|
||||
/* if cmd is wrapped inside tcleval(...) pass the content to tcl
|
||||
* for evaluation, return tcl result. If no tcleval(...) found return copy of cmd */
|
||||
const char *tcl_hook2(const char *cmd)
|
||||
|
|
@ -140,70 +78,6 @@ const char *tcl_hook2(const char *cmd)
|
|||
return result;
|
||||
}
|
||||
|
||||
void check_unique_names(int rename)
|
||||
{
|
||||
int i, first = 1, modified = 0;
|
||||
int newpropcnt = 0;
|
||||
char *tmp = NULL;
|
||||
int used;
|
||||
|
||||
if(xctx->hilight_nets) {
|
||||
xctx->enable_drill=0;
|
||||
clear_all_hilights();
|
||||
draw();
|
||||
}
|
||||
int_hash_free(&xctx->inst_name_table);
|
||||
int_hash_init(&xctx->inst_name_table, HASHSIZE);
|
||||
|
||||
/* look for duplicates */
|
||||
first = 1;
|
||||
for(i=0;i<xctx->instances; ++i) {
|
||||
if(xctx->inst[i].instname && xctx->inst[i].instname[0]) {
|
||||
if(xctx->inst[i].ptr == -1) continue;
|
||||
if(!(xctx->inst[i].ptr+ xctx->sym)->type) continue;
|
||||
used = name_is_used(xctx->inst[i].instname);
|
||||
hash_names(i, XINSERT_NOREPLACE);
|
||||
if( used != -1 && used != i) {
|
||||
dbg(0, "check_unique_names(): found duplicate: i=%d name=%s\n", i, xctx->inst[i].instname);
|
||||
xctx->inst[i].color = -PINLAYER;
|
||||
inst_hilight_hash_lookup(i, -PINLAYER, XINSERT_NOREPLACE);
|
||||
if(rename == 1) {
|
||||
if(first) {
|
||||
bbox(START,0.0,0.0,0.0,0.0);
|
||||
modified = 1;
|
||||
xctx->push_undo();
|
||||
xctx->prep_hash_inst=0;
|
||||
xctx->prep_net_structs=0;
|
||||
xctx->prep_hi_structs=0;
|
||||
first = 0;
|
||||
}
|
||||
bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* for(i...) */
|
||||
|
||||
/* rename duplicates */
|
||||
if(rename) for(i=0;i<xctx->instances; ++i) {
|
||||
if( (xctx->inst[i].color != -10000)) {
|
||||
my_strdup(_ALLOC_ID_, &tmp, xctx->inst[i].prop_ptr);
|
||||
new_prop_string(i, tmp, newpropcnt++, 0);
|
||||
hash_names(i, XINSERT);
|
||||
symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2);
|
||||
bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
|
||||
my_free(_ALLOC_ID_, &tmp);
|
||||
}
|
||||
} /* for(i...) */
|
||||
if(modified) set_modify(1);
|
||||
if(rename == 1 && xctx->hilight_nets) {
|
||||
bbox(SET,0.0,0.0,0.0,0.0);
|
||||
draw();
|
||||
bbox(END,0.0,0.0,0.0,0.0);
|
||||
}
|
||||
redraw_hilights(0);
|
||||
int_hash_free(&xctx->inst_name_table);
|
||||
}
|
||||
|
||||
int is_generator(const char *name)
|
||||
{
|
||||
#ifdef __unix__
|
||||
|
|
@ -257,7 +131,6 @@ const char *sanitize(const char *name)
|
|||
* if no xxxx generator file found return NULL */
|
||||
char *get_generator_command(const char *str)
|
||||
{
|
||||
|
||||
char *cmd = NULL;
|
||||
char *gen_cmd = NULL;
|
||||
const char *cmd_filename;
|
||||
|
|
@ -762,19 +635,86 @@ static char *get_pin_attr_from_inst(int inst, int pin, const char *attr)
|
|||
return pin_attr_value; /* caller is responsible for freeing up storage for pin_attr_value */
|
||||
}
|
||||
|
||||
/* given a old_prop property string, return a new */
|
||||
/* property string in xctx->inst[i].prop_ptr such that the element name is */
|
||||
/* unique in current design (that is, element name is changed */
|
||||
/* if necessary) */
|
||||
/* if old_prop=NULL return NULL */
|
||||
/* if old_prop does not contain a valid "name" or empty return old_prop */
|
||||
int get_last_used_index(const char *old_name_base, const char *brkt)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* if inst == -1 hash all instance names, else do only given instance
|
||||
* action can be XINSERT or XDELETE to insert or remove items */
|
||||
void hash_names(int inst, int action)
|
||||
{
|
||||
int i, mult, start, stop;
|
||||
char *upinst = NULL;
|
||||
char *upinst_ptr, *upinst_state, *single_name;
|
||||
dbg(1, "hash_names(): inst=%d, action=%d\n", inst, action);
|
||||
if(inst == -1) {
|
||||
int_hash_free(&xctx->inst_name_table);
|
||||
int_hash_init(&xctx->inst_name_table, HASHSIZE);
|
||||
}
|
||||
if(inst == -1) {
|
||||
start = 0;
|
||||
stop = xctx->instances;
|
||||
} else {
|
||||
start = inst;
|
||||
stop = inst + 1;
|
||||
}
|
||||
if(inst != -1) dbg(1, "hash_names(): start=%d, stop=%d, instname=%s\n",
|
||||
start, stop, xctx->inst[inst].instname? xctx->inst[inst].instname : "NULL");
|
||||
for(i = start; i < stop; ++i) {
|
||||
if(xctx->inst[i].instname && xctx->inst[i].instname[0]) {
|
||||
my_strdup(_ALLOC_ID_, &upinst, expandlabel(xctx->inst[i].instname, &mult));
|
||||
strtoupper(upinst);
|
||||
|
||||
upinst_ptr = upinst;
|
||||
while( (single_name = my_strtok_r(upinst_ptr, ",", "", &upinst_state)) ) {
|
||||
upinst_ptr = NULL;
|
||||
dbg(1, "hash_names(): inst %d, name %s --> %d\n", i, single_name, action);
|
||||
int_hash_lookup(&xctx->inst_name_table, single_name, i, action);
|
||||
dbg(1, "hash_names(): hashing %s from %s\n", single_name, xctx->inst[i].instname);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(upinst) my_free(_ALLOC_ID_, &upinst);
|
||||
}
|
||||
|
||||
/* return -1 if name is not used, else return instance number with same name found */
|
||||
static int name_is_used(char *name)
|
||||
{
|
||||
int mult, used = -1;
|
||||
char *upinst = NULL;
|
||||
char *upinst_ptr, *upinst_state, *single_name;
|
||||
Int_hashentry *entry;
|
||||
my_strdup(_ALLOC_ID_, &upinst, expandlabel(name, &mult));
|
||||
strtoupper(upinst);
|
||||
upinst_ptr = upinst;
|
||||
while( (single_name = my_strtok_r(upinst_ptr, ",", "", &upinst_state)) ) {
|
||||
upinst_ptr = NULL;
|
||||
entry = int_hash_lookup(&xctx->inst_name_table, single_name, 1, XLOOKUP);
|
||||
if(entry) {
|
||||
used = entry->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
my_free(_ALLOC_ID_, &upinst);
|
||||
dbg(1, "name_is_used(%s): return inst %d\n", name, used);
|
||||
return used;
|
||||
}
|
||||
|
||||
/* given a old_prop property string, return a new
|
||||
* property string in xctx->inst[i].prop_ptr such that the element name is
|
||||
* unique in current design (that is, element name is changed
|
||||
* if necessary)
|
||||
* if old_prop=NULL return NULL
|
||||
* if old_prop does not contain a valid "name" or empty return old_prop
|
||||
* hash_names(-1, XINSERT) must be called before using this function */
|
||||
void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
|
||||
{
|
||||
char *old_name=NULL, *new_name=NULL;
|
||||
const char *brkt;
|
||||
const char *new_prop;
|
||||
size_t old_name_len;
|
||||
int n, q;
|
||||
int n, q, qq;
|
||||
char *old_name_base = NULL;
|
||||
char *up_new_name = NULL;
|
||||
int is_used;
|
||||
|
|
@ -804,16 +744,17 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
|
|||
brkt=find_bracket(old_name);
|
||||
my_realloc(_ALLOC_ID_, &new_name, old_name_len + 40); /* strlen(old_name)+40); */
|
||||
|
||||
for(q = 1 ;; ++q) {
|
||||
if(n) {
|
||||
my_snprintf(new_name, old_name_len + 40, "%s%d%s", old_name_base, q, brkt);
|
||||
} else { /* goes here if weird name set for example to name=[3:0] or name=12 */
|
||||
my_snprintf(new_name, old_name_len + 40, "%d%s", q, brkt);
|
||||
}
|
||||
is_used = name_is_used(new_name);
|
||||
if(is_used == -1 ) break;
|
||||
|
||||
qq = get_last_used_index(old_name_base, brkt); /* */
|
||||
for(q = qq ;; ++q) {
|
||||
if(n) {
|
||||
my_snprintf(new_name, old_name_len + 40, "%s%d%s", old_name_base, q, brkt);
|
||||
} else { /* goes here if weird name set for example to name=[3:0] or name=12 */
|
||||
my_snprintf(new_name, old_name_len + 40, "%d%s", q, brkt);
|
||||
}
|
||||
is_used = name_is_used(new_name);
|
||||
if(is_used == -1 ) break;
|
||||
}
|
||||
|
||||
my_free(_ALLOC_ID_, &old_name_base);
|
||||
dbg(1, "new_prop_string(): new_name=%s\n", new_name);
|
||||
new_prop = subst_token(old_prop, "name", new_name);
|
||||
|
|
@ -828,7 +769,69 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
|
|||
my_free(_ALLOC_ID_, &up_new_name);
|
||||
}
|
||||
|
||||
void check_unique_names(int rename)
|
||||
{
|
||||
int i, first = 1, modified = 0;
|
||||
int newpropcnt = 0;
|
||||
char *tmp = NULL;
|
||||
int used;
|
||||
|
||||
if(xctx->hilight_nets) {
|
||||
xctx->enable_drill=0;
|
||||
clear_all_hilights();
|
||||
draw();
|
||||
}
|
||||
int_hash_free(&xctx->inst_name_table);
|
||||
int_hash_init(&xctx->inst_name_table, HASHSIZE);
|
||||
|
||||
/* look for duplicates */
|
||||
first = 1;
|
||||
for(i=0;i<xctx->instances; ++i) {
|
||||
if(xctx->inst[i].instname && xctx->inst[i].instname[0]) {
|
||||
if(xctx->inst[i].ptr == -1) continue;
|
||||
if(!(xctx->inst[i].ptr+ xctx->sym)->type) continue;
|
||||
used = name_is_used(xctx->inst[i].instname);
|
||||
hash_names(i, XINSERT_NOREPLACE);
|
||||
if( used != -1 && used != i) {
|
||||
dbg(0, "check_unique_names(): found duplicate: i=%d name=%s\n", i, xctx->inst[i].instname);
|
||||
xctx->inst[i].color = -PINLAYER;
|
||||
inst_hilight_hash_lookup(i, -PINLAYER, XINSERT_NOREPLACE);
|
||||
if(rename == 1) {
|
||||
if(first) {
|
||||
bbox(START,0.0,0.0,0.0,0.0);
|
||||
modified = 1;
|
||||
xctx->push_undo();
|
||||
xctx->prep_hash_inst=0;
|
||||
xctx->prep_net_structs=0;
|
||||
xctx->prep_hi_structs=0;
|
||||
first = 0;
|
||||
}
|
||||
bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* for(i...) */
|
||||
|
||||
/* rename duplicates */
|
||||
if(rename) for(i=0;i<xctx->instances; ++i) {
|
||||
if( (xctx->inst[i].color != -10000)) {
|
||||
my_strdup(_ALLOC_ID_, &tmp, xctx->inst[i].prop_ptr);
|
||||
new_prop_string(i, tmp, newpropcnt++, 0);
|
||||
hash_names(i, XINSERT);
|
||||
symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2);
|
||||
bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
|
||||
my_free(_ALLOC_ID_, &tmp);
|
||||
}
|
||||
} /* for(i...) */
|
||||
if(modified) set_modify(1);
|
||||
if(rename == 1 && xctx->hilight_nets) {
|
||||
bbox(SET,0.0,0.0,0.0,0.0);
|
||||
draw();
|
||||
bbox(END,0.0,0.0,0.0,0.0);
|
||||
}
|
||||
redraw_hilights(0);
|
||||
int_hash_free(&xctx->inst_name_table);
|
||||
}
|
||||
|
||||
static int is_quoted(const char *s)
|
||||
{
|
||||
|
|
|
|||
19
src/xinit.c
19
src/xinit.c
|
|
@ -1894,12 +1894,8 @@ static void destroy_all_tabs(int *window_count, int force)
|
|||
int new_schematic(const char *what, const char *win_path, const char *fname)
|
||||
{
|
||||
int tabbed_interface;
|
||||
const char *tmp;
|
||||
|
||||
tabbed_interface = 0;
|
||||
if((tmp = tclgetvar("tabbed_interface"))) {
|
||||
if(tmp[0] == '1') tabbed_interface = 1;
|
||||
}
|
||||
tabbed_interface = tclgetboolvar("tabbed_interface");
|
||||
dbg(1, "new_schematic(): current_win_path=%s, what=%s, win_path=%s\n", xctx->current_win_path, what, win_path);
|
||||
if(!strcmp(what, "ntabs")) {
|
||||
return window_count;
|
||||
|
|
@ -2485,16 +2481,13 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
cairo_font_line_spacing = tclgetdoublevar("cairo_font_line_spacing");
|
||||
|
||||
if(color_ps==-1)
|
||||
color_ps=atoi(tclgetvar("color_ps"));
|
||||
color_ps=tclgetboolvar("color_ps");
|
||||
else {
|
||||
my_snprintf(tmp, S(tmp), "%d",color_ps);
|
||||
tclsetvar("color_ps",tmp);
|
||||
tclsetboolvar("color_ps", color_ps);
|
||||
}
|
||||
l_width=atoi(tclgetvar("line_width"));
|
||||
if(tclgetboolvar("change_lw")) l_width = 0.0;
|
||||
|
||||
cadlayers=atoi(tclgetvar("cadlayers"));
|
||||
|
||||
l_width=tclgetdoublevar("line_width");
|
||||
if(tclgetboolvar("change_lw")) l_width = -1.0;
|
||||
cadlayers=tclgetintvar("cadlayers");
|
||||
fix_broken_tiled_fill = tclgetboolvar("fix_broken_tiled_fill");
|
||||
if(debug_var==-10) debug_var=0;
|
||||
my_snprintf(tmp, S(tmp), "%.16g",CADGRID);
|
||||
|
|
|
|||
|
|
@ -1513,7 +1513,6 @@ extern const char *subst_token(const char *s, const char *tok, const char *new_v
|
|||
extern void new_prop_string(int i, const char *old_prop,int fast, int dis_uniq_names);
|
||||
extern void hash_name(char *token, int remove);
|
||||
extern void hash_names(int inst, int action); /* if i == -1 hash all instances, else do only inst */
|
||||
extern int name_is_used(char *name);
|
||||
extern void floater_hash_all_names(void);
|
||||
extern void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2);
|
||||
/* extern char *escape_chars(char *dest, const char *source, int size); */
|
||||
|
|
|
|||
Loading…
Reference in New Issue