further fix expandlabel() potentially returning its string argument (instead of a copy) in case of weird and wrong node syntax

This commit is contained in:
stefan schippers 2023-10-06 11:11:17 +02:00
parent 42781f8456
commit 3e4f49dbea
2 changed files with 103 additions and 34 deletions

View File

@ -15,16 +15,17 @@
#### XSCHEM SYSTEM-WIDE DESIGN LIBRARY PATHS: XSCHEM_LIBRARY_PATH #### XSCHEM SYSTEM-WIDE DESIGN LIBRARY PATHS: XSCHEM_LIBRARY_PATH
########################################################################### ###########################################################################
#### If unset xschem starts with XSCHEM_LIBRARY_PATH set to the default, typically: #### If unset xschem starts with XSCHEM_LIBRARY_PATH set to the default, typically:
#### /home/schippes/.xschem/xschem_library #### <install_root>/.xschem/xschem_library
#### /home/schippes/share/xschem/xschem_library/devices #### <install_root>/share/xschem/xschem_library/devices
#### /home/schippes/share/doc/xschem/examples #### <install_root>/share/doc/xschem/examples
#### /home/schippes/share/doc/xschem/ngspice #### <install_root>/share/doc/xschem/ngspice
#### /home/schippes/share/doc/xschem/logic #### <install_root>/share/doc/xschem/logic
#### /home/schippes/share/doc/xschem/xschem_simulator #### <install_root>/share/doc/xschem/xschem_simulator
#### /home/schippes/share/doc/xschem/generators #### <install_root>/share/doc/xschem/generators
#### /home/schippes/share/doc/xschem/binto7seg #### <install_root>/share/doc/xschem/inst_sch_select
#### /home/schippes/share/doc/xschem/pcb #### <install_root>/share/doc/xschem/binto7seg
#### /home/schippes/share/doc/xschem/rom8k #### <install_root>/share/doc/xschem/pcb
#### <install_root>/share/doc/xschem/rom8k
#### For testing in build src directory #### For testing in build src directory
#### if unset following paths are set and maintained if existing: #### if unset following paths are set and maintained if existing:
@ -35,6 +36,7 @@
#### ../xschem_library/logic #### ../xschem_library/logic
#### ../xschem_library/xschem_simulator #### ../xschem_library/xschem_simulator
#### ../xschem_library/generators #### ../xschem_library/generators
#### ../xschem_library/inst_sch_select
#### ../xschem_library/binto7seg #### ../xschem_library/binto7seg
#### ../xschem_library/pcb #### ../xschem_library/pcb
#### ../xschem_library/rom8k #### ../xschem_library/rom8k
@ -46,12 +48,14 @@
# append XSCHEM_LIBRARY_PATH :${XSCHEM_SHAREDIR}/xschem_library/devices # append XSCHEM_LIBRARY_PATH :${XSCHEM_SHAREDIR}/xschem_library/devices
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/examples # append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/examples
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/ngspice # append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/ngspice
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/xschem_simulator
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/rom8k
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/logic # append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/logic
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/pcb # append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/xschem_simulator
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/generators # append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/generators
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/inst_sch_select
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/binto7seg # append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/binto7seg
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/pcb
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/rom8k
#### Optional, often not needed...
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/symgen # append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/symgen
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/xTAG # append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/xTAG
# append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/rulz-r8c33 # append XSCHEM_LIBRARY_PATH :${xschem_doc_dir}/rulz-r8c33
@ -63,12 +67,13 @@
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/devices" # append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/devices"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/examples" # append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/examples"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/ngspice" # append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/ngspice"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/xschem_simulator"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/rom8k"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/logic" # append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/logic"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/pcb" # append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/xschem_simulator"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/generators" # append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/generators"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/inst_sch_select"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/binto7seg" # append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/binto7seg"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/pcb"
# append XSCHEM_LIBRARY_PATH ";${XSCHEM_SHAREDIR}/../xschem_library/rom8k"
########################################################################### ###########################################################################
#### SET CUSTOM COLORS FOR XSCHEM LIBRARIES MATCHING CERTAIN PATTERNS #### SET CUSTOM COLORS FOR XSCHEM LIBRARIES MATCHING CERTAIN PATTERNS
@ -94,6 +99,10 @@
#### If unset $USER_CONF_DIR/simulations is assumed (normally ~/.xschem/simulations) #### If unset $USER_CONF_DIR/simulations is assumed (normally ~/.xschem/simulations)
# set netlist_dir $env(HOME)/.xschem/simulations # set netlist_dir $env(HOME)/.xschem/simulations
#### if this is set to '1' netlists and simulations will go into a simulation/ folder
#### inside the directory containing the top level schematic. Default: not set (0)
# set local_netlist_dir 1
########################################################################### ###########################################################################
#### NETLIST AND HIERARCHICAL PRINT EXCLUDE PATTERNS #### NETLIST AND HIERARCHICAL PRINT EXCLUDE PATTERNS
########################################################################### ###########################################################################
@ -141,6 +150,11 @@
#### allow color postscript and svg exports. Default: 1, enable color #### allow color postscript and svg exports. Default: 1, enable color
# set color_ps 1 # set color_ps 1
#### set paper size: name, height, width. Sizes in 1/72 of an inch (typographical points)
#### default: {a4 842 595}
# set ps_paper_size {a4 842 595}
# set ps_paper_size {letter 792 612}
#### initial size of xschem window you can specify also position with (wxh+x+y) #### initial size of xschem window you can specify also position with (wxh+x+y)
#### this is the default: #### this is the default:
# set initial_geometry {900x600} # set initial_geometry {900x600}
@ -150,6 +164,10 @@
#### default setting: 0 #### default setting: 0
# set unzoom_nodrift 0 # set unzoom_nodrift 0
#### if set to 1 full zoom will center the drawing instead of anhoring to lower
#### left corner. Default: 0
# set zoom_full_center 1
#### if set to 1 allow to place multiple components with same name. #### if set to 1 allow to place multiple components with same name.
#### Warning: this is normally not allowed in any simulation netlist. #### Warning: this is normally not allowed in any simulation netlist.
#### default: 0, do not allow place multiple elements with same name (refdes) #### default: 0, do not allow place multiple elements with same name (refdes)
@ -159,22 +177,45 @@
#### default: 0 #### default: 0
# set persistent_command 1 # set persistent_command 1
#### if set to 1 a wire is inserted when separating components that are #### if set to 1 at end of a move operation that stretches wires attached to
#### connected by pins. Default: not enabled (0) #### moved objects these wires will be unselected.
# set connect_by_kissing 1 #### default: not enabled (0)
# set unselect_partial_sel_wires 0
#### if set to 1 automatically join/trim wires while editing #### if set to 1 automatically join/trim wires while editing
#### this may slow down on rally big designs. Can be disabled via menu #### this may slow down on rally big designs. Can be disabled via menu
#### default: 0 #### default: 0
# set autotrim_wires 0 # set autotrim_wires 0
#### do not ask to save file when doing control-s or File -> Save
#### default: disabled (0), will ask before saving.
# set no_ask_save 0
#### set widget scaling (mainly for font display), this is useful on 4K displays #### set widget scaling (mainly for font display), this is useful on 4K displays
#### default: unset (tk uses its default) > 1.0 ==> bigger #### default: unset (tk uses its default) > 1.0 ==> bigger
# set tk_scaling 1.7 # set tk_scaling 1.7
#### use the tclreadline package if available , Default: 1 (enabled).
# set use_tclreadline 1
#### disable some symbol layers. Default: none, all layers are visible. #### disable some symbol layers. Default: none, all layers are visible.
# set enable_layer(5) 0 ;# example to disable pin red boxes # set enable_layer(5) 0 ;# example to disable pin red boxes
#### enable drawing the grid. Default: enabled (1)
# set draw_grid 1
#### enable stretch mode: when dragging a selection rectangle that cuts wires these are stretched
#### to follow the selected objects when moved. Default: not enabled (0).
#### This can be normally done by dragging with the Control key pressed.
#### Enabling this option swaps the two drag modes.
# set enable_stretch 0
#### enable drawing crosshairs at mouse coordinates. Default: disabled (0)
# set draw_crosshair 1
#### set crosshair layer; Default 3 (TEXTLAYER)
# set crosshair_layer 3
#### enable to scale grid point size as done with lines at close zoom, default: 0 #### enable to scale grid point size as done with lines at close zoom, default: 0
# set big_grid_points 0 # set big_grid_points 0
@ -194,10 +235,18 @@
#### default: enabled (1) #### default: enabled (1)
# set autofocus_mainwindow 0 # set autofocus_mainwindow 0
#### replace selected text in text widgets when pasting from clipboard
#### default: enabled (1)
# set text_replace_selection 0
#### set component browser always above drawing canvas. #### set component browser always above drawing canvas.
#### default: enabled (1) #### default: enabled (1)
# set component_browser_on_top 0 # set component_browser_on_top 0
#### set graph line width multiplier with respect to xschem actual line width
#### default: 2.0
# set graph_linewidth_mult 4.0
########################################################################### ###########################################################################
#### EXPORT FORMAT TRANSLATORS, PNG AND PDF #### EXPORT FORMAT TRANSLATORS, PNG AND PDF
########################################################################### ###########################################################################
@ -318,6 +367,11 @@ set editor {notepad.exe}
# set show_infowindow 0 # set show_infowindow 0
########################################################################### ###########################################################################
#### SHOW ERC INFO WINDOW AFTER NETLIST
###########################################################################
#### allowed values: never onerror always
#### default: onerror
# set show_infowindow_after_netlist onerror
########################################################################### ###########################################################################
#### TCP CONNECTION WITH GAW #### TCP CONNECTION WITH GAW
@ -342,29 +396,36 @@ set editor {notepad.exe}
#### TCL FILES TO LOAD AT STARTUP #### TCL FILES TO LOAD AT STARTUP
########################################################################### ###########################################################################
#### list of tcl files to preload. #### list of tcl files to preload.
# set tcl_files {}
# lappend tcl_files [list ${XSCHEM_SHAREDIR}/ngspice_backannotate.tcl]
# lappend tcl_files ${XSCHEM_SHAREDIR}/change_index.tcl # lappend tcl_files ${XSCHEM_SHAREDIR}/change_index.tcl
# lappend tcl_files ${XSCHEM_SHAREDIR}/ngspice_backannotate.tcl # lappend tcl_files ....
###########################################################################
#### TCL COMMANDS TO BE EXECUTED AFTER COMPLETING STARTUP
###########################################################################
# set postinit_commands {puts [xschem get version]}
########################################################################### ###########################################################################
#### WEB URL DOWNLOAD HELPER APPLICATION #### WEB URL DOWNLOAD HELPER APPLICATION
########################################################################### ###########################################################################
#### used to download files from web: default: {curl -f -s -O} #### used to download files from web: default: {curl -f -s -O -J}
# set download_url_helper {curl -f -s -O} # set download_url_helper {curl -f -s -O -J}
# set download_url_helper {wget -N --quiet} # set download_url_helper {wget -N --quiet --content-disposition}
########################################################################### ###########################################################################
#### XSCHEM TOOLBAR #### XSCHEM TOOLBAR
########################################################################### ###########################################################################
#### default: not enabled. #### default: enabled, horizontal
# set toolbar_visible 1 # set toolbar_visible 0
# set toolbar_horiz 1 # set toolbar_horiz 1
########################################################################### ###########################################################################
#### TABBED WINDOWS #### TABBED WINDOWS
########################################################################### ###########################################################################
#### default: not enabled. Interface can be changed runtime if only one window #### default: enabled. Interface can be changed runtime if only one window
#### or tab is open. #### or tab is open.
# set tabbed_interface 1 # set tabbed_interface 0
########################################################################### ###########################################################################
#### CASE INSENSITIVE SYMBOL LOOKUP #### CASE INSENSITIVE SYMBOL LOOKUP
@ -407,3 +468,10 @@ set editor {notepad.exe}
#### Instead, additional drives can be added using XSCHEM_LIBRARY_PATH #### Instead, additional drives can be added using XSCHEM_LIBRARY_PATH
#### default: 1 #### default: 1
# set add_all_windows_drives 0 # set add_all_windows_drives 0
###########################################################################
#### FIX GRAPHIC PROBLEMS ON SOME DRIVERS/GPU CONFIGURATIONS
###########################################################################
#### if you see garbage on screen / graphic artifacts while editing with
#### xschem try to set this to 1. Default: not enabled (0)
# set fix_broken_tiled_fill 0

