Fix Swig_file_extension when the path has a . and there is no extension in the filename

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13905 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-11-18 00:45:39 +00:00
commit 41fed461fa

View file

@ -323,19 +323,11 @@ File *Swig_filebyname(const_String_or_char_ptr filename) {
* ----------------------------------------------------------------------------- */
String *Swig_file_extension(const_String_or_char_ptr filename) {
const char *d;
const char *c = Char(filename);
int len = Len(filename);
if (strlen(c)) {
d = c + len - 1;
while (d != c) {
if (*d == '.')
return NewString(d);
d--;
}
return NewString(c + len);
}
return NewString(c);
String *name = Swig_file_filename(filename);
const char *c = strrchr(Char(name), '.');
String *extension = c ? NewString(c) : NewString("");
Delete(name);
return extension;
}
/* -----------------------------------------------------------------------------