Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 8dec830

Browse files
adeas31OpenModelica-Hudson
authored andcommitted
Use str to clear the stream instead of clear.
Make sure we count the opening of tags.
1 parent cfb2366 commit 8dec830

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

SimulationRuntime/c/simulation/simulation_runtime.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,12 +1006,13 @@ static inline void sendXMLTCPIfClosed()
10061006
{
10071007
if (numOpenTags==0) {
10081008
sim_communication_port.send(xmlTcpStream.str());
1009-
xmlTcpStream.clear();
1009+
xmlTcpStream.str("");
10101010
}
10111011
}
10121012

10131013
static void messageXMLTCP(int type, int stream, int indentNext, char *msg, int subline, const int *indexes)
10141014
{
1015+
numOpenTags++;
10151016
xmlTcpStream << "<message stream=\"" << LOG_STREAM_NAME[stream] << "\" type=\"" << LOG_TYPE_DESC[type] << "\" text=\"";
10161017
printEscapedXMLTCP(&xmlTcpStream, msg);
10171018
if (indexes) {
@@ -1021,10 +1022,16 @@ static void messageXMLTCP(int type, int stream, int indentNext, char *msg, int s
10211022
xmlTcpStream << "<used index=\"" << indexes[i] << "%d\" />\n";
10221023
}
10231024
if (!indentNext) {
1025+
numOpenTags--;
10241026
xmlTcpStream << "</message>\n";
10251027
}
10261028
} else {
1027-
xmlTcpStream << (indentNext ? "\">\n" : "\" />\n");
1029+
if (indentNext) {
1030+
xmlTcpStream << "\">\n";
1031+
} else {
1032+
numOpenTags--;
1033+
xmlTcpStream << "\" />\n";
1034+
}
10281035
}
10291036
sendXMLTCPIfClosed();
10301037
}

0 commit comments

Comments
 (0)