diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index 69f9387e..9d9a65c9 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -481,7 +481,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" -
Resets UI state, unselect all and abort any pending operation
@@ -1073,14 +1072,18 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
Start a GUI start snapped wire placement (click to start a
wire to closest pin/net endpoint)
+ + replace 'rep' with 'with' in string 'str' + if rep not preceeded by an 'escape' character
Return string 'str' with 'tok' attribute value replaced with 'newval'
When a symbol is selected edit it in a new tab/window if not already open.
If nothing selected open another window of the second schematic (issues a warning).
if 'new_process' is given start a new xschem process
- - List all used symbols+
+ if 'n' given list symbol with name or number 'n', else + list all used symbols
If a simulation raw file is lodaded unload from memory.
else read a tabular file 'table_file'
@@ -1159,6 +1162,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
Zoom to selection
+
+
diff --git a/src/actions.c b/src/actions.c
index ca53bb5f..cb7e52ed 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1269,7 +1269,6 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst)
{
char *sch = NULL;
char *str_tmp = NULL;
- char *ptr;
int web_url = 0;
struct stat buf;
@@ -1282,15 +1281,7 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst)
if(!str_tmp) my_strdup2(_ALLOC_ID_, &str_tmp, get_tok_value(sym->prop_ptr, "schematic", 2));
if(str_tmp[0]) {
/* @symname in schematic attribute will be replaced with symbol name */
- if( (ptr = strstr(str_tmp, "@symname")) && ( ptr == str_tmp || *(ptr - 1) != '\\') ) {
- *ptr = '\0';
- my_strdup2(_ALLOC_ID_, &sch, str_tmp);
- my_strcat(_ALLOC_ID_, &sch, sym->name);
- ptr += 8;
- my_strcat(_ALLOC_ID_, &sch, ptr);
- } else {
- my_strdup2(_ALLOC_ID_, &sch, str_tmp);
- }
+ my_strdup(_ALLOC_ID_, &sch, str_replace(str_tmp, "@symname", skip_dir(sym->name), '\\'));
dbg(1, "get_sch_from_sym(): sch=%s\n", sch);
my_strdup2(_ALLOC_ID_, &sch, tcl_hook2(&sch));
dbg(1, "get_sch_from_sym(): after tcl_hook2 sch=%s\n", sch);
diff --git a/src/editprop.c b/src/editprop.c
index f68851b8..fc5432be 100644
--- a/src/editprop.c
+++ b/src/editprop.c
@@ -1507,13 +1507,15 @@ void change_elem_order(void)
}
}
-char *str_replace(const char *s, const char *rep, const char *with)
+char *str_replace(const char *str, const char *rep, const char *with, int escape)
{
static char *result = NULL;
static size_t size=0;
size_t result_pos = 0;
size_t rep_len;
size_t with_len;
+ const char *s = str;
+ int cond;
if(s==NULL || rep == NULL || with == NULL || rep[0] == '\0') {
my_free(_ALLOC_ID_, &result);
@@ -1529,7 +1531,9 @@ char *str_replace(const char *s, const char *rep, const char *with)
}
while(*s) {
STR_ALLOC(&result, result_pos + with_len + 1, &size);
- if(!strncmp(s, rep, rep_len)) {
+
+ cond = ((s == str) || ((*(s - 1) != escape))) && (!strncmp(s, rep, rep_len));
+ if(cond) {
my_strncpy(result + result_pos, with, with_len + 1);
result_pos += with_len;
s += rep_len;
diff --git a/src/scheduler.c b/src/scheduler.c
index 324ab2d5..33609dba 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -3506,6 +3506,21 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
xctx->ui_state |= MENUSTARTSNAPWIRE;
}
+ /* str_replace str rep with [escape]
+ * replace 'rep' with 'with' in string 'str'
+ * if rep not preceeded by an 'escape' character */
+ else if(!strcmp(argv[1], "str_replace"))
+ {
+ int escape = 0;
+ if(argc > 5) escape = argv[5][0];
+ if(argc > 4) {
+ Tcl_AppendResult(interp, str_replace(argv[2], argv[3], argv[4], escape), NULL);
+ } else {
+ Tcl_SetResult(interp, "Missing arguments", TCL_STATIC);
+ return TCL_ERROR;
+ }
+ }
+
/* subst_tok str tok newval
* Return string 'str' with 'tok' attribute value replaced with 'newval' */
else if(!strcmp(argv[1], "subst_tok"))
@@ -3529,13 +3544,17 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
- /* symbols
- * List all used symbols */
+ /* symbols [n]
+ * if 'n' given list symbol with name or number 'n', else
+ * list all used symbols */
else if(!strcmp(argv[1], "symbols"))
{
int i;
char n[100];
- for(i=0; i