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:
parent
d918bddfc0
commit
41fed461fa
1 changed files with 5 additions and 13 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue