[xml] Fix how the output filename is built

Avoid problems when it contains the embedded strings ".c", ".cpp" or ".cxx".
Fixes #540 reported by djack42.
This commit is contained in:
Olly Betts 2016-08-05 11:52:35 +12:00
commit a950d1309b
2 changed files with 10 additions and 3 deletions

View file

@ -81,9 +81,11 @@ public:
virtual int top(Node *n) {
if (out == 0) {
String *outfile = Getattr(n, "outfile");
Replaceall(outfile, ".cxx", ".xml");
Replaceall(outfile, ".cpp", ".xml");
Replaceall(outfile, ".c", ".xml");
String *ext = Swig_file_extension(outfile);
// If there's an extension, ext will include the ".".
Delslice(outfile, Len(outfile) - Len(ext), DOH_END);
Delete(ext);
Append(outfile, ".xml");
out = NewFile(outfile, "w", SWIG_output_files());
if (!out) {
FileErrorDisplay(outfile);