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) {
|
String *Swig_file_extension(const_String_or_char_ptr filename) {
|
||||||
const char *d;
|
String *name = Swig_file_filename(filename);
|
||||||
const char *c = Char(filename);
|
const char *c = strrchr(Char(name), '.');
|
||||||
int len = Len(filename);
|
String *extension = c ? NewString(c) : NewString("");
|
||||||
if (strlen(c)) {
|
Delete(name);
|
||||||
d = c + len - 1;
|
return extension;
|
||||||
while (d != c) {
|
|
||||||
if (*d == '.')
|
|
||||||
return NewString(d);
|
|
||||||
d--;
|
|
||||||
}
|
|
||||||
return NewString(c + len);
|
|
||||||
}
|
|
||||||
return NewString(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue