From 3ef28c8a9d77ff71bfd4339076c54587ce87dabb Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 4 Dec 2021 23:57:24 +0100 Subject: [PATCH 1/9] WIP: fixed some string extractors --- src/gsiqt/gsiqt.pro | 2 +- src/klayout.pri | 2 +- src/klayout_main/klayout_main/klayout_main.pro | 2 +- src/lay/lay/lay.pro | 2 +- src/laybasic/laybasic/laybasic.pro | 2 +- src/lib_ut.pri | 2 +- src/plugins/tools/view_25d/view_25d.pro | 2 +- src/pymod/QtCore/QtCore.pro | 2 +- src/pymod/QtGui/QtGui.pro | 2 +- src/pymod/QtXml/QtXml.pro | 2 +- src/pymod/pymod.pro | 2 +- src/pymod/tl/tl.pro | 2 +- src/unit_tests/unit_tests.pro | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gsiqt/gsiqt.pro b/src/gsiqt/gsiqt.pro index a252b470f..8e0f734e4 100644 --- a/src/gsiqt/gsiqt.pro +++ b/src/gsiqt/gsiqt.pro @@ -2,7 +2,7 @@ TEMPLATE = subdirs SUBDIRS = qtbasic -equals(HAVE_QT5, "1") { +greaterThan(QT_MAJOR_VERSION, 4) { SUBDIRS += qt5 qt5.depends += qtbasic } else { diff --git a/src/klayout.pri b/src/klayout.pri index 550c0cba7..01e08ba06 100644 --- a/src/klayout.pri +++ b/src/klayout.pri @@ -178,7 +178,7 @@ equals(HAVE_QT, "0") { } } - equals(HAVE_QT5, "1") { + greaterThan(QT_MAJOR_VERSION, 4) { QT += widgets gui printsupport xmlpatterns diff --git a/src/klayout_main/klayout_main/klayout_main.pro b/src/klayout_main/klayout_main/klayout_main.pro index 31ab7eb22..695f11e88 100644 --- a/src/klayout_main/klayout_main/klayout_main.pro +++ b/src/klayout_main/klayout_main/klayout_main.pro @@ -45,7 +45,7 @@ equals(HAVE_QTBINDINGS, "1") { LIBS += -lklayout_QtUiTools } - equals(HAVE_QT5, "1") { + greaterThan(QT_MAJOR_VERSION, 4) { LIBS += -lklayout_QtWidgets diff --git a/src/lay/lay/lay.pro b/src/lay/lay/lay.pro index 8a07f7da3..dea36e8e7 100644 --- a/src/lay/lay/lay.pro +++ b/src/lay/lay/lay.pro @@ -207,7 +207,7 @@ equals(HAVE_QTBINDINGS, "1") { !equals(HAVE_QT_XML, "0") { LIBS += -lklayout_QtXml } - equals(HAVE_QT5, "1") { + greaterThan(QT_MAJOR_VERSION, 4) { LIBS += -lklayout_QtWidgets } } diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 5cf65cefe..309e33a20 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -310,7 +310,7 @@ DEPENDPATH += $$QTBASIC_INC equals(HAVE_QTBINDINGS, "1") { LIBS += -lklayout_qtbasic -lklayout_QtGui -lklayout_QtCore - equals(HAVE_QT5, "1") { + greaterThan(QT_MAJOR_VERSION, 4) { LIBS += -lklayout_QtWidgets } } diff --git a/src/lib_ut.pri b/src/lib_ut.pri index 92abe0854..e80c7ba32 100644 --- a/src/lib_ut.pri +++ b/src/lib_ut.pri @@ -17,7 +17,7 @@ win32 { QMAKE_POST_LINK += $(COPY) $(DESTDIR)$(TARGET) $$DESTDIR_UT/$${TARGET}.ut } -equals(HAVE_QT5, "1") { +greaterThan(QT_MAJOR_VERSION, 4) { QT += testlib } else { CONFIG += qtestlib diff --git a/src/plugins/tools/view_25d/view_25d.pro b/src/plugins/tools/view_25d/view_25d.pro index 3eb5a6fad..138f0890d 100644 --- a/src/plugins/tools/view_25d/view_25d.pro +++ b/src/plugins/tools/view_25d/view_25d.pro @@ -3,7 +3,7 @@ TEMPLATE = subdirs contains(QT_CONFIG, opengl) { - equals(HAVE_QT5, "1") { + greaterThan(QT_MAJOR_VERSION, 4) { SUBDIRS = lay_plugin unit_tests } diff --git a/src/pymod/QtCore/QtCore.pro b/src/pymod/QtCore/QtCore.pro index b45334bd4..9f7943d23 100644 --- a/src/pymod/QtCore/QtCore.pro +++ b/src/pymod/QtCore/QtCore.pro @@ -10,6 +10,6 @@ HEADERS += \ LIBS += -lklayout_QtCore -lklayout_QtGui -equals(HAVE_QT5, "1") { +greaterThan(QT_MAJOR_VERSION, 4) { LIBS += -lklayout_QtWidgets } diff --git a/src/pymod/QtGui/QtGui.pro b/src/pymod/QtGui/QtGui.pro index a2f39a5bc..287a0a072 100644 --- a/src/pymod/QtGui/QtGui.pro +++ b/src/pymod/QtGui/QtGui.pro @@ -10,7 +10,7 @@ HEADERS += \ LIBS += -lklayout_QtGui -lklayout_QtCore -equals(HAVE_QT5, "1") { +greaterThan(QT_MAJOR_VERSION, 4) { LIBS += -lklayout_QtWidgets } diff --git a/src/pymod/QtXml/QtXml.pro b/src/pymod/QtXml/QtXml.pro index a8641948a..0e178a75e 100644 --- a/src/pymod/QtXml/QtXml.pro +++ b/src/pymod/QtXml/QtXml.pro @@ -13,6 +13,6 @@ LIBS += -lklayout_QtCore -lklayout_QtXml # Because of stupid dependency of QtCore on QtGui and this on QtWidgets: LIBS += -lklayout_QtGui -equals(HAVE_QT5, "1") { +greaterThan(QT_MAJOR_VERSION, 4) { LIBS += -lklayout_QtWidgets } diff --git a/src/pymod/pymod.pro b/src/pymod/pymod.pro index 1b1998702..7b140159f 100644 --- a/src/pymod/pymod.pro +++ b/src/pymod/pymod.pro @@ -18,7 +18,7 @@ SUBDIRS = \ QtCore \ QtGui - equals(HAVE_QT5, "1") { + greaterThan(QT_MAJOR_VERSION, 4) { SUBDIRS += QtWidgets diff --git a/src/pymod/tl/tl.pro b/src/pymod/tl/tl.pro index 2ae8a8b1f..58219f4a0 100644 --- a/src/pymod/tl/tl.pro +++ b/src/pymod/tl/tl.pro @@ -12,7 +12,7 @@ HEADERS += \ # Use this opportunity to provide the __init__.py file equals(HAVE_QTBINDINGS, "1") { - equals(HAVE_QT5, "1") { + greaterThan(QT_MAJOR_VERSION, 4) { INIT_PY = $$PWD/../__init__.py.qt5 } else { INIT_PY = $$PWD/../__init__.py.qt4 diff --git a/src/unit_tests/unit_tests.pro b/src/unit_tests/unit_tests.pro index 1676e614a..0e01149cb 100644 --- a/src/unit_tests/unit_tests.pro +++ b/src/unit_tests/unit_tests.pro @@ -37,7 +37,7 @@ LIBS += -lklayout_gsi_test !equals(HAVE_QT_XML, "0") { LIBS += -lklayout_QtXml } - equals(HAVE_QT5, "1") { + greaterThan(QT_MAJOR_VERSION, 4) { LIBS += -lklayout_QtWidgets } } From 519d7f6353a022bdd0598cbe8de0a843437afd99 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 7 Dec 2021 23:40:26 +0100 Subject: [PATCH 2/9] Fixed issue #942 (plus: cleaned some config inconsistencies and fixed a small Ui flaw) --- .../lefdef/db_plugin/dbLEFDEFPlugin.cc | 45 +++++++++++++------ .../lay_plugin/layLEFDEFImportDialogs.cc | 3 ++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc index 35489ff1e..24f8383ea 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc @@ -331,59 +331,75 @@ class LEFDEFFormatDeclaration tl::make_member (&LEFDEFReaderOptions::inst_property_name, &LEFDEFReaderOptions::set_inst_property_name, "inst-property-name") + tl::make_member (&LEFDEFReaderOptions::produce_pin_names, &LEFDEFReaderOptions::set_produce_pin_names, "produce-pin-names") + tl::make_member (&LEFDEFReaderOptions::pin_property_name, &LEFDEFReaderOptions::set_pin_property_name, "pin-property-name") + + tl::make_member (&LEFDEFReaderOptions::produce_cell_outlines, &LEFDEFReaderOptions::set_produce_cell_outlines, "produce-cell-outlines") + tl::make_member (&LEFDEFReaderOptions::cell_outline_layer, &LEFDEFReaderOptions::set_cell_outline_layer, "cell-outline-layer") + + tl::make_member (&LEFDEFReaderOptions::produce_placement_blockages, &LEFDEFReaderOptions::set_produce_placement_blockages, "produce-placement-blockages") + tl::make_member (&LEFDEFReaderOptions::placement_blockage_layer, &LEFDEFReaderOptions::set_placement_blockage_layer, "placement-blockage-layer") + + tl::make_member (&LEFDEFReaderOptions::produce_regions, &LEFDEFReaderOptions::set_produce_regions, "produce-regions") + tl::make_member (&LEFDEFReaderOptions::region_layer, &LEFDEFReaderOptions::set_region_layer, "region-layer") + + tl::make_member (&LEFDEFReaderOptions::produce_via_geometry, &LEFDEFReaderOptions::set_produce_via_geometry, "produce-via-geometry") + // for backward compatibility tl::make_member (&LEFDEFReaderOptions::set_via_geometry_suffix, "special-via_geometry-suffix") + tl::make_member (&LEFDEFReaderOptions::set_via_geometry_datatype, "special-via_geometry-datatype") + + tl::make_member (&LEFDEFReaderOptions::set_via_geometry_suffix_str, "special-via_geometry-suffix-string") + + tl::make_member (&LEFDEFReaderOptions::set_via_geometry_datatype_str, "special-via_geometry-datatype-string") + // new: - tl::make_member (&LEFDEFReaderOptions::via_geometry_suffix_str, &LEFDEFReaderOptions::set_via_geometry_suffix_str, "special-via_geometry-suffix-string") + - tl::make_member (&LEFDEFReaderOptions::via_geometry_datatype_str, &LEFDEFReaderOptions::set_via_geometry_datatype_str, "special-via_geometry-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::via_geometry_suffix_str, &LEFDEFReaderOptions::set_via_geometry_suffix_str, "via_geometry-suffix-string") + + tl::make_member (&LEFDEFReaderOptions::via_geometry_datatype_str, &LEFDEFReaderOptions::set_via_geometry_datatype_str, "via_geometry-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::produce_pins, &LEFDEFReaderOptions::set_produce_pins, "produce-pins") + // for backward compatibility tl::make_member (&LEFDEFReaderOptions::set_pins_suffix, "special-pins-suffix") + tl::make_member (&LEFDEFReaderOptions::set_pins_datatype, "special-pins-datatype") + + tl::make_member (&LEFDEFReaderOptions::set_pins_suffix_str, "special-pins-suffix-string") + + tl::make_member (&LEFDEFReaderOptions::set_pins_datatype_str, "special-pins-datatype-string") + // new: - tl::make_member (&LEFDEFReaderOptions::pins_suffix_str, &LEFDEFReaderOptions::set_pins_suffix_str, "special-pins-suffix-string") + - tl::make_member (&LEFDEFReaderOptions::pins_datatype_str, &LEFDEFReaderOptions::set_pins_datatype_str, "special-pins-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::pins_suffix_str, &LEFDEFReaderOptions::set_pins_suffix_str, "pins-suffix-string") + + tl::make_member (&LEFDEFReaderOptions::pins_datatype_str, &LEFDEFReaderOptions::set_pins_datatype_str, "pins-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::produce_lef_pins, &LEFDEFReaderOptions::set_produce_lef_pins, "produce-lef-pins") + // for backward compatibility tl::make_member (&LEFDEFReaderOptions::set_lef_pins_suffix, "special-lef_pins-suffix") + tl::make_member (&LEFDEFReaderOptions::set_lef_pins_datatype, "special-lef_pins-datatype") + + tl::make_member (&LEFDEFReaderOptions::set_lef_pins_suffix_str, "special-lef_pins-suffix-string") + + tl::make_member (&LEFDEFReaderOptions::set_lef_pins_datatype_str, "special-lef_pins-datatype-string") + // new: - tl::make_member (&LEFDEFReaderOptions::lef_pins_suffix_str, &LEFDEFReaderOptions::set_lef_pins_suffix_str, "special-lef_pins-suffix-string") + - tl::make_member (&LEFDEFReaderOptions::lef_pins_datatype_str, &LEFDEFReaderOptions::set_lef_pins_datatype_str, "special-lef_pins-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::lef_pins_suffix_str, &LEFDEFReaderOptions::set_lef_pins_suffix_str, "lef_pins-suffix-string") + + tl::make_member (&LEFDEFReaderOptions::lef_pins_datatype_str, &LEFDEFReaderOptions::set_lef_pins_datatype_str, "lef_pins-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::produce_fills, &LEFDEFReaderOptions::set_produce_fills, "produce-fills") + // for backward compatibility tl::make_member (&LEFDEFReaderOptions::set_fills_suffix, "special-fills-suffix") + tl::make_member (&LEFDEFReaderOptions::set_fills_datatype, "special-fills-datatype") + + tl::make_member (&LEFDEFReaderOptions::set_fills_suffix_str, "special-fills-suffix-string") + + tl::make_member (&LEFDEFReaderOptions::set_fills_datatype_str, "special-fills-datatype-string") + // new: - tl::make_member (&LEFDEFReaderOptions::fills_suffix_str, &LEFDEFReaderOptions::set_fills_suffix_str, "special-fills-suffix-string") + - tl::make_member (&LEFDEFReaderOptions::fills_datatype_str, &LEFDEFReaderOptions::set_fills_datatype_str, "special-fills-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::fills_suffix_str, &LEFDEFReaderOptions::set_fills_suffix_str, "fills-suffix-string") + + tl::make_member (&LEFDEFReaderOptions::fills_datatype_str, &LEFDEFReaderOptions::set_fills_datatype_str, "fills-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::produce_obstructions, &LEFDEFReaderOptions::set_produce_obstructions, "produce-obstructions") + tl::make_member (&LEFDEFReaderOptions::obstructions_suffix, &LEFDEFReaderOptions::set_obstructions_suffix, "obstructions-suffix") + tl::make_member (&LEFDEFReaderOptions::obstructions_datatype, &LEFDEFReaderOptions::set_obstructions_datatype, "obstructions-datatype") + + tl::make_member (&LEFDEFReaderOptions::produce_blockages, &LEFDEFReaderOptions::set_produce_blockages, "produce-blockages") + tl::make_member (&LEFDEFReaderOptions::blockages_suffix, &LEFDEFReaderOptions::set_blockages_suffix, "blockages-suffix") + tl::make_member (&LEFDEFReaderOptions::blockages_datatype, &LEFDEFReaderOptions::set_blockages_datatype, "blockages-datatype") + + tl::make_member (&LEFDEFReaderOptions::produce_labels, &LEFDEFReaderOptions::set_produce_labels, "produce-labels") + tl::make_member (&LEFDEFReaderOptions::labels_suffix, &LEFDEFReaderOptions::set_labels_suffix, "labels-suffix") + tl::make_member (&LEFDEFReaderOptions::labels_datatype, &LEFDEFReaderOptions::set_labels_datatype, "labels-datatype") + tl::make_member (&LEFDEFReaderOptions::produce_lef_labels, &LEFDEFReaderOptions::set_produce_lef_labels, "produce-lef-labels") + tl::make_member (&LEFDEFReaderOptions::lef_labels_suffix, &LEFDEFReaderOptions::set_lef_labels_suffix, "lef-labels-suffix") + tl::make_member (&LEFDEFReaderOptions::lef_labels_datatype, &LEFDEFReaderOptions::set_lef_labels_datatype, "lef-labels-datatype") + + tl::make_member (&LEFDEFReaderOptions::produce_routing, &LEFDEFReaderOptions::set_produce_routing, "produce-routing") + - // for backward compatibility - tl::make_member (&LEFDEFReaderOptions::set_routing_suffix, "special-routing-suffix") + - tl::make_member (&LEFDEFReaderOptions::set_routing_datatype, "special-routing-datatype") + - // new: - tl::make_member (&LEFDEFReaderOptions::routing_suffix_str, &LEFDEFReaderOptions::set_routing_suffix_str, "special-routing-suffix-string") + - tl::make_member (&LEFDEFReaderOptions::routing_datatype_str, &LEFDEFReaderOptions::set_routing_datatype_str, "special-routing-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::routing_suffix_str, &LEFDEFReaderOptions::set_routing_suffix_str, "routing-suffix-string") + + tl::make_member (&LEFDEFReaderOptions::routing_datatype_str, &LEFDEFReaderOptions::set_routing_datatype_str, "routing-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::produce_special_routing, &LEFDEFReaderOptions::set_produce_special_routing, "produce-special-routing") + // for backward compatibility tl::make_member (&LEFDEFReaderOptions::set_special_routing_suffix, "special-routing-suffix") + @@ -391,6 +407,7 @@ class LEFDEFFormatDeclaration // new: tl::make_member (&LEFDEFReaderOptions::special_routing_suffix_str, &LEFDEFReaderOptions::set_special_routing_suffix_str, "special-routing-suffix-string") + tl::make_member (&LEFDEFReaderOptions::special_routing_datatype_str, &LEFDEFReaderOptions::set_special_routing_datatype_str, "special-routing-datatype-string") + + tl::make_member (&LEFDEFReaderOptions::via_cellname_prefix, &LEFDEFReaderOptions::set_via_cellname_prefix, "via-cellname-prefix") + tl::make_member (&LEFDEFReaderOptions::begin_lef_files, &LEFDEFReaderOptions::end_lef_files, &LEFDEFReaderOptions::push_lef_file, "lef-files") + tl::make_member (&LEFDEFReaderOptions::begin_macro_layout_files, &LEFDEFReaderOptions::end_macro_layout_files, &LEFDEFReaderOptions::push_macro_layout_file, "macro_layout-files") + diff --git a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc index 744dab2f0..4badeb7e9 100644 --- a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc +++ b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc @@ -360,6 +360,7 @@ LEFDEFReaderOptionsEditor::LEFDEFReaderOptionsEditor (QWidget *parent) connect (produce_routing, SIGNAL (stateChanged (int)), this, SLOT (checkbox_changed ())); connect (produce_special_routing, SIGNAL (stateChanged (int)), this, SLOT (checkbox_changed ())); connect (produce_labels, SIGNAL (stateChanged (int)), this, SLOT (checkbox_changed ())); + connect (produce_lef_labels, SIGNAL (stateChanged (int)), this, SLOT (checkbox_changed ())); connect (add_lef_file, SIGNAL (clicked ()), this, SLOT (add_lef_file_clicked ())); connect (del_lef_files, SIGNAL (clicked ()), this, SLOT (del_lef_files_clicked ())); connect (move_lef_files_up, SIGNAL (clicked ()), this, SLOT (move_lef_files_up_clicked ())); @@ -644,6 +645,7 @@ LEFDEFReaderOptionsEditor::checkbox_changed () suffix_routing->setEnabled (produce_routing->isChecked ()); suffix_special_routing->setEnabled (produce_special_routing->isChecked ()); suffix_labels->setEnabled (produce_labels->isChecked ()); + suffix_lef_labels->setEnabled (produce_lef_labels->isChecked ()); datatype_via_geometry->setEnabled (produce_via_geometry->isChecked ()); datatype_pins->setEnabled (produce_pins->isChecked ()); datatype_lef_pins->setEnabled (produce_lef_pins->isChecked ()); @@ -653,6 +655,7 @@ LEFDEFReaderOptionsEditor::checkbox_changed () datatype_routing->setEnabled (produce_routing->isChecked ()); datatype_special_routing->setEnabled (produce_special_routing->isChecked ()); datatype_labels->setEnabled (produce_labels->isChecked ()); + datatype_lef_labels->setEnabled (produce_lef_labels->isChecked ()); } void From 07515cd716c65a1f97225407e19c788929bba484 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 15 Dec 2021 23:04:58 +0100 Subject: [PATCH 3/9] Fixed issue #946 for the case of file paths with blanks --- src/tl/tl/tlInclude.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tl/tl/tlInclude.cc b/src/tl/tl/tlInclude.cc index 53a5a6dc1..6f52a438a 100644 --- a/src/tl/tl/tlInclude.cc +++ b/src/tl/tl/tlInclude.cc @@ -134,7 +134,11 @@ IncludeExpander::to_string () const tl_assert (m_sections.begin ()->second.second == 0); std::string fn = m_sections.begin ()->second.first; - return tl::to_word_or_quoted_string (fn, valid_fn_chars); + if (! fn.empty () && fn.front () == '@') { + return tl::to_quoted_string (fn); + } else { + return fn; + } } else { @@ -166,7 +170,7 @@ IncludeExpander::from_string (const std::string &s) ex.read_quoted (ie.m_sections [1].first); - } else if (ex.test ("@")) { + } else if (*ex == '@') { while (! ex.at_end ()) { From 533a72b7bd6b27e523e4ffdb293931cd17b616fc Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 15 Dec 2021 23:18:42 +0100 Subject: [PATCH 4/9] Added tests, fixed implementation --- src/tl/tl/tlInclude.cc | 2 ++ src/tl/unit_tests/tlIncludeTests.cc | 28 ++++++++++++++++++++++++++++ testdata/tl/inc 4.txt | 1 + testdata/tl/x_inc4.txt | 3 +++ 4 files changed, 34 insertions(+) create mode 100644 testdata/tl/inc 4.txt create mode 100644 testdata/tl/x_inc4.txt diff --git a/src/tl/tl/tlInclude.cc b/src/tl/tl/tlInclude.cc index 6f52a438a..e247ab9f3 100644 --- a/src/tl/tl/tlInclude.cc +++ b/src/tl/tl/tlInclude.cc @@ -172,6 +172,8 @@ IncludeExpander::from_string (const std::string &s) } else if (*ex == '@') { + ++ex; + while (! ex.at_end ()) { int ln = 0; diff --git a/src/tl/unit_tests/tlIncludeTests.cc b/src/tl/unit_tests/tlIncludeTests.cc index da681c43e..8ed1651fd 100644 --- a/src/tl/unit_tests/tlIncludeTests.cc +++ b/src/tl/unit_tests/tlIncludeTests.cc @@ -108,3 +108,31 @@ TEST(4_multi_include_interpolate) EXPECT_EQ (ie.translate_to_original (6).second, 3); } +TEST(5_issue946) +{ + std::string fn = tl::testdata () + "/tl/x_inc4.txt"; + + std::string et; + tl::IncludeExpander ie = tl::IncludeExpander::expand (fn, tl::InputStream (fn).read_all (), et); + EXPECT_EQ (et, "A line\nincluded.4\nAnother line\n"); + + EXPECT_EQ (np (ie.to_string ()), np ("@1*" + tl::testdata () + "/tl/x_inc4.txt*0;2*'" + tl::testdata () + "/tl/inc 4.txt'*-1;3*" + tl::testdata () + "/tl/x_inc4.txt*0;")); + EXPECT_EQ (tl::IncludeExpander::from_string (ie.to_string ()).to_string (), ie.to_string ()); + + EXPECT_EQ (ie.translate_to_original (1).first, fn); + EXPECT_EQ (ie.translate_to_original (1).second, 1); + EXPECT_EQ (np (ie.translate_to_original (2).first), np (tl::testdata () + "/tl/inc 4.txt")); + EXPECT_EQ (ie.translate_to_original (2).second, 1); + EXPECT_EQ (ie.translate_to_original (3).first, fn); + EXPECT_EQ (ie.translate_to_original (3).second, 3); + + fn = tl::testdata () + "/tl/inc 4.txt"; + + et.clear (); + ie = tl::IncludeExpander::expand (fn, tl::InputStream (fn).read_all (), et); + EXPECT_EQ (et, "included.4\n"); + + // no quotes here so this string can be used as the original file name if there is no include + EXPECT_EQ (np (ie.to_string ()), np (tl::testdata () + "/tl/inc 4.txt")); +} + diff --git a/testdata/tl/inc 4.txt b/testdata/tl/inc 4.txt new file mode 100644 index 000000000..710f3fd3d --- /dev/null +++ b/testdata/tl/inc 4.txt @@ -0,0 +1 @@ +included.4 diff --git a/testdata/tl/x_inc4.txt b/testdata/tl/x_inc4.txt new file mode 100644 index 000000000..954d8ff6f --- /dev/null +++ b/testdata/tl/x_inc4.txt @@ -0,0 +1,3 @@ +A line +# %include 'inc 4.txt' +Another line From a6d4c80c6c8d2b9a3333a6248905de2bef0d30f3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 16 Dec 2021 00:23:06 +0100 Subject: [PATCH 5/9] Less expression evaluation for more robustness --- src/ant/ant/antConfigPage.cc | 4 +- src/ant/ant/antPropertiesPage.cc | 8 +- src/edt/edt/edtDialogs.cc | 44 +++++------ src/edt/edt/edtEditorOptionsPages.cc | 4 +- src/edt/edt/edtInstPropertiesPage.cc | 20 ++--- src/edt/edt/edtPCellParametersPage.cc | 4 +- src/edt/edt/edtPropertiesPageUtils.cc | 4 +- src/edt/edt/edtPropertiesPages.cc | 20 ++--- src/img/img/imgPropertiesPage.cc | 26 +++--- src/lay/lay/layClipDialog.cc | 16 ++-- src/lay/lay/layFillDialog.cc | 8 +- src/lay/lay/laySearchReplaceConfigPage.cc | 4 +- src/lay/lay/layTechSetupDialog.cc | 2 +- .../laybasic/layBrowseInstancesForm.cc | 4 +- src/laybasic/laybasic/layBrowseShapesForm.cc | 6 +- src/laybasic/laybasic/layDialogs.cc | 40 +++++----- .../laybasic/layEditorOptionsPages.cc | 2 +- .../laybasic/layLayoutPropertiesForm.cc | 2 +- .../laybasic/layLayoutViewConfigPages.cc | 10 +-- .../laybasic/layLayoutViewFunctions.cc | 8 +- src/laybasic/laybasic/layNetExportDialog.cc | 2 +- src/laybasic/laybasic/layNetlistBrowser.cc | 8 +- .../laybasic/laySaveLayoutOptionsDialog.cc | 8 +- src/laybasic/laybasic/rdbMarkerBrowser.cc | 8 +- .../cif/lay_plugin/layCIFReaderPlugin.cc | 2 +- .../dxf/lay_plugin/layDXFReaderPlugin.cc | 12 +-- .../gds2/lay_plugin/layGDS2WriterPlugin.cc | 4 +- .../lay_plugin/layLEFDEFImportDialogs.cc | 2 +- .../magic/lay_plugin/layMAGReaderPlugin.cc | 4 +- .../magic/lay_plugin/layMAGWriterPlugin.cc | 2 +- .../pcb/lay_plugin/layGerberImportDialog.cc | 8 +- .../lay_plugin/layNetTracerConfig.cc | 8 +- .../lay_plugin/layNetTracerDialog.cc | 2 +- .../tools/view_25d/lay_plugin/layD25View.cc | 4 +- src/tl/tl/tlExpression.cc | 15 +++- src/tl/tl/tlExpression.h | 13 ++- src/tl/tl/tlString.cc | 79 ++++++++++++++++--- src/tl/tl/tlString.h | 8 ++ src/tl/unit_tests/tlStringTests.cc | 17 +++- src/tl/unit_tests/tlXMLParserTests.cc | 4 +- 40 files changed, 267 insertions(+), 179 deletions(-) diff --git a/src/ant/ant/antConfigPage.cc b/src/ant/ant/antConfigPage.cc index 4f1cef563..479eefd5f 100644 --- a/src/ant/ant/antConfigPage.cc +++ b/src/ant/ant/antConfigPage.cc @@ -76,7 +76,7 @@ ConfigPage::commit (lay::Dispatcher *root) root->config_set (cfg_ruler_grid_snap, mp_ui->ruler_grid_snap_cbx->isChecked ()); int sr = 0; - tl::from_string (tl::to_string (mp_ui->ruler_snap_range_edit->text ()), sr); + tl::from_string_ext (tl::to_string (mp_ui->ruler_snap_range_edit->text ()), sr); if (sr < 1 || sr > 1000) { throw tl::Exception (tl::to_string (QObject::tr ("Not a valid pixel value (must be non-zero positive and not too large): %s")), tl::to_string (mp_ui->ruler_snap_range_edit->text ())); } @@ -127,7 +127,7 @@ ConfigPage2::commit (lay::Dispatcher *root) { int mr; try { - tl::from_string (tl::to_string (mp_ui->num_rulers_edit->text ()), mr); + tl::from_string_ext (tl::to_string (mp_ui->num_rulers_edit->text ()), mr); } catch (...) { mr = -1; } diff --git a/src/ant/ant/antPropertiesPage.cc b/src/ant/ant/antPropertiesPage.cc index 98bb0fcd5..8932ea4d1 100644 --- a/src/ant/ant/antPropertiesPage.cc +++ b/src/ant/ant/antPropertiesPage.cc @@ -132,7 +132,7 @@ PropertiesPage::get_points (db::DPoint &p1, db::DPoint &p2) bool has_error = false; try { - tl::from_string (tl::to_string (x1->text ()), dx1); + tl::from_string_ext (tl::to_string (x1->text ()), dx1); lay::indicate_error (x1, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (x1, &ex); @@ -140,7 +140,7 @@ PropertiesPage::get_points (db::DPoint &p1, db::DPoint &p2) } try { - tl::from_string (tl::to_string (x2->text ()), dx2); + tl::from_string_ext (tl::to_string (x2->text ()), dx2); lay::indicate_error (x2, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (x2, &ex); @@ -148,7 +148,7 @@ PropertiesPage::get_points (db::DPoint &p1, db::DPoint &p2) } try { - tl::from_string (tl::to_string (y1->text ()), dy1); + tl::from_string_ext (tl::to_string (y1->text ()), dy1); lay::indicate_error (y1, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (y1, &ex); @@ -156,7 +156,7 @@ PropertiesPage::get_points (db::DPoint &p1, db::DPoint &p2) } try { - tl::from_string (tl::to_string (y2->text ()), dy2); + tl::from_string_ext (tl::to_string (y2->text ()), dy2); lay::indicate_error (y2, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (y2, &ex); diff --git a/src/edt/edt/edtDialogs.cc b/src/edt/edt/edtDialogs.cc index 44e9d86ed..0fd252150 100644 --- a/src/edt/edt/edtDialogs.cc +++ b/src/edt/edt/edtDialogs.cc @@ -380,10 +380,10 @@ DistributeOptionsDialog::exec_dialog (lay::LayoutView * /*view*/, bool &hdistrib } hspace = 0.0; - tl::from_string (tl::to_string (this->h_space->text ()), hspace); + tl::from_string_ext (tl::to_string (this->h_space->text ()), hspace); hpitch = 0.0; - tl::from_string (tl::to_string (this->h_pitch->text ()), hpitch); + tl::from_string_ext (tl::to_string (this->h_pitch->text ()), hpitch); vdistribute = this->v_distribute->isChecked (); vmode = -1; @@ -394,10 +394,10 @@ DistributeOptionsDialog::exec_dialog (lay::LayoutView * /*view*/, bool &hdistrib } vspace = 0.0; - tl::from_string (tl::to_string (this->v_space->text ()), vspace); + tl::from_string_ext (tl::to_string (this->v_space->text ()), vspace); vpitch = 0.0; - tl::from_string (tl::to_string (this->v_pitch->text ()), vpitch); + tl::from_string_ext (tl::to_string (this->v_pitch->text ()), vpitch); visible_layers = false; for (int i = 0; i < 2; ++i) { @@ -557,13 +557,13 @@ RoundCornerOptionsDialog::exec_dialog (const db::Layout &layout, double &router, undo_before_apply = m_has_extracted && amend_cb->isChecked (); - tl::from_string (tl::to_string (router_le->text ()), router); + tl::from_string_ext (tl::to_string (router_le->text ()), router); if (rinner_le->text ().isEmpty ()) { rinner = router; } else { - tl::from_string (tl::to_string (rinner_le->text ()), rinner); + tl::from_string_ext (tl::to_string (rinner_le->text ()), rinner); } - tl::from_string (tl::to_string (points_le->text ()), npoints); + tl::from_string_ext (tl::to_string (points_le->text ()), npoints); mp_layout = 0; return true; @@ -582,13 +582,13 @@ BEGIN_PROTECTED; double rhull = 0.0, rholes = 0.0; unsigned int npoints = 0; - tl::from_string (tl::to_string (router_le->text ()), rhull); + tl::from_string_ext (tl::to_string (router_le->text ()), rhull); if (rinner_le->text ().isEmpty ()) { rholes = rhull; } else { - tl::from_string (tl::to_string (rinner_le->text ()), rholes); + tl::from_string_ext (tl::to_string (rinner_le->text ()), rholes); } - tl::from_string (tl::to_string (points_le->text ()), npoints); + tl::from_string_ext (tl::to_string (points_le->text ()), npoints); const unsigned int min_points = 16; const double seg_thr = 10.0; // in DBU @@ -638,12 +638,12 @@ MakeArrayOptionsDialog::exec_dialog (db::DVector &a, unsigned int &na, db::DVect double bx = 0.0, by = 0.0; double ax = 0.0, ay = 0.0; - tl::from_string (tl::to_string (column_x_le->text ()), bx); - tl::from_string (tl::to_string (column_y_le->text ()), by); - tl::from_string (tl::to_string (columns_le->text ()), nb); - tl::from_string (tl::to_string (row_x_le->text ()), ax); - tl::from_string (tl::to_string (row_y_le->text ()), ay); - tl::from_string (tl::to_string (rows_le->text ()), na); + tl::from_string_ext (tl::to_string (column_x_le->text ()), bx); + tl::from_string_ext (tl::to_string (column_y_le->text ()), by); + tl::from_string_ext (tl::to_string (columns_le->text ()), nb); + tl::from_string_ext (tl::to_string (row_x_le->text ()), ax); + tl::from_string_ext (tl::to_string (row_y_le->text ()), ay); + tl::from_string_ext (tl::to_string (rows_le->text ()), na); a = db::DVector (ax, ay); b = db::DVector (bx, by); @@ -665,12 +665,12 @@ BEGIN_PROTECTED; double ax = 0.0, ay = 0.0; int na, nb; - tl::from_string (tl::to_string (column_x_le->text ()), bx); - tl::from_string (tl::to_string (column_y_le->text ()), by); - tl::from_string (tl::to_string (columns_le->text ()), nb); - tl::from_string (tl::to_string (row_x_le->text ()), ax); - tl::from_string (tl::to_string (row_y_le->text ()), ay); - tl::from_string (tl::to_string (rows_le->text ()), na); + tl::from_string_ext (tl::to_string (column_x_le->text ()), bx); + tl::from_string_ext (tl::to_string (column_y_le->text ()), by); + tl::from_string_ext (tl::to_string (columns_le->text ()), nb); + tl::from_string_ext (tl::to_string (row_x_le->text ()), ax); + tl::from_string_ext (tl::to_string (row_y_le->text ()), ay); + tl::from_string_ext (tl::to_string (rows_le->text ()), na); if (na < 1 || nb < 1) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid row or column count (must be larger or equal one)"))); diff --git a/src/edt/edt/edtEditorOptionsPages.cc b/src/edt/edt/edtEditorOptionsPages.cc index 7681eb396..e2abdd7de 100644 --- a/src/edt/edt/edtEditorOptionsPages.cc +++ b/src/edt/edt/edtEditorOptionsPages.cc @@ -58,7 +58,7 @@ static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le { try { Value value = Value (0); - tl::from_string (tl::to_string (le->text ()), value); + tl::from_string_ext (tl::to_string (le->text ()), value); dispatcher->config_set (cfg_name, tl::to_string (value)); lay::indicate_error (le, (tl::Exception *) 0); } catch (tl::Exception &ex) { @@ -249,7 +249,7 @@ EditorOptionsText::apply (lay::Dispatcher *root) root->config_set (cfg_edit_text_size, 0.0); } else { double sz = 0.0; - tl::from_string (tl::to_string (mp_ui->size_le->text ()), sz); + tl::from_string_ext (tl::to_string (mp_ui->size_le->text ()), sz); root->config_set (cfg_edit_text_size, sz); } } diff --git a/src/edt/edt/edtInstPropertiesPage.cc b/src/edt/edt/edtInstPropertiesPage.cc index 3ba054717..2492c49c0 100644 --- a/src/edt/edt/edtInstPropertiesPage.cc +++ b/src/edt/edt/edtInstPropertiesPage.cc @@ -456,7 +456,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & double x = 0.0, y = 0.0; try { - tl::from_string (tl::to_string (pos_x_le->text ()), x); + tl::from_string_ext (tl::to_string (pos_x_le->text ()), x); lay::indicate_error (pos_x_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (pos_x_le, &ex); @@ -464,7 +464,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & } try { - tl::from_string (tl::to_string (pos_y_le->text ()), y); + tl::from_string_ext (tl::to_string (pos_y_le->text ()), y); lay::indicate_error (pos_y_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (pos_y_le, &ex); @@ -481,7 +481,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & bool mirror = mirror_cbx->isChecked (); double angle = 0.0; try { - tl::from_string (tl::to_string (angle_le->text ()), angle); + tl::from_string_ext (tl::to_string (angle_le->text ()), angle); lay::indicate_error (angle_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (angle_le, &ex); @@ -490,7 +490,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & double mag = 0.0; try { - tl::from_string (tl::to_string (mag_le->text ()), mag); + tl::from_string_ext (tl::to_string (mag_le->text ()), mag); lay::indicate_error (mag_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (mag_le, &ex); @@ -519,7 +519,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & unsigned long rows = 0, cols = 0; try { - tl::from_string (tl::to_string (column_x_le->text ()), cx); + tl::from_string_ext (tl::to_string (column_x_le->text ()), cx); lay::indicate_error (column_x_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (column_x_le, &ex); @@ -527,7 +527,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & } try { - tl::from_string (tl::to_string (column_y_le->text ()), cy); + tl::from_string_ext (tl::to_string (column_y_le->text ()), cy); lay::indicate_error (column_y_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (column_y_le, &ex); @@ -535,7 +535,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & } try { - tl::from_string (tl::to_string (row_x_le->text ()), rx); + tl::from_string_ext (tl::to_string (row_x_le->text ()), rx); lay::indicate_error (row_x_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (row_x_le, &ex); @@ -543,7 +543,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & } try { - tl::from_string (tl::to_string (row_y_le->text ()), ry); + tl::from_string_ext (tl::to_string (row_y_le->text ()), ry); lay::indicate_error (row_y_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (row_y_le, &ex); @@ -551,7 +551,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & } try { - tl::from_string (tl::to_string (rows_le->text ()), rows); + tl::from_string_ext (tl::to_string (rows_le->text ()), rows); if (rows < 1) { throw tl::Exception (tl::to_string (tr ("Rows count can't be zero"))); } @@ -562,7 +562,7 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & } try { - tl::from_string (tl::to_string (columns_le->text ()), cols); + tl::from_string_ext (tl::to_string (columns_le->text ()), cols); if (cols < 1) { throw tl::Exception (tl::to_string (tr ("Columns count can't be zero"))); } diff --git a/src/edt/edt/edtPCellParametersPage.cc b/src/edt/edt/edtPCellParametersPage.cc index 17c2bdada..4c15ca492 100644 --- a/src/edt/edt/edtPCellParametersPage.cc +++ b/src/edt/edt/edtPCellParametersPage.cc @@ -493,7 +493,7 @@ PCellParametersPage::get_parameters (bool *ok) try { int v = 0; - tl::from_string (tl::to_string (le->text ()), v); + tl::from_string_ext (tl::to_string (le->text ()), v); parameters.back () = tl::Variant (v); lay::indicate_error (le, (tl::Exception *) 0); @@ -517,7 +517,7 @@ PCellParametersPage::get_parameters (bool *ok) try { double v = 0; - tl::from_string (tl::to_string (le->text ()), v); + tl::from_string_ext (tl::to_string (le->text ()), v); parameters.back () = tl::Variant (v); lay::indicate_error (le, (tl::Exception *) 0); diff --git a/src/edt/edt/edtPropertiesPageUtils.cc b/src/edt/edt/edtPropertiesPageUtils.cc index e7bac7de7..8568dc382 100644 --- a/src/edt/edt/edtPropertiesPageUtils.cc +++ b/src/edt/edt/edtPropertiesPageUtils.cc @@ -768,7 +768,7 @@ db::DCoord dcoord_from_string (const char *txt, double dbu, bool du, const db::DCplxTrans &t) { double d = 0.0; - tl::from_string (txt, d); + tl::from_string_ext (txt, d); return dcoord_from_dcoord (d, dbu, du, t); } @@ -776,7 +776,7 @@ db::Coord coord_from_string (const char *txt, double dbu, bool du, const db::VCplxTrans &t) { double d = 0.0; - tl::from_string (txt, d); + tl::from_string_ext (txt, d); return coord_from_dcoord (d, dbu, du, t); } diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index b8a038291..bdb53086f 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -608,7 +608,7 @@ BoxPropertiesPage::get_box (int mode) const double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0; try { - tl::from_string (tl::to_string (x1_le_1->text ()), x1); + tl::from_string_ext (tl::to_string (x1_le_1->text ()), x1); lay::indicate_error (x1_le_1, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (x1_le_1, &ex); @@ -616,7 +616,7 @@ BoxPropertiesPage::get_box (int mode) const } try { - tl::from_string (tl::to_string (y1_le_1->text ()), y1); + tl::from_string_ext (tl::to_string (y1_le_1->text ()), y1); lay::indicate_error (y1_le_1, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (y1_le_1, &ex); @@ -624,7 +624,7 @@ BoxPropertiesPage::get_box (int mode) const } try { - tl::from_string (tl::to_string (x2_le_1->text ()), x2); + tl::from_string_ext (tl::to_string (x2_le_1->text ()), x2); lay::indicate_error (x2_le_1, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (x2_le_1, &ex); @@ -632,7 +632,7 @@ BoxPropertiesPage::get_box (int mode) const } try { - tl::from_string (tl::to_string (y2_le_1->text ()), y2); + tl::from_string_ext (tl::to_string (y2_le_1->text ()), y2); lay::indicate_error (y2_le_1, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (y2_le_1, &ex); @@ -668,7 +668,7 @@ BoxPropertiesPage::get_box (int mode) const double cx = 0.0, cy = 0.0, w = 0.0, h = 0.0; try { - tl::from_string (tl::to_string (cx_le_2->text ()), cx); + tl::from_string_ext (tl::to_string (cx_le_2->text ()), cx); lay::indicate_error (cx_le_2, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (cx_le_2, &ex); @@ -676,7 +676,7 @@ BoxPropertiesPage::get_box (int mode) const } try { - tl::from_string (tl::to_string (cy_le_2->text ()), cy); + tl::from_string_ext (tl::to_string (cy_le_2->text ()), cy); lay::indicate_error (cy_le_2, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (cy_le_2, &ex); @@ -684,7 +684,7 @@ BoxPropertiesPage::get_box (int mode) const } try { - tl::from_string (tl::to_string (w_le_2->text ()), w); + tl::from_string_ext (tl::to_string (w_le_2->text ()), w); lay::indicate_error (w_le_2, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (w_le_2, &ex); @@ -692,7 +692,7 @@ BoxPropertiesPage::get_box (int mode) const } try { - tl::from_string (tl::to_string (h_le_2->text ()), h); + tl::from_string_ext (tl::to_string (h_le_2->text ()), h); lay::indicate_error (h_le_2, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (h_le_2, &ex); @@ -833,7 +833,7 @@ TextPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Shape double x = 0.0, y = 0.0; try { - tl::from_string (tl::to_string (x_le->text ()), x); + tl::from_string_ext (tl::to_string (x_le->text ()), x); lay::indicate_error (x_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (x_le, &ex); @@ -841,7 +841,7 @@ TextPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Shape } try { - tl::from_string (tl::to_string (y_le->text ()), y); + tl::from_string_ext (tl::to_string (y_le->text ()), y); lay::indicate_error (y_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (y_le, &ex); diff --git a/src/img/img/imgPropertiesPage.cc b/src/img/img/imgPropertiesPage.cc index 751ea4eff..4623478ed 100644 --- a/src/img/img/imgPropertiesPage.cc +++ b/src/img/img/imgPropertiesPage.cc @@ -218,7 +218,7 @@ PropertiesPage::get_xmin_xmax (double &xmin, double &xmax, bool &has_error_out) bool has_error = false; try { - tl::from_string (tl::to_string (from_le->text ()), xmin); + tl::from_string_ext (tl::to_string (from_le->text ()), xmin); lay::indicate_error (from_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (from_le, &ex); @@ -226,7 +226,7 @@ PropertiesPage::get_xmin_xmax (double &xmin, double &xmax, bool &has_error_out) } try { - tl::from_string (tl::to_string (to_le->text ()), xmax); + tl::from_string_ext (tl::to_string (to_le->text ()), xmax); lay::indicate_error (to_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (to_le, &ex); @@ -335,7 +335,7 @@ PropertiesPage::value_changed () double x = 0.0; try { - tl::from_string (tl::to_string (value_le->text ()), x); + tl::from_string_ext (tl::to_string (value_le->text ()), x); lay::indicate_error (value_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (value_le, &ex); @@ -485,8 +485,8 @@ PropertiesPage::recompute_histogram () try { double xmin, xmax; - tl::from_string (tl::to_string (from_le->text ()), xmin); - tl::from_string (tl::to_string (to_le->text ()), xmax); + tl::from_string_ext (tl::to_string (from_le->text ()), xmin); + tl::from_string_ext (tl::to_string (to_le->text ()), xmax); if (xmin >= xmax) { throw tl::Exception (""); } @@ -801,7 +801,7 @@ PropertiesPage::apply () a = matrix.angle (), sa = matrix.shear_angle (), tx = matrix.perspective_tilt_x (z), ty = matrix.perspective_tilt_y (z); try { - tl::from_string (tl::to_string (width_le->text ()), w); + tl::from_string_ext (tl::to_string (width_le->text ()), w); if (w <= 0.0 || h <= 0.0) { throw tl::Exception (tl::to_string (QObject::tr ("Pixel width or height must be positive, non-null values"))); } @@ -812,7 +812,7 @@ PropertiesPage::apply () } try { - tl::from_string (tl::to_string (height_le->text ()), h); + tl::from_string_ext (tl::to_string (height_le->text ()), h); lay::indicate_error (height_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (height_le, &ex); @@ -820,7 +820,7 @@ PropertiesPage::apply () } try { - tl::from_string (tl::to_string (x_offset_le->text ()), x); + tl::from_string_ext (tl::to_string (x_offset_le->text ()), x); lay::indicate_error (x_offset_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (x_offset_le, &ex); @@ -828,7 +828,7 @@ PropertiesPage::apply () } try { - tl::from_string (tl::to_string (y_offset_le->text ()), y); + tl::from_string_ext (tl::to_string (y_offset_le->text ()), y); lay::indicate_error (y_offset_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (y_offset_le, &ex); @@ -836,7 +836,7 @@ PropertiesPage::apply () } try { - tl::from_string (tl::to_string (angle_le->text ()), a); + tl::from_string_ext (tl::to_string (angle_le->text ()), a); lay::indicate_error (angle_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (angle_le, &ex); @@ -844,7 +844,7 @@ PropertiesPage::apply () } try { - tl::from_string (tl::to_string (shear_le->text ()), sa); + tl::from_string_ext (tl::to_string (shear_le->text ()), sa); if (sa <= -45 || sa >= 45) { throw tl::Exception (tl::to_string (QObject::tr ("The shear angle must be larger than -45 and less than 45 degree"))); } @@ -855,7 +855,7 @@ PropertiesPage::apply () } try { - tl::from_string (tl::to_string (persp_tx_le->text ()), tx); + tl::from_string_ext (tl::to_string (persp_tx_le->text ()), tx); if (tx <= -90 || tx >= 90) { throw tl::Exception (tl::to_string (QObject::tr ("The perspective tilt angles must be larger than -90 and less than 90 degree"))); } @@ -866,7 +866,7 @@ PropertiesPage::apply () } try { - tl::from_string (tl::to_string (persp_ty_le->text ()), ty); + tl::from_string_ext (tl::to_string (persp_ty_le->text ()), ty); if (ty <= -90 || ty >= 90) { throw tl::Exception (tl::to_string (QObject::tr ("The perspective tilt angles must be larger than -90 and less than 90 degree"))); } diff --git a/src/lay/lay/layClipDialog.cc b/src/lay/lay/layClipDialog.cc index ef574c46f..c124914c2 100644 --- a/src/lay/lay/layClipDialog.cc +++ b/src/lay/lay/layClipDialog.cc @@ -125,10 +125,10 @@ BEGIN_PROTECTED double x1 = 0.0, y1 = 0.0; double x2 = 0.0, y2 = 0.0; - tl::from_string (tl::to_string (le_x1->text ()), x1); - tl::from_string (tl::to_string (le_x2->text ()), x2); - tl::from_string (tl::to_string (le_y1->text ()), y1); - tl::from_string (tl::to_string (le_y2->text ()), y2); + tl::from_string_ext (tl::to_string (le_x1->text ()), x1); + tl::from_string_ext (tl::to_string (le_x2->text ()), x2); + tl::from_string_ext (tl::to_string (le_y1->text ()), y1); + tl::from_string_ext (tl::to_string (le_y2->text ()), y2); clip_boxes.push_back (db::Box (db::DBox (db::DPoint (x1, y1), db::DPoint (x2, y2)) * (1.0 / cv->layout ().dbu ()))); @@ -141,10 +141,10 @@ BEGIN_PROTECTED double x = 0.0, y = 0.0; double w = 0.0, h = 0.0; - tl::from_string (tl::to_string (le_x->text ()), x); - tl::from_string (tl::to_string (le_y->text ()), y); - tl::from_string (tl::to_string (le_w->text ()), w); - tl::from_string (tl::to_string (le_h->text ()), h); + tl::from_string_ext (tl::to_string (le_x->text ()), x); + tl::from_string_ext (tl::to_string (le_y->text ()), y); + tl::from_string_ext (tl::to_string (le_w->text ()), w); + tl::from_string_ext (tl::to_string (le_h->text ()), h); clip_boxes.push_back (db::Box (db::DBox (db::DPoint (x - 0.5 * w, y - 0.5 * h), db::DPoint (x + 0.5 * w, y + 0.5 * h)) * (1.0 / cv->layout ().dbu ()))); diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index b9b6458e1..d829436db 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -354,10 +354,10 @@ FillDialog::get_fill_parameters () double x1 = 0.0, y1 = 0.0; double x2 = 0.0, y2 = 0.0; - tl::from_string (tl::to_string (le_x1->text ()), x1); - tl::from_string (tl::to_string (le_x2->text ()), x2); - tl::from_string (tl::to_string (le_y1->text ()), y1); - tl::from_string (tl::to_string (le_y2->text ()), y2); + tl::from_string_ext (tl::to_string (le_x1->text ()), x1); + tl::from_string_ext (tl::to_string (le_x2->text ()), x2); + tl::from_string_ext (tl::to_string (le_y1->text ()), y1); + tl::from_string_ext (tl::to_string (le_y2->text ()), y2); fp.fill_region.insert (db::Box (db::DBox (db::DPoint (x1, y1), db::DPoint (x2, y2)) * (1.0 / cv->layout ().dbu ()))); diff --git a/src/lay/lay/laySearchReplaceConfigPage.cc b/src/lay/lay/laySearchReplaceConfigPage.cc index a48f8b6b4..618806f87 100644 --- a/src/lay/lay/laySearchReplaceConfigPage.cc +++ b/src/lay/lay/laySearchReplaceConfigPage.cc @@ -110,10 +110,10 @@ void SearchReplaceConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (le_window->text ()), dim); unsigned int max_item_count = 1000; - tl::from_string (tl::to_string (le_max_items->text ()), max_item_count); + tl::from_string_ext (tl::to_string (le_max_items->text ()), max_item_count); root->config_set (cfg_sr_window_mode, SearchReplaceDialog::window_type (cbx_window->currentIndex ()), SearchReplaceWindowModeConverter ()); root->config_set (cfg_sr_window_dim, dim); diff --git a/src/lay/lay/layTechSetupDialog.cc b/src/lay/lay/layTechSetupDialog.cc index 17c7ef644..20ebb8261 100644 --- a/src/lay/lay/layTechSetupDialog.cc +++ b/src/lay/lay/layTechSetupDialog.cc @@ -166,7 +166,7 @@ TechBaseEditorPage::commit () tech ()->set_explicit_base_path (tl::to_string (mp_ui->base_path_le->text ())); double d = 0.001; - tl::from_string (tl::to_string (mp_ui->dbu_le->text ()), d); + tl::from_string_ext (tl::to_string (mp_ui->dbu_le->text ()), d); tech ()->set_dbu (d); if (! mp_ui->lyp_grp->isChecked ()) { diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.cc b/src/laybasic/laybasic/layBrowseInstancesForm.cc index a60da628a..b2628de09 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.cc +++ b/src/laybasic/laybasic/layBrowseInstancesForm.cc @@ -224,10 +224,10 @@ void BrowseInstancesConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (le_window->text ()), dim); unsigned int max_inst_count = 1000; - tl::from_string (tl::to_string (le_max_count->text ()), max_inst_count); + tl::from_string_ext (tl::to_string (le_max_count->text ()), max_inst_count); root->config_set (cfg_cib_context_cell, tl::to_string (le_cell_name->text ())); root->config_set (cfg_cib_context_mode, BrowseInstancesForm::mode_type (cbx_context->currentIndex ()), BrowseInstancesContextModeConverter ()); diff --git a/src/laybasic/laybasic/layBrowseShapesForm.cc b/src/laybasic/laybasic/layBrowseShapesForm.cc index 05b413b5d..a53b3911a 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.cc +++ b/src/laybasic/laybasic/layBrowseShapesForm.cc @@ -231,13 +231,13 @@ void BrowseShapesConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (le_window->text ()), dim); unsigned int max_inst_count = 1000; - tl::from_string (tl::to_string (le_max_inst->text ()), max_inst_count); + tl::from_string_ext (tl::to_string (le_max_inst->text ()), max_inst_count); unsigned int max_shape_count = 1000; - tl::from_string (tl::to_string (le_max_shapes->text ()), max_shape_count); + tl::from_string_ext (tl::to_string (le_max_shapes->text ()), max_shape_count); root->config_set (cfg_shb_context_cell, tl::to_string (le_cell_name->text ())); root->config_set (cfg_shb_context_mode, BrowseShapesForm::mode_type (cbx_context->currentIndex ()), BrowseShapesContextModeConverter ()); diff --git a/src/laybasic/laybasic/layDialogs.cc b/src/laybasic/laybasic/layDialogs.cc index c00c4d262..dff4f4136 100644 --- a/src/laybasic/laybasic/layDialogs.cc +++ b/src/laybasic/laybasic/layDialogs.cc @@ -170,9 +170,9 @@ NewLayoutPropertiesDialog::exec_dialog (std::string &technology, std::string &ce technology = std::string (); } - tl::from_string (tl::to_string (mp_ui->window_le->text ()), size); + tl::from_string_ext (tl::to_string (mp_ui->window_le->text ()), size); if (! mp_ui->dbu_le->text ().isEmpty ()) { - tl::from_string (tl::to_string (mp_ui->dbu_le->text ()), dbu); + tl::from_string_ext (tl::to_string (mp_ui->dbu_le->text ()), dbu); } else { dbu = 0.0; } @@ -207,9 +207,9 @@ NewLayoutPropertiesDialog::accept () BEGIN_PROTECTED; double x = 0.0; - tl::from_string (tl::to_string (mp_ui->window_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->window_le->text ()), x); if (!mp_ui->dbu_le->text ().isEmpty ()) { - tl::from_string (tl::to_string (mp_ui->dbu_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->dbu_le->text ()), x); } if (mp_ui->topcell_le->text ().isEmpty ()) { @@ -250,7 +250,7 @@ NewCellPropertiesDialog::exec_dialog (const db::Layout *layout, std::string &cel if (QDialog::exec ()) { - tl::from_string (tl::to_string (mp_ui->window_le->text ()), size); + tl::from_string_ext (tl::to_string (mp_ui->window_le->text ()), size); cell_name = tl::to_string (mp_ui->name_le->text ()); return true; @@ -265,7 +265,7 @@ NewCellPropertiesDialog::accept () BEGIN_PROTECTED; double x = 0.0; - tl::from_string (tl::to_string (mp_ui->window_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->window_le->text ()), x); if (mp_layout->cell_by_name (tl::to_string (mp_ui->name_le->text ()).c_str ()).first) { throw tl::Exception (tl::to_string (QObject::tr ("A cell with that name already exists: %s")), tl::to_string (mp_ui->name_le->text ())); @@ -335,14 +335,14 @@ NewLayerPropertiesDialog::get (db::LayerProperties &src) { if (! mp_ui->layer_le->text ().isEmpty ()) { int l = -1; - tl::from_string (tl::to_string (mp_ui->layer_le->text ()), l); + tl::from_string_ext (tl::to_string (mp_ui->layer_le->text ()), l); src.layer = l; } else { src.layer = -1; } if (! mp_ui->datatype_le->text ().isEmpty ()) { int d = -1; - tl::from_string (tl::to_string (mp_ui->datatype_le->text ()), d); + tl::from_string_ext (tl::to_string (mp_ui->datatype_le->text ()), d); src.datatype = d; } else { src.datatype = -1; @@ -395,8 +395,8 @@ MoveOptionsDialog::exec_dialog (db::DVector &disp) if (QDialog::exec ()) { double x = 0.0, y = 0.0; - tl::from_string (tl::to_string (mp_ui->disp_x_le->text ()), x); - tl::from_string (tl::to_string (mp_ui->disp_y_le->text ()), y); + tl::from_string_ext (tl::to_string (mp_ui->disp_x_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->disp_y_le->text ()), y); disp = db::DVector (x, y); @@ -412,8 +412,8 @@ MoveOptionsDialog::accept () { BEGIN_PROTECTED; double x = 0.0; - tl::from_string (tl::to_string (mp_ui->disp_x_le->text ()), x); - tl::from_string (tl::to_string (mp_ui->disp_y_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->disp_x_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->disp_y_le->text ()), x); QDialog::accept (); END_PROTECTED; } @@ -470,8 +470,8 @@ MoveToOptionsDialog::exec_dialog (int &mode_x, int &mode_y, db::DPoint &target) } double x = 0.0, y = 0.0; - tl::from_string (tl::to_string (mp_ui->x_le->text ()), x); - tl::from_string (tl::to_string (mp_ui->y_le->text ()), y); + tl::from_string_ext (tl::to_string (mp_ui->x_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->y_le->text ()), y); target = db::DPoint (x, y); @@ -487,8 +487,8 @@ MoveToOptionsDialog::accept () { BEGIN_PROTECTED; double x = 0.0; - tl::from_string (tl::to_string (mp_ui->x_le->text ()), x); - tl::from_string (tl::to_string (mp_ui->y_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->x_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->y_le->text ()), x); QDialog::accept (); END_PROTECTED; } @@ -955,8 +955,8 @@ AlignCellOptionsDialog::exec_dialog (AlignCellOptions &data) } } - tl::from_string (tl::to_string (mp_ui->x_le->text ()), data.xpos); - tl::from_string (tl::to_string (mp_ui->y_le->text ()), data.ypos); + tl::from_string_ext (tl::to_string (mp_ui->x_le->text ()), data.xpos); + tl::from_string_ext (tl::to_string (mp_ui->y_le->text ()), data.ypos); return true; @@ -971,8 +971,8 @@ AlignCellOptionsDialog::accept () BEGIN_PROTECTED; double x = 0.0; - tl::from_string (tl::to_string (mp_ui->x_le->text ()), x); - tl::from_string (tl::to_string (mp_ui->y_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->x_le->text ()), x); + tl::from_string_ext (tl::to_string (mp_ui->y_le->text ()), x); QDialog::accept (); diff --git a/src/laybasic/laybasic/layEditorOptionsPages.cc b/src/laybasic/laybasic/layEditorOptionsPages.cc index eaac5cd8c..5ab7e9bd2 100644 --- a/src/laybasic/laybasic/layEditorOptionsPages.cc +++ b/src/laybasic/laybasic/layEditorOptionsPages.cc @@ -204,7 +204,7 @@ static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le { try { Value value = Value (0); - tl::from_string (tl::to_string (le->text ()), value); + tl::from_string_ext (tl::to_string (le->text ()), value); dispatcher->config_set (cfg_name, tl::to_string (value)); lay::indicate_error (le, (tl::Exception *) 0); } catch (tl::Exception &ex) { diff --git a/src/laybasic/laybasic/layLayoutPropertiesForm.cc b/src/laybasic/laybasic/layLayoutPropertiesForm.cc index b02913317..ab7d0e1e0 100644 --- a/src/laybasic/laybasic/layLayoutPropertiesForm.cc +++ b/src/laybasic/laybasic/layLayoutPropertiesForm.cc @@ -96,7 +96,7 @@ LayoutPropertiesForm::commit () // get the database unit double dbu = 0.001; - tl::from_string (tl::to_string (dbu_le->text ()), dbu); + tl::from_string_ext (tl::to_string (dbu_le->text ()), dbu); if (dbu < 1e-6 || dbu > 1e3) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid database unit"))); } diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.cc b/src/laybasic/laybasic/layLayoutViewConfigPages.cc index 9f5bc1ec0..f400787fc 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.cc +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.cc @@ -170,7 +170,7 @@ LayoutViewConfigPage1::commit (lay::Dispatcher *root) root->config_set (cfg_abstract_mode_enabled, mp_ui->abstract_mode_grp->isChecked ()); double w = 10.0; - tl::from_string (tl::to_string (mp_ui->abstract_mode_width_le->text ()), w); + tl::from_string_ext (tl::to_string (mp_ui->abstract_mode_width_le->text ()), w); root->config_set (cfg_abstract_mode_width, w); if (w <= 0.0) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid abstract mode border with - must be larger than 0"))); @@ -254,7 +254,7 @@ LayoutViewConfigPage2a::commit (lay::Dispatcher *root) try { int n; - tl::from_string (tl::to_string (mp_ui->cell_min_size_for_label_edit->text ()), n); + tl::from_string_ext (tl::to_string (mp_ui->cell_min_size_for_label_edit->text ()), n); root->config_set (cfg_min_inst_label_size, n); } catch (...) { } } @@ -319,7 +319,7 @@ LayoutViewConfigPage2b::commit (lay::Dispatcher *root) try { double s; - tl::from_string (tl::to_string (mp_ui->text_def_size_edit->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->text_def_size_edit->text ()), s); root->config_set (cfg_default_text_size, s); } catch (...) { } } @@ -511,7 +511,7 @@ LayoutViewConfigPage3b::commit (lay::Dispatcher *root) double pd = 0.0; try { - tl::from_string (tl::to_string (mp_ui->pan_distance_le->text ()), pd); + tl::from_string_ext (tl::to_string (mp_ui->pan_distance_le->text ()), pd); } catch (...) { } if (pd <= 0.0) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid pan distance: must be larger than 0.0"))); @@ -619,7 +619,7 @@ LayoutViewConfigPage3f::commit (lay::Dispatcher *root) try { unsigned int s; - tl::from_string (tl::to_string (mp_ui->drop_small_cells_value_le->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->drop_small_cells_value_le->text ()), s); root->config_set (cfg_drop_small_cells_value, s); } catch (...) { } diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/laybasic/laybasic/layLayoutViewFunctions.cc index 28ed82c32..a8b739a4b 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/laybasic/laybasic/layLayoutViewFunctions.cc @@ -1423,7 +1423,7 @@ LayoutViewFunctions::cm_lay_free_rot () if (ok) { double angle = 0.0; - tl::from_string (tl::to_string (s), angle); + tl::from_string_ext (tl::to_string (s), angle); transform_layout (db::DCplxTrans (1.0, angle, false, db::DVector ())); @@ -1443,7 +1443,7 @@ LayoutViewFunctions::cm_lay_scale () if (ok) { double scale = 0.0; - tl::from_string (tl::to_string (s), scale); + tl::from_string_ext (tl::to_string (s), scale); transform_layout (db::DCplxTrans (scale)); @@ -1516,7 +1516,7 @@ LayoutViewFunctions::cm_sel_free_rot () if (ok) { double angle = 0.0; - tl::from_string (tl::to_string (s), angle); + tl::from_string_ext (tl::to_string (s), angle); db::DCplxTrans tr = db::DCplxTrans (1.0, angle, false, db::DVector ()); db::DBox sel_bbox (view ()->lay::Editables::selection_bbox ()); @@ -1541,7 +1541,7 @@ LayoutViewFunctions::cm_sel_scale () if (ok) { double scale = 0.0; - tl::from_string (tl::to_string (s), scale); + tl::from_string_ext (tl::to_string (s), scale); db::DCplxTrans tr = db::DCplxTrans (scale); db::DBox sel_bbox (view ()->lay::Editables::selection_bbox ()); diff --git a/src/laybasic/laybasic/layNetExportDialog.cc b/src/laybasic/laybasic/layNetExportDialog.cc index 4e5471347..ae89eabe1 100644 --- a/src/laybasic/laybasic/layNetExportDialog.cc +++ b/src/laybasic/laybasic/layNetExportDialog.cc @@ -151,7 +151,7 @@ int NetExportDialog::start_layer_number () { int ln = 0; - tl::from_string (tl::to_string (ui->layernum->text ()), ln); + tl::from_string_ext (tl::to_string (ui->layernum->text ()), ln); return ln; } diff --git a/src/laybasic/laybasic/layNetlistBrowser.cc b/src/laybasic/laybasic/layNetlistBrowser.cc index e6b8a7407..b923ca95f 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.cc +++ b/src/laybasic/laybasic/layNetlistBrowser.cc @@ -136,10 +136,10 @@ void NetlistBrowserConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (le_window->text ()), dim); unsigned int max_shapes_highlighted = 10000; - tl::from_string (tl::to_string (le_max_markers->text ()), max_shapes_highlighted); + tl::from_string_ext (tl::to_string (le_max_markers->text ()), max_shapes_highlighted); root->config_set (cfg_l2ndb_window_mode, lay::NetlistBrowserConfig::net_window_type (cbx_window->currentIndex ()), NetlistBrowserWindowModeConverter ()); root->config_set (cfg_l2ndb_window_dim, dim); @@ -300,7 +300,7 @@ NetlistBrowserConfigPage2::commit (lay::Dispatcher *root) } else { try { int s; - tl::from_string (tl::to_string (lw_le->text ()), s); + tl::from_string_ext (tl::to_string (lw_le->text ()), s); root->config_set (cfg_l2ndb_marker_line_width, s); } catch (...) { } } @@ -310,7 +310,7 @@ NetlistBrowserConfigPage2::commit (lay::Dispatcher *root) } else { try { int s; - tl::from_string (tl::to_string (vs_le->text ()), s); + tl::from_string_ext (tl::to_string (vs_le->text ()), s); root->config_set (cfg_l2ndb_marker_vertex_size, s); } catch (...) { } } diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc index 174832042..4284f7a96 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc +++ b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc @@ -396,8 +396,8 @@ SaveLayoutAsOptionsDialog::ok_button_pressed () } double x = 0.0; - tl::from_string (tl::to_string (dbu_le->text ()), x); - tl::from_string (tl::to_string (sf_le->text ()), x); + tl::from_string_ext (tl::to_string (dbu_le->text ()), x); + tl::from_string_ext (tl::to_string (sf_le->text ()), x); accept (); @@ -475,10 +475,10 @@ SaveLayoutAsOptionsDialog::get_options (lay::LayoutView *view, unsigned int cv_i } double dbu = 0.0; - tl::from_string (tl::to_string (dbu_le->text ()), dbu); + tl::from_string_ext (tl::to_string (dbu_le->text ()), dbu); double sf = 1.0; - tl::from_string (tl::to_string (sf_le->text ()), sf); + tl::from_string_ext (tl::to_string (sf_le->text ()), sf); options.set_dbu (dbu); options.set_scale_factor (sf); diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.cc b/src/laybasic/laybasic/rdbMarkerBrowser.cc index d787c2e59..6e8479835 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowser.cc @@ -170,10 +170,10 @@ void MarkerBrowserConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (le_window->text ()), dim); unsigned int max_markers_count = 1000; - tl::from_string (tl::to_string (le_max_markers->text ()), max_markers_count); + tl::from_string_ext (tl::to_string (le_max_markers->text ()), max_markers_count); root->config_set (cfg_rdb_context_mode, rdb::context_mode_type (cbx_context->currentIndex ()), MarkerBrowserContextModeConverter ()); root->config_set (cfg_rdb_window_mode, rdb::window_type (cbx_window->currentIndex ()), MarkerBrowserWindowModeConverter ()); @@ -238,7 +238,7 @@ MarkerBrowserConfigPage2::commit (lay::Dispatcher *root) } else { try { int s; - tl::from_string (tl::to_string (lw_le->text ()), s); + tl::from_string_ext (tl::to_string (lw_le->text ()), s); root->config_set (cfg_rdb_marker_line_width, s); } catch (...) { } } @@ -248,7 +248,7 @@ MarkerBrowserConfigPage2::commit (lay::Dispatcher *root) } else { try { int s; - tl::from_string (tl::to_string (vs_le->text ()), s); + tl::from_string_ext (tl::to_string (vs_le->text ()), s); root->config_set (cfg_rdb_marker_vertex_size, s); } catch (...) { } } diff --git a/src/plugins/streamers/cif/lay_plugin/layCIFReaderPlugin.cc b/src/plugins/streamers/cif/lay_plugin/layCIFReaderPlugin.cc index 9113b3bec..dec33b469 100644 --- a/src/plugins/streamers/cif/lay_plugin/layCIFReaderPlugin.cc +++ b/src/plugins/streamers/cif/lay_plugin/layCIFReaderPlugin.cc @@ -69,7 +69,7 @@ CIFReaderOptionPage::commit (db::FormatSpecificReaderOptions *o, const db::Techn { db::CIFReaderOptions *options = dynamic_cast (o); if (options) { - tl::from_string (tl::to_string (mp_ui->dbu_le->text ()), options->dbu); + tl::from_string_ext (tl::to_string (mp_ui->dbu_le->text ()), options->dbu); if (options->dbu > 1000.0 || options->dbu < 1e-9) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid value for database unit"))); } diff --git a/src/plugins/streamers/dxf/lay_plugin/layDXFReaderPlugin.cc b/src/plugins/streamers/dxf/lay_plugin/layDXFReaderPlugin.cc index 9e5da3281..6607019e3 100644 --- a/src/plugins/streamers/dxf/lay_plugin/layDXFReaderPlugin.cc +++ b/src/plugins/streamers/dxf/lay_plugin/layDXFReaderPlugin.cc @@ -75,24 +75,24 @@ DXFReaderOptionPage::commit (db::FormatSpecificReaderOptions *o, const db::Techn { db::DXFReaderOptions *options = dynamic_cast (o); if (options) { - tl::from_string (tl::to_string (mp_ui->dbu_le->text ()), options->dbu); + tl::from_string_ext (tl::to_string (mp_ui->dbu_le->text ()), options->dbu); if (options->dbu > 1000.0 || options->dbu < 1e-9) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid value for database unit"))); } - tl::from_string (tl::to_string (mp_ui->unit_le->text ()), options->unit); + tl::from_string_ext (tl::to_string (mp_ui->unit_le->text ()), options->unit); if (options->unit > 1e9 || options->unit < 1e-9) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid value for the unit"))); } - tl::from_string (tl::to_string (mp_ui->text_scaling_le->text ()), options->text_scaling); + tl::from_string_ext (tl::to_string (mp_ui->text_scaling_le->text ()), options->text_scaling); if (options->text_scaling > 10000 || options->text_scaling < 1) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid value for the text scaling"))); } - tl::from_string (tl::to_string(mp_ui->circle_points_le->text ()), options->circle_points); + tl::from_string_ext (tl::to_string(mp_ui->circle_points_le->text ()), options->circle_points); if (options->circle_points < 4 || options->circle_points > 1000000) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid value for the number of points for arc interpolation"))); } - tl::from_string (tl::to_string(mp_ui->circle_accuracy_le->text ()), options->circle_accuracy); - tl::from_string (tl::to_string(mp_ui->contour_accuracy_le->text ()), options->contour_accuracy); + tl::from_string_ext (tl::to_string(mp_ui->circle_accuracy_le->text ()), options->circle_accuracy); + tl::from_string_ext (tl::to_string(mp_ui->contour_accuracy_le->text ()), options->contour_accuracy); options->polyline_mode = mp_ui->polyline2poly_cbx->currentIndex (); options->render_texts_as_polygons = mp_ui->render_texts_as_polygons_cbx->isChecked (); options->keep_other_cells = mp_ui->keep_other_cells_cbx->isChecked (); diff --git a/src/plugins/streamers/gds2/lay_plugin/layGDS2WriterPlugin.cc b/src/plugins/streamers/gds2/lay_plugin/layGDS2WriterPlugin.cc index 948b211a7..1603adbbe 100644 --- a/src/plugins/streamers/gds2/lay_plugin/layGDS2WriterPlugin.cc +++ b/src/plugins/streamers/gds2/lay_plugin/layGDS2WriterPlugin.cc @@ -83,7 +83,7 @@ GDS2WriterOptionPage::commit (db::FormatSpecificWriterOptions *o, const db::Tech options->write_file_properties = mp_ui->write_file_properties->isChecked (); options->no_zero_length_paths = mp_ui->no_zero_length_paths->isChecked (); - tl::from_string (tl::to_string (mp_ui->max_vertex_le->text ()), n); + tl::from_string_ext (tl::to_string (mp_ui->max_vertex_le->text ()), n); if (! options->multi_xy_records) { if (n > 8191) { throw tl::Exception (tl::to_string (QObject::tr ("Maximum number of vertices must not exceed 8191"))); @@ -95,7 +95,7 @@ GDS2WriterOptionPage::commit (db::FormatSpecificWriterOptions *o, const db::Tech options->max_vertex_count = n; n = 32000; - tl::from_string (tl::to_string (mp_ui->cell_name_length_le->text ()), n); + tl::from_string_ext (tl::to_string (mp_ui->cell_name_length_le->text ()), n); if (n > 32000) { throw tl::Exception (tl::to_string (QObject::tr ("Maximum cell name length must not exceed 32000"))); } diff --git a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc index 744dab2f0..e043a1d59 100644 --- a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc +++ b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc @@ -391,7 +391,7 @@ LEFDEFReaderOptionsEditor::commit (db::FormatSpecificReaderOptions *options, con data->set_produce_pin_names (produce_pin_names->isChecked ()); double dbu_value = 0.0; - tl::from_string (tl::to_string (dbu->text ()), dbu_value); + tl::from_string_ext (tl::to_string (dbu->text ()), dbu_value); if (dbu_value < 1e-7) { throw tl::Exception (tl::to_string (tr ("Invalid database unit value (must be non-null and positive)"))); } diff --git a/src/plugins/streamers/magic/lay_plugin/layMAGReaderPlugin.cc b/src/plugins/streamers/magic/lay_plugin/layMAGReaderPlugin.cc index bb6f40cab..18b11bbf7 100644 --- a/src/plugins/streamers/magic/lay_plugin/layMAGReaderPlugin.cc +++ b/src/plugins/streamers/magic/lay_plugin/layMAGReaderPlugin.cc @@ -80,12 +80,12 @@ MAGReaderOptionPage::commit (db::FormatSpecificReaderOptions *o, const db::Techn db::MAGReaderOptions *options = dynamic_cast (o); if (options) { - tl::from_string (tl::to_string (mp_ui->dbu_le->text ()), options->dbu); + tl::from_string_ext (tl::to_string (mp_ui->dbu_le->text ()), options->dbu); if (options->dbu > 1000.0 || options->dbu < 1e-9) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid value for database unit"))); } - tl::from_string (tl::to_string (mp_ui->lambda_le->text ()), options->lambda); + tl::from_string_ext (tl::to_string (mp_ui->lambda_le->text ()), options->lambda); if (options->lambda > 10000000.0 || options->lambda < 1e-9) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid value for lambda"))); } diff --git a/src/plugins/streamers/magic/lay_plugin/layMAGWriterPlugin.cc b/src/plugins/streamers/magic/lay_plugin/layMAGWriterPlugin.cc index 4cd261947..d1c0e77bf 100644 --- a/src/plugins/streamers/magic/lay_plugin/layMAGWriterPlugin.cc +++ b/src/plugins/streamers/magic/lay_plugin/layMAGWriterPlugin.cc @@ -73,7 +73,7 @@ MAGWriterOptionPage::commit (db::FormatSpecificWriterOptions *o, const db::Techn QString l = mp_ui->lambda_le->text ().trimmed (); options->lambda = 0.0; if (! l.isEmpty ()) { - tl::from_string (tl::to_string (l), options->lambda); + tl::from_string_ext (tl::to_string (l), options->lambda); } options->tech = tl::to_string (mp_ui->tech_le->text ().trimmed ()); options->write_timestamp = ! mp_ui->zero_ts_cbx->isChecked (); diff --git a/src/plugins/streamers/pcb/lay_plugin/layGerberImportDialog.cc b/src/plugins/streamers/pcb/lay_plugin/layGerberImportDialog.cc index d0db6825c..17a9e086f 100644 --- a/src/plugins/streamers/pcb/lay_plugin/layGerberImportDialog.cc +++ b/src/plugins/streamers/pcb/lay_plugin/layGerberImportDialog.cc @@ -1024,8 +1024,8 @@ GerberImportDialog::commit_page () mp_data->num_metal_layers = -1; mp_data->num_via_types = -1; - tl::from_string (tl::to_string (mp_ui->num_metal_le->text ()), mp_data->num_metal_layers); - tl::from_string (tl::to_string (mp_ui->num_via_le->text ()), mp_data->num_via_types); + tl::from_string_ext (tl::to_string (mp_ui->num_metal_le->text ()), mp_data->num_metal_layers); + tl::from_string_ext (tl::to_string (mp_ui->num_via_le->text ()), mp_data->num_via_types); if (mp_data->num_metal_layers < 0) { throw tl::Exception (tl::to_string (QObject::tr ("Invalid number of metal layers"))); @@ -1297,12 +1297,12 @@ GerberImportDialog::commit_page () mp_data->merge_flag = mp_ui->merge_cb->isChecked (); mp_data->invert_negative_layers = mp_ui->invert_cb->isChecked (); - tl::from_string (tl::to_string (mp_ui->border_le->text ()), mp_data->border); + tl::from_string_ext (tl::to_string (mp_ui->border_le->text ()), mp_data->border); bool import_into = (mp_data->mode == db::GerberImportData::ModeIntoLayout); if (! import_into) { - tl::from_string (tl::to_string (mp_ui->dbu_le->text ()), mp_data->dbu); + tl::from_string_ext (tl::to_string (mp_ui->dbu_le->text ()), mp_data->dbu); if (mp_data->dbu < 1e-6) { throw tl::Exception (tl::to_string (QObject::tr ("Database unit must not be negative or zero"))); } diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.cc index 7f38298ff..cee0e33ad 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.cc @@ -242,10 +242,10 @@ void NetTracerConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (le_window->text ()), dim); unsigned int max_shapes_highlighted = 10000; - tl::from_string (tl::to_string (le_max_markers->text ()), max_shapes_highlighted); + tl::from_string_ext (tl::to_string (le_max_markers->text ()), max_shapes_highlighted); root->config_set (cfg_nt_window_mode, lay::nt_window_type (cbx_window->currentIndex ()), NetTracerWindowModeConverter ()); root->config_set (cfg_nt_window_dim, dim); @@ -262,7 +262,7 @@ NetTracerConfigPage::commit (lay::Dispatcher *root) } else { try { int s; - tl::from_string (tl::to_string (lw_le->text ()), s); + tl::from_string_ext (tl::to_string (lw_le->text ()), s); root->config_set (cfg_nt_marker_line_width, s); } catch (...) { } } @@ -272,7 +272,7 @@ NetTracerConfigPage::commit (lay::Dispatcher *root) } else { try { int s; - tl::from_string (tl::to_string (vs_le->text ()), s); + tl::from_string_ext (tl::to_string (vs_le->text ()), s); root->config_set (cfg_nt_marker_vertex_size, s); } catch (...) { } } diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc index 7f4006ee4..9668a6a63 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc @@ -1427,7 +1427,7 @@ NetTracerDialog::get_trace_depth() try { QString depth = depth_le->text ().trimmed (); if (! depth.isEmpty ()) { - tl::from_string (tl::to_string (depth), n); + tl::from_string_ext (tl::to_string (depth), n); if (n < 0 || n > double (std::numeric_limits::max ())) { n = 0.0; } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc index 603136699..a8aef4b3d 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc @@ -132,7 +132,7 @@ D25View::scale_value_edited () { double f = mp_ui->d25_view->scale_factor (); try { - tl::from_string (tl::to_string (mp_ui->zoom_factor->text ()), f); + tl::from_string_ext (tl::to_string (mp_ui->zoom_factor->text ()), f); f = std::min (1e6, std::max (1e-6, f)); } catch (...) { // ignore exceptions @@ -146,7 +146,7 @@ D25View::vscale_value_edited () { double f = mp_ui->d25_view->vscale_factor (); try { - tl::from_string (tl::to_string (mp_ui->vzoom_factor->text ()), f); + tl::from_string_ext (tl::to_string (mp_ui->vzoom_factor->text ()), f); f = std::min (1e6, std::max (1e-6, f)); } catch (...) { // ignore exceptions diff --git a/src/tl/tl/tlExpression.cc b/src/tl/tl/tlExpression.cc index a00dbefd1..b7fb623a8 100644 --- a/src/tl/tl/tlExpression.cc +++ b/src/tl/tl/tlExpression.cc @@ -2916,6 +2916,7 @@ printf_f (const ExpressionParserContext &context, tl::Variant &, const std::vect } std::cout << tl::sprintf (vv[0].to_string (), vv, 1); + std::cout.flush (); } // ---------------------------------------------------------------------------- @@ -3125,10 +3126,16 @@ Expression::execute (EvalTarget &v) const // ---------------------------------------------------------------------------- // Implementation of Eval -Eval Eval::m_global; +Eval Eval::m_global (0, 0, false); Eval::Eval (Eval *parent, bool sloppy) - : mp_parent (parent), m_sloppy (sloppy), mp_ctx_handler (0) + : mp_parent (parent), mp_global (&Eval::m_global), m_sloppy (sloppy), mp_ctx_handler (0) +{ + // .. nothing yet .. +} + +Eval::Eval (Eval *global, Eval *parent, bool sloppy) + : mp_parent (parent), mp_global (global), m_sloppy (sloppy), mp_ctx_handler (0) { // .. nothing yet .. } @@ -3958,8 +3965,8 @@ Eval::resolve_name (const std::string &t, const EvalFunction *&function, const t if (! function && ! value && ! var) { if (mp_parent) { mp_parent->resolve_name (t, function, value, var); - } else if (this != &m_global) { - m_global.resolve_name (t, function, value, var); + } else if (mp_global) { + mp_global->resolve_name (t, function, value, var); } } } diff --git a/src/tl/tl/tlExpression.h b/src/tl/tl/tlExpression.h index 325f11914..e67877828 100644 --- a/src/tl/tl/tlExpression.h +++ b/src/tl/tl/tlExpression.h @@ -367,7 +367,16 @@ public: * @param parent The parent evaluation context * @param sloppy True to enable sloppy evaluation for pure parsing */ - Eval (Eval *parent = 0, bool sloppy = false); + explicit Eval (Eval *parent = 0, bool sloppy = false); + + /** + * @brief Create a new object for expression evaluation + * + * @param global The global evaluation context + * @param parent The parent evaluation context + * @param sloppy True to enable sloppy evaluation for pure parsing + */ + explicit Eval (Eval *global, Eval *parent, bool sloppy = false); /** * @brief virtual dtor to enable dynamic_cast on derived classes. @@ -513,7 +522,7 @@ public: private: friend class Expression; - Eval *mp_parent; + Eval *mp_parent, *mp_global; std::map m_local_vars; std::map m_local_functions; bool m_sloppy; diff --git a/src/tl/tl/tlString.cc b/src/tl/tl/tlString.cc index 2842e1161..f13b5400f 100644 --- a/src/tl/tl/tlString.cc +++ b/src/tl/tl/tlString.cc @@ -775,8 +775,8 @@ from_string (const std::string &s, const unsigned char * &result) result = (unsigned char *) s.c_str (); } -void -from_string (const std::string &s, double &v) +static void +from_string_numeric (const std::string &s, double &v, bool eval) { const char *cp = s.c_str (); while (safe_isspace (*cp)) { @@ -791,18 +791,23 @@ from_string (const std::string &s, double &v) ++cp_end; } if (*cp_end) { - // try using an expression - v = tl::Eval ().parse (s).execute ().to_double (); + if (eval) { + // try using an expression (using a clean environment disables all global features and leaves + // only some static functions) + v = tl::Eval (0, 0, false).parse (s).execute ().to_double (); + } else { + throw tl::Exception (tl::to_string (tr ("Unexpected text after numeric value: '...")) + cp_end + "'"); + } } } template -void -convert_string_to_int (const std::string &s, T &v) +static void +convert_string_to_int (const std::string &s, T &v, bool eval) { double x; // HACK: this should be some real string-to-int conversion - tl::from_string (s, x); + tl::from_string_numeric (s, x, eval); if (x < std::numeric_limits ::min ()) { throw tl::Exception (tl::to_string (tr ("Range underflow: ")) + s); } @@ -815,40 +820,88 @@ convert_string_to_int (const std::string &s, T &v) } } +void +from_string (const std::string &s, double &v) +{ + return from_string_numeric (s, v, false); +} + void from_string (const std::string &s, int &v) { - convert_string_to_int (s, v); + convert_string_to_int (s, v, false); } void from_string (const std::string &s, long &v) { - convert_string_to_int (s, v); + convert_string_to_int (s, v, false); } void from_string (const std::string &s, long long &v) { - convert_string_to_int (s, v); + convert_string_to_int (s, v, false); } void from_string (const std::string &s, unsigned int &v) { - convert_string_to_int (s, v); + convert_string_to_int (s, v, false); } void from_string (const std::string &s, unsigned long &v) { - convert_string_to_int (s, v); + convert_string_to_int (s, v, false); } void from_string (const std::string &s, unsigned long long &v) { - convert_string_to_int (s, v); + convert_string_to_int (s, v, false); +} + +void +from_string_ext (const std::string &s, double &v) +{ + return from_string_numeric (s, v, true); +} + +void +from_string_ext (const std::string &s, int &v) +{ + convert_string_to_int (s, v, true); +} + +void +from_string_ext (const std::string &s, long &v) +{ + convert_string_to_int (s, v, true); +} + +void +from_string_ext (const std::string &s, long long &v) +{ + convert_string_to_int (s, v, true); +} + +void +from_string_ext (const std::string &s, unsigned int &v) +{ + convert_string_to_int (s, v, true); +} + +void +from_string_ext (const std::string &s, unsigned long &v) +{ + convert_string_to_int (s, v, true); +} + +void +from_string_ext (const std::string &s, unsigned long long &v) +{ + convert_string_to_int (s, v, true); } void diff --git a/src/tl/tl/tlString.h b/src/tl/tl/tlString.h index 576b3a93d..014928d5f 100644 --- a/src/tl/tl/tlString.h +++ b/src/tl/tl/tlString.h @@ -807,6 +807,14 @@ TL_PUBLIC void from_string (const std::string &s, unsigned long &v); TL_PUBLIC void from_string (const std::string &s, unsigned long long &v); TL_PUBLIC void from_string (const std::string &s, bool &b); +TL_PUBLIC void from_string_ext (const std::string &s, double &v); +TL_PUBLIC void from_string_ext (const std::string &s, int &v); +TL_PUBLIC void from_string_ext (const std::string &s, long &v); +TL_PUBLIC void from_string_ext (const std::string &s, long long &v); +TL_PUBLIC void from_string_ext (const std::string &s, unsigned int &v); +TL_PUBLIC void from_string_ext (const std::string &s, unsigned long &v); +TL_PUBLIC void from_string_ext (const std::string &s, unsigned long long &v); + inline void from_string (const std::string &s, std::string &v) { v = s; } template inline void from_string (const std::string &s, T &t) diff --git a/src/tl/unit_tests/tlStringTests.cc b/src/tl/unit_tests/tlStringTests.cc index d1724a558..d02f2adeb 100644 --- a/src/tl/unit_tests/tlStringTests.cc +++ b/src/tl/unit_tests/tlStringTests.cc @@ -84,13 +84,16 @@ TEST(1a) from_string("-15.000E+1", d); EXPECT_EQ (to_string(d), "-150"); - from_string("25400/25.4", d); + from_string_ext("-15.000E+1", d); + EXPECT_EQ (to_string(d), "-150"); + + from_string_ext("25400/25.4", d); EXPECT_EQ (to_string(d), "1000"); - from_string("25400/(25+0.4)", d); + from_string_ext("25400/(25+0.4)", d); EXPECT_EQ (to_string(d), "1000"); - from_string(" 25400 / (25 + 0.4 ) ", d); + from_string_ext(" 25400 / (25 + 0.4 ) ", d); EXPECT_EQ (to_string(d), "1000"); from_string("1E+03", d); @@ -136,6 +139,8 @@ TEST(2) from_string (" 12 ", ul); EXPECT_EQ (ul, (unsigned int) 12); + from_string_ext (" 12 ", ul); + EXPECT_EQ (ul, (unsigned int) 12); error = false; try { from_string ("a", ul); } catch (...) { error = true; } EXPECT_EQ (error, true); @@ -145,12 +150,16 @@ TEST(2) from_string (" 12 ", l); EXPECT_EQ (l, 12); + from_string_ext (" 12 ", l); + EXPECT_EQ (l, 12); error = false; try { from_string ("a", l); } catch (...) { error = true; } EXPECT_EQ (error, true); from_string (" 12 ", ui); EXPECT_EQ (ui, (unsigned int) 12); + from_string_ext (" 12 ", ui); + EXPECT_EQ (ui, (unsigned int) 12); error = false; try { from_string ("a", ui); } catch (...) { error = true; } EXPECT_EQ (error, true); @@ -160,6 +169,8 @@ TEST(2) from_string (" 12 ", i); EXPECT_EQ (i, 12); + from_string_ext (" 12 ", i); + EXPECT_EQ (i, 12); error = false; try { from_string ("a", i); } catch (...) { error = true; } EXPECT_EQ (error, true); diff --git a/src/tl/unit_tests/tlXMLParserTests.cc b/src/tl/unit_tests/tlXMLParserTests.cc index a9837ab06..092bf5bc7 100644 --- a/src/tl/unit_tests/tlXMLParserTests.cc +++ b/src/tl/unit_tests/tlXMLParserTests.cc @@ -220,10 +220,10 @@ TEST (6) } #if !defined (HAVE_EXPAT) - EXPECT_EQ (error, "XML parser error: Expected end of text at position 1 (..a) in line 2, column 27"); + EXPECT_EQ (error, "XML parser error: Unexpected text after numeric value: '...a' in line 2, column 27"); #else // expat delivers cdata at beginning of closing tag - EXPECT_EQ (error, "XML parser error: Expected end of text at position 1 (..a) in line 2, column 18"); + EXPECT_EQ (error, "XML parser error: Unexpected text after numeric value: '...a' in line 2, column 18"); #endif } From f3a5678c15403164cfc798c0d09b0fba5df6d6a2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 16 Dec 2021 00:47:11 +0100 Subject: [PATCH 6/9] Updated version and copyright --- Changelog | 8 ++++++++ Changelog.Debian | 7 +++++++ version.sh | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 9c130dd01..882bfde59 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,12 @@ +0.27.6 (2021-12-19): +* Bugfix: %GITHUB%/issues/942 Technology file routing suffix string typo +* Bugfix: %GITHUB%/issues/946 Python: __file__ returns quoted path string +* Bugfix: less liberal evaluation of expressions in string to numeric conversion + This will fix a potential vulnerability which allows someone to sneak + in expression code through malicious configuration, technology or layer properties + files. + 0.27.5 (2021-11-14): * Enhancements: Better support for execution (also cross-interpreter) of macro code from scripts - New methods for the Macro class like "run" and loading from file diff --git a/Changelog.Debian b/Changelog.Debian index 5bfd0057a..715b33b21 100644 --- a/Changelog.Debian +++ b/Changelog.Debian @@ -1,3 +1,10 @@ +klayout (0.27.6-1) unstable; urgency=low + + * New features and bugfixes + - See changelog + + -- Matthias Köfferlein Sun, 17 Dec 2021 17:04:40 +0100 + klayout (0.27.5-1) unstable; urgency=low * New features and bugfixes diff --git a/version.sh b/version.sh index 81eafc7fe..42df8ef96 100644 --- a/version.sh +++ b/version.sh @@ -2,10 +2,10 @@ # This script is sourced to define the main version parameters # The main version -KLAYOUT_VERSION="0.27.5" +KLAYOUT_VERSION="0.27.6" # The version used for PyPI (don't use variables here!) -KLAYOUT_PYPI_VERSION="0.27.5" +KLAYOUT_PYPI_VERSION="0.27.6" # The build date KLAYOUT_VERSION_DATE=$(date "+%Y-%m-%d") From 397efd411940d569a2079cdaeffad82235e1759b Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 16 Dec 2021 07:59:25 +0100 Subject: [PATCH 7/9] Updated version files --- Changelog | 2 +- Changelog.Debian | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 882bfde59..5232ec13b 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,5 @@ -0.27.6 (2021-12-19): +0.27.6 (2021-12-18): * Bugfix: %GITHUB%/issues/942 Technology file routing suffix string typo * Bugfix: %GITHUB%/issues/946 Python: __file__ returns quoted path string * Bugfix: less liberal evaluation of expressions in string to numeric conversion diff --git a/Changelog.Debian b/Changelog.Debian index 715b33b21..7516cde62 100644 --- a/Changelog.Debian +++ b/Changelog.Debian @@ -3,7 +3,7 @@ klayout (0.27.6-1) unstable; urgency=low * New features and bugfixes - See changelog - -- Matthias Köfferlein Sun, 17 Dec 2021 17:04:40 +0100 + -- Matthias Köfferlein Thu, 16 Dec 2021 07:55:34 +0100 klayout (0.27.5-1) unstable; urgency=low From e1df15a47ffafd206f68fee338e3fcb09fd922bf Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 16 Dec 2021 22:51:14 +0100 Subject: [PATCH 8/9] Fixed Windows tests --- src/tl/unit_tests/tlIncludeTests.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tl/unit_tests/tlIncludeTests.cc b/src/tl/unit_tests/tlIncludeTests.cc index 8ed1651fd..cad6fc58e 100644 --- a/src/tl/unit_tests/tlIncludeTests.cc +++ b/src/tl/unit_tests/tlIncludeTests.cc @@ -28,6 +28,7 @@ static std::string np (const std::string &s) { + return tl::replaced (s, "\\\\", "/"); return tl::replaced (s, "\\", "/"); } From 219fbceb28b2990c56442b2cca8f457042c1b762 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 17 Dec 2021 08:18:35 +0100 Subject: [PATCH 9/9] Fixed the fix. --- src/tl/unit_tests/tlIncludeTests.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tl/unit_tests/tlIncludeTests.cc b/src/tl/unit_tests/tlIncludeTests.cc index cad6fc58e..efa6e8f04 100644 --- a/src/tl/unit_tests/tlIncludeTests.cc +++ b/src/tl/unit_tests/tlIncludeTests.cc @@ -28,8 +28,8 @@ static std::string np (const std::string &s) { - return tl::replaced (s, "\\\\", "/"); - return tl::replaced (s, "\\", "/"); + std::string t = tl::replaced (s, "\\\\", "/"); + return tl::replaced (t, "\\", "/"); } TEST(1_simple)