fix input filename containing a path on windows

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11000 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2008-12-24 13:19:55 +00:00
commit 9a94969fdd
4 changed files with 18 additions and 6 deletions

View file

@ -1002,7 +1002,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (lang_config) {
Printf(fs, "\n%%include <%s>\n", lang_config);
}
Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", input_file, Swig_last_file());
Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(NewString(input_file)), Swig_last_file());
for (i = 0; i < Len(libfiles); i++) {
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
}

View file

@ -183,12 +183,8 @@ static FILE *Swig_open_file(const String_or_char *name, int sysfile, int use_inc
Delete(spath);
}
if (f) {
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
Replaceall(filename, "\\\\", "\\"); /* remove double '\' in case any already present */
Replaceall(filename, "\\", "\\\\");
#endif
Delete(lastpath);
lastpath = Copy(filename);
lastpath = Swig_filename_escape(filename);
}
Delete(filename);
return f;

View file

@ -117,6 +117,21 @@ String *Swig_strip_c_comments(const String *s) {
}
/* -----------------------------------------------------------------------------
* Swig_filename_escape()
*
* Escapes backslashes in filename - for Windows
* ----------------------------------------------------------------------------- */
String *Swig_filename_escape(String *filename) {
String *adjusted_filename = Copy(filename);
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */
Replaceall(adjusted_filename, "\\", "\\\\");
#endif
return adjusted_filename;
}
/* -----------------------------------------------------------------------------
* Swig_string_escape()
*

View file

@ -286,6 +286,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern const char *Swig_package_version(void);
extern void Swig_banner(File *f);
extern String *Swig_strip_c_comments(const String *s);
extern String *Swig_filename_escape(String *filename);
extern String *Swig_string_escape(String *s);
extern String *Swig_string_mangle(const String *s);
extern void Swig_scopename_split(String *s, String **prefix, String **last);