Skip to content

rapidxml fix for mac os

Francesco Troisi requested to merge rapidxmml_fix into release-14.0

Description

This MR addresses an issue on MacOS with the RapidXML library. The function pseudopotential::format detect_format, which detects the format of the pseudopotential files, was first trying to parse the file as XML and then, in case of failure, looking at the extension of the file (e.g. .psf).

While this was fine on Linux, on MacOS the following lines were failing:

try {
 doc.parse<0>(…)
catch (rapidxml::parse_error xml_error)
 isxml = false
}

In particular, for the test case I was trying (03-derivatives_3d.01), that try statement was supposed to fail because the pseudopotential was in a PSF file, not an XML. However, on Mac instead of executing the catch statement the code was stopping. To be fair I did not understand what was happening exactly. I first tried to initialize the doc (which is only declared), but that was not the issue. Then I tried to add more generic catch:

try {
 doc.parse<0>(…)
catch (rapidxml::parse_error xml_error)
 isxml = false;
} catch (std::standarderror e) {
 isxml = false;
} catch (...) {
 isxml = false;
}

But no luck even with this. I also asked @LecrisUT, but we could not figure out the issue.

So at the end I decided to move the try-catch at the end of the function. In the example this works because the try catch is not executed. It should work in general because we are not relying on the catch to work properly, as all other file extensions are detected before that.

Checklist

  • I have checked that my code follows the Octopus coding standards
  • I have added tests for all the new features added in this request.
Edited by Francesco Troisi

Merge request reports