Fixing issue #1750 and issue #1751

This commit is contained in:
Matthias Koefferlein 2024-06-22 21:00:26 +02:00
parent 4e430ff38f
commit 27073cb128
3 changed files with 21 additions and 25 deletions

View File

@ -35,6 +35,9 @@
#include <set>
#include <stdexcept>
#include <cstdint>
#if __cplusplus >= 201703L
#include <optional>
#endif
#if defined(HAVE_QT)
#include <QString>

View File

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

View File

@ -75,7 +75,7 @@ public:
mp_progress->set_unit (1024 * 1024);
}
size_t read (char *data, size_t n)
ssize_t read (char *data, size_t n)
{
try {
@ -88,11 +88,7 @@ public:
*data++ = *rd;
}
if (n0 == n) {
return -1;
} else {
return n0 - n;
}
return n0 - n;
} catch (tl::Exception &ex) {
m_error = ex.msg ();
@ -282,24 +278,21 @@ public:
const size_t chunk = 65536;
char buffer [chunk];
size_t n;
ssize_t 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, int (n), n < ssize_t (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<XMLParserPrivateData *> (user_data);
d->cdata (std::string (s, 0, size_t (len)));
d->cdata (std::string (s, size_t (len)));
}