Better handling of file paths containing multiple path separators. Fix recent regression incorrectly detecting a directory on Windows when the output directory is not the current directory.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11944 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-03-13 22:28:24 +00:00
commit 4f88d641af
3 changed files with 46 additions and 16 deletions

View file

@ -281,20 +281,21 @@ static unsigned int decode_numbers_list(String *numlist) {
// -----------------------------------------------------------------------------
// Sets the output directory for language specific (proxy) files if not set and
// adds trailing file separator if necessary.
// corrects the directory name and adds trailing file separator if necessary.
// -----------------------------------------------------------------------------
static void set_outdir(const String *c_wrapper_file_dir) {
static void configure_outdir(const String *c_wrapper_file_dir) {
// Use the C wrapper file's directory if the output directory has not been set by user
if (!outdir || Len(outdir) == 0)
outdir = NewString(c_wrapper_file_dir);
Swig_filename_correct(outdir);
// Add file delimiter if not present in output directory name
if (outdir && Len(outdir) != 0) {
const char *outd = Char(outdir);
if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0)
Printv(outdir, SWIG_FILE_DELIMITER, NIL);
}
// Use the C wrapper file's directory if the output directory has not been set by user
if (!outdir)
outdir = NewString(c_wrapper_file_dir);
const char *outd = Char(outdir);
if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0)
Printv(outdir, SWIG_FILE_DELIMITER, NIL);
}
/* This function sets the name of the configuration file */
@ -1221,7 +1222,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
} else {
Setattr(top, "outfile_h", outfile_name_h);
}
set_outdir(Swig_file_dirname(Getattr(top, "outfile")));
configure_outdir(Swig_file_dirname(Getattr(top, "outfile")));
if (Swig_contract_mode_get()) {
Swig_contracts(top);
}