Skip to content

Commit e5241e6

Browse files
committed
Backport error trimming
1 parent b58f130 commit e5241e6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/xml2_init.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <libxml/xmlversion.h>
33
#include <libxml/xmlerror.h>
44
#include <libxml/parser.h>
5+
#include <string.h>
56

67
/* * *
78
* Author: Nick Wellnhofer <wellnhofer@aevum.de>
@@ -16,8 +17,11 @@ void handleStructuredError(void* userData, const xmlError* error) {
1617
void handleStructuredError(void* userData, xmlError* error) {
1718
#endif
1819

19-
//std::string message = std::string(error->message);
20-
//message.resize(message.size() - 1); // trim off trailing newline
20+
int len = strlen(error->message);
21+
if(len > 2){
22+
error->message[len-1] = '\0';
23+
}
24+
2125
if (error->level <= 2) {
2226
Rf_warning("%s [%i]", error->message, (int) error->code);
2327
} else {

0 commit comments

Comments
 (0)