[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
parent 2740812970
commit a950d1309b
2 changed files with 10 additions and 3 deletions

View File

@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 3.0.11 (in progress)
============================
2016-08-05: olly
[xml] Fix how the output filename is built to avoid problems when
it contains the embedded strings ".c", ".cpp" or ".cxx".
Fixes #540 reported by djack42.
2016-07-01: wsfulton
Fix corner case of wrapping std::vector of T pointers where a pointer to a pointer of T
also exists in the wrapped code. SF Bug 2359417 (967).

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);