Merge remote-tracking branch 'origin/master' into qt6

This commit is contained in:
Matthias Koefferlein 2021-12-17 21:44:50 +01:00
commit 4820207cd3
47 changed files with 357 additions and 198 deletions

View File

@ -1,6 +1,11 @@
0.27.6 (2021-xx-xx):
TODO
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
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

View File

@ -1,3 +1,10 @@
klayout (0.27.6-1) unstable; urgency=low
* New features and bugfixes
- See changelog
-- Matthias Köfferlein <matthias@koefferlein.de> Thu, 16 Dec 2021 07:55:34 +0100
klayout (0.27.5-1) unstable; urgency=low
* New features and bugfixes

View File

@ -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;
}

View File

@ -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);

View File

@ -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)")));

View File

@ -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);
}
}

View File

@ -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")));
}

View File

@ -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);

View File

@ -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);
}

View File

@ -614,7 +614,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);
@ -622,7 +622,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);
@ -630,7 +630,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);
@ -638,7 +638,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);
@ -674,7 +674,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);
@ -682,7 +682,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);
@ -690,7 +690,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);
@ -698,7 +698,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);
@ -839,7 +839,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);
@ -847,7 +847,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);

View File

@ -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")));
}

View File

@ -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 ())));

View File

@ -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 ())));

View File

@ -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);

View File

@ -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 ()) {

View File

@ -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 ());

View File

@ -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 ());

View File

@ -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 ();

View File

@ -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) {

View File

@ -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")));
}

View File

@ -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 (...) { }

View File

@ -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 ());

View File

@ -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;
}

View File

@ -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 (...) { }
}

View File

@ -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);

View File

@ -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 (...) { }
}

View File

@ -69,7 +69,7 @@ CIFReaderOptionPage::commit (db::FormatSpecificReaderOptions *o, const db::Techn
{
db::CIFReaderOptions *options = dynamic_cast<db::CIFReaderOptions *> (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")));
}

View File

@ -75,24 +75,24 @@ DXFReaderOptionPage::commit (db::FormatSpecificReaderOptions *o, const db::Techn
{
db::DXFReaderOptions *options = dynamic_cast<db::DXFReaderOptions *> (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 ();

View File

@ -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")));
}

View File

@ -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") +

View File

@ -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 ()));
@ -391,7 +392,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)")));
}
@ -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

View File

@ -80,12 +80,12 @@ MAGReaderOptionPage::commit (db::FormatSpecificReaderOptions *o, const db::Techn
db::MAGReaderOptions *options = dynamic_cast<db::MAGReaderOptions *> (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")));
}

View File

@ -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 ();

View File

@ -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")));
}

View File

@ -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 (...) { }
}

View File

@ -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<size_t>::max ())) {
n = 0.0;
}

View File

@ -130,7 +130,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
@ -144,7 +144,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

View File

@ -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);
}
}
}

View File

@ -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 <std::string, tl::Variant> m_local_vars;
std::map <std::string, EvalFunction *> m_local_functions;
bool m_sloppy;

View File

@ -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,9 @@ IncludeExpander::from_string (const std::string &s)
ex.read_quoted (ie.m_sections [1].first);
} else if (ex.test ("@")) {
} else if (*ex == '@') {
++ex;
while (! ex.at_end ()) {

View File

@ -790,8 +790,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)) {
@ -806,18 +806,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 <class T>
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 <T>::min ()) {
throw tl::Exception (tl::to_string (tr ("Range underflow: ")) + s);
}
@ -830,40 +835,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

View File

@ -833,6 +833,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 <class T> inline void from_string (const std::string &s, T &t)

View File

@ -28,7 +28,8 @@
static std::string np (const std::string &s)
{
return tl::replaced (s, "\\", "/");
std::string t = tl::replaced (s, "\\\\", "/");
return tl::replaced (t, "\\", "/");
}
TEST(1_simple)
@ -108,3 +109,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"));
}

View File

@ -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);

View File

@ -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
}

1
testdata/tl/inc 4.txt vendored Normal file
View File

@ -0,0 +1 @@
included.4

3
testdata/tl/x_inc4.txt vendored Normal file
View File

@ -0,0 +1,3 @@
A line
# %include 'inc 4.txt'
Another line