Skip to content

Commit

Permalink
Merge branch 'lheinfiniteloop' into 'master'
Browse files Browse the repository at this point in the history
Implement treatment of <![CDATA[ in LHEF

Closes #80

See merge request hepmc/HepMC3!340
  • Loading branch information
Andrii Verbytskyi committed Apr 17, 2024
2 parents 2c45fd5 + a3a0da2 commit ca05dea
Show file tree
Hide file tree
Showing 4 changed files with 1,154 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/HepMC3/LHEF.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@ struct XMLTag {
continue;
}

// Check for character data
if ( begin != end && str.find("<![CDATA[", curr) == begin ) {
pos_t endcom = str.find("]]>", begin);
tags.push_back(new XMLTag());
if ( endcom == end ) {
tags.back()->contents = str.substr(curr);
if ( leftover ) *leftover += str.substr(curr);
return tags;
}
tags.back()->contents = str.substr(curr, endcom - curr);
if ( leftover ) *leftover += str.substr(curr, endcom - curr);
curr = endcom;
continue;
}

if ( begin != curr ) {
tags.push_back(new XMLTag());
tags.back()->contents = str.substr(curr, begin - curr);
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ set( HepMC_tests
testIO8
testIO11
testIO12
testIO13
testReaderFactory1
testSingleVertexHepMC2
testAttributes
Expand Down
Loading

0 comments on commit ca05dea

Please sign in to comment.