diff --git a/src/gsi/gsi/gsiTypes.h b/src/gsi/gsi/gsiTypes.h index cf02ea391..974ded2ec 100644 --- a/src/gsi/gsi/gsiTypes.h +++ b/src/gsi/gsi/gsiTypes.h @@ -35,6 +35,9 @@ #include #include #include +#if __cplusplus >= 201703L +#include +#endif #if defined(HAVE_QT) #include diff --git a/src/gsi/unit_tests/gsiExpressionTests.cc b/src/gsi/unit_tests/gsiExpressionTests.cc index 2f83ffce0..d85f566fe 100644 --- a/src/gsi/unit_tests/gsiExpressionTests.cc +++ b/src/gsi/unit_tests/gsiExpressionTests.cc @@ -748,28 +748,28 @@ TEST(14) v = e.parse("var t = CplxTrans.new(1.5, 2.5); var tt = CplxTrans.new(); t.assign(other=t)").execute(); EXPECT_EQ (true, false); } catch (tl::Exception &ex) { - EXPECT_EQ (ex.msg ().find ("Keyword arguments not permitted at position 60 (...assign(other=t))"), 0); + EXPECT_EQ (ex.msg ().find ("Keyword arguments not permitted at position 60 (...assign(other=t))"), size_t (0)); } try { v = e.parse("var t = CplxTrans.new('abc');").execute(); EXPECT_EQ (true, false); } catch (tl::Exception &ex) { - EXPECT_EQ (ex.msg ().find ("No overload with matching arguments. Variants are:"), 0); + EXPECT_EQ (ex.msg ().find ("No overload with matching arguments. Variants are:"), size_t (0)); } try { v = e.parse("var t = CplxTrans.new(uu=17);").execute(); EXPECT_EQ (true, false); } catch (tl::Exception &ex) { - EXPECT_EQ (ex.msg ().find ("Can't match arguments. Variants are:"), 0); + EXPECT_EQ (ex.msg ().find ("Can't match arguments. Variants are:"), size_t (0)); } try { v = e.parse("var t = CplxTrans.new(u='17');").execute(); EXPECT_EQ (true, false); } catch (tl::Exception &ex) { - EXPECT_EQ (ex.msg ().find ("No overload with matching arguments. Variants are:"), 0); + EXPECT_EQ (ex.msg ().find ("No overload with matching arguments. Variants are:"), size_t (0)); } } diff --git a/src/tl/tl/tlXMLParser.cc b/src/tl/tl/tlXMLParser.cc index 164578ab0..55174fc75 100644 --- a/src/tl/tl/tlXMLParser.cc +++ b/src/tl/tl/tlXMLParser.cc @@ -75,7 +75,7 @@ public: mp_progress->set_unit (1024 * 1024); } - size_t read (char *data, size_t n) + int read (char *data, size_t n) { try { @@ -88,11 +88,7 @@ public: *data++ = *rd; } - if (n0 == n) { - return -1; - } else { - return n0 - n; - } + return int (n0 - n); } catch (tl::Exception &ex) { m_error = ex.msg (); @@ -279,27 +275,24 @@ public: XML_SetElementHandler (mp_parser, start_element_handler, end_element_handler); XML_SetCharacterDataHandler (mp_parser, cdata_handler); - const size_t chunk = 65536; + const int chunk = 65536; char buffer [chunk]; - size_t n; + int n; do { - try { + n = source.source ()->read (buffer, chunk); + if (n < 0) { + break; + } - n = source.source ()->read (buffer, chunk); - - XML_Status status = XML_Parse (mp_parser, buffer, int (n), n < chunk /*is final*/); - if (status == XML_STATUS_ERROR) { - m_has_error = true; - m_error = XML_ErrorString (XML_GetErrorCode (mp_parser)); - m_error_line = XML_GetErrorLineNumber (mp_parser); - m_error_column = XML_GetErrorColumnNumber (mp_parser); - } - - } catch (tl::Exception &ex) { - error (ex); + XML_Status status = XML_Parse (mp_parser, buffer, n, n < chunk /*is final*/); + if (status == XML_STATUS_ERROR) { + m_has_error = true; + m_error = XML_ErrorString (XML_GetErrorCode (mp_parser)); + m_error_line = XML_GetErrorLineNumber (mp_parser); + m_error_column = XML_GetErrorColumnNumber (mp_parser); } } while (n == chunk && !m_has_error); @@ -343,7 +336,7 @@ void end_element_handler (void *user_data, const XML_Char *name) void cdata_handler (void *user_data, const XML_Char *s, int len) { XMLParserPrivateData *d = reinterpret_cast (user_data); - d->cdata (std::string (s, 0, size_t (len))); + d->cdata (std::string (s, size_t (len))); }