View File

@ -97,7 +97,10 @@ const char *expandlabel(const char *s, int *m)
YY_BUFFER_STATE buf; YY_BUFFER_STATE buf;
my_free(_ALLOC_ID_, &dest_string.str); /* 30102004 delete 'memory' of previous execution */ my_free(_ALLOC_ID_, &dest_string.str); /* 30102004 delete 'memory' of previous execution */
if(!s) {
*m = -1;
return NULL;
}
if(parselabel_debug >= 3) fprintf(errfp, "expandlabel(): entering\n"); if(parselabel_debug >= 3) fprintf(errfp, "expandlabel(): entering\n");
if(!strpbrk(s, "*,.:")) { /* shortcut: nothing to parse / expand */ if(!strpbrk(s, "*,.:")) { /* shortcut: nothing to parse / expand */
*m = 1; *m = 1;
@ -123,19 +126,17 @@ const char *expandlabel(const char *s, int *m)
} }
if(parselabel_debug >= 3) if(parselabel_debug >= 3)
fprintf(errfp, "expandlabel(): returning %s from %s mult=%d\n",dest_string.str, s, dest_string.m); fprintf(errfp, "expandlabel(): returning %s from %s mult=%d\n",dest_string.str, s, dest_string.m);
if(dest_string.str)
*m = dest_string.m;
else
*m=-1;
if(dest_string.str) { if(dest_string.str) {
*m = dest_string.m;
if(xctx->netlist_type == CAD_SPICE_NETLIST && bus_char[0] && bus_char[1]) { if(xctx->netlist_type == CAD_SPICE_NETLIST && bus_char[0] && bus_char[1]) {
str_char_replace(dest_string.str, '[', bus_char[0]); str_char_replace(dest_string.str, '[', bus_char[0]);
str_char_replace(dest_string.str, ']', bus_char[1]); str_char_replace(dest_string.str, ']', bus_char[1]);
} }
return dest_string.str;
} else { } else {
return s; *m=-1;
my_strdup(_ALLOC_ID_, &dest_string.str, s);
} }
return dest_string.str;
} }