@@ -249,21 +249,6 @@ bool PrintParameters::setPageSelection(const std::string& pageSelectionStr)
249249 return !pageSelection.empty ();
250250}
251251
252- #if __cpp_lib_to_chars < 201611L
253- double double_from_chars (const char * begin, const char * end)
254- {
255- static locale_t c_locale = newlocale (LC_ALL_MASK, " C" , nullptr );
256- return strtod_l (begin, (char **)&end, c_locale);
257- }
258- #else
259- double double_from_chars (const char * begin, const char * end)
260- {
261- double tmp = 0 ;
262- std::from_chars (begin, end, tmp);
263- return tmp;
264- }
265- #endif
266-
267252bool PrintParameters::setPaperSize (const std::string& sizeStr)
268253{
269254 const std::regex nameRegex (" ^[0-9a-z_-]+_([0-9]+([.][0-9]+)?)x([0-9]+([.][0-9]+)?)(mm|in)$" );
@@ -272,8 +257,14 @@ bool PrintParameters::setPaperSize(const std::string& sizeStr)
272257 if (std::regex_match (sizeStr.c_str (), match, nameRegex))
273258 {
274259 paperSizeName = sizeStr;
275- paperSizeW = double_from_chars (match[1 ].first , match[1 ].second );
276- paperSizeH = double_from_chars (match[3 ].first , match[3 ].second );
260+ #if __cpp_lib_to_chars < 201611L
261+ static locale_t c_locale = newlocale (LC_ALL_MASK, " C" , nullptr );
262+ paperSizeW = strtod_l (match[1 ].first , nullptr , c_locale);
263+ paperSizeH = strtod_l (match[3 ].first , nullptr , c_locale);
264+ #else
265+ std::from_chars (match[1 ].first , match[1 ].second , paperSizeW);
266+ std::from_chars (match[3 ].first , match[3 ].second , paperSizeH);
267+ #endif
277268 if (match[5 ] == " in" )
278269 {
279270 paperSizeUnits = Inches;
0 commit comments