|
|
Returning nullptr is a very bad idea, as almost any calling code will have to test for this, usually to change it right back to "".
Returning "" (actually the nul at the end of the filename) if there is no extension, and returning starting from the period if there is one, is the original design and was always intended. This was so the offset into the filename was where the period would be written if you wanted to change the extension.
I agree it would be best to fix it to ignore any period before the first non-period after the last slash, so that ".hidden" and ".." and so on act like they have no extension.
>I agree, if this is indeed day-zero behavior, then the docs could be >fixed, but OTOH returning NULL seems more appropriate (to me).
That is up to you guys. As a library maintainer in the past, I was taught that introducing breaking changes was a no-no.
Changing the docs instead of the code avoids having to check the 5 places in the FLTK codebase where the function is used [and where several calls assume that strcmp will not fall over when passed NULL].
>First of all, what is a "hidden" file, or, a better question would be:
Then I shouldn't have mentioned that part - my question is merely whether the file/folder ".somefile" has an extension or not. Or "." and ".." : both of whom return "." from the function.
This is kinda a naming debate - the function is named "fl_filename_ext" which implies that it returns the extension portion of the filename, as defined by the platform rules. However, the implementation returns the portion of the path from the last period onward, which might not be the same thing?
Kevin
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/4a94e266-942d-4991-afa7-41580004fad5n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/CAL-8oAgW2tEAuL-TOYgaksbs7aVOx%3D%2B9aLom6B1oKhmSSSipWQ%40mail.gmail.com.
[ Direct Link to Message ] | |
|
| |