Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getopt.h / wgetopt.h cleanup #2790

Closed
krader1961 opened this issue Mar 3, 2016 · 5 comments
Closed

getopt.h / wgetopt.h cleanup #2790

krader1961 opened this issue Mar 3, 2016 · 5 comments

Comments

@krader1961
Copy link
Contributor

While working on issue #102 I noticed that src/fallback.h defines several values normally found in the systems getopt.h header. Which wouldn't be an issue except that it defines them piecemeal which means they can easily conflict with symbols defined before src/fallback.h is included. In practice that is extremely unlikely but is still a potential problem. What's worse, however, is the code uses fish's wgetopt implementation everywhere but fish.cpp, fish_indent.cpp, and fish_tests.cpp. It seems to me that those getopt symbols should be removed from fallback.h and those modules should be using fish's wgetopt implementation.

P.S., None of the existing labels are appropriate. I'd select something like "lint" or "cleanup" if they existed.

@krader1961
Copy link
Contributor Author

I can't find any reason why a workaround for a missing getopt_long() function was needed in early 2006. Googling shows it had been part of the GNU library for several years by then. I can only surmise that some of the mainstream UNIX distros like Solaris may not have had an implementation at that time. But since BSD, OS X, Linux, Solaris all have it now there is no good reason to keep that baggage.

For the record the workaround for a missing getopt_long() function was introduced by ~axel on 2006-08-28 via commit 548e379. It was to avoid doing the same check in fishd.c, mimedb.c and set_color.c none of which still exist. All of the changes to those lines of code since then only make non-functional changes (e.g., adding comments, lint removal).

The aforementioned workaround in fallback.h was introduced after the initial introduction of getopt_long() use guarded by #ifdef HAVE_GETOPT_LONG by ~axel in commit 89eb80f on 2006-01-24.

@krader1961
Copy link
Contributor Author

I also noticed, while addressing the original issue, that there is inconsistency in how the fish private wgetopt_long() function is used. Not to mention silly things like conflating the NULL pointer and zero (yeah, I know that isn't a problem in practice, but it's still ugly).

@krader1961
Copy link
Contributor Author

I'm not going to convert fish.cpp and fish_indent.cpp to use wgetopt_long at this time. I (or someone else) needs to first ensure that such changes are compatible with locale settings that are not UTF-8.

@zanchey
Copy link
Member

zanchey commented Mar 6, 2016

Sounds like a good idea. wgetopt_long didn't exist on Solaris 9, according to the manual page archive on the FreeBSD website, but was introduced in Solaris 10 as a compatibility shim.

@faho
Copy link
Member

faho commented Mar 6, 2016

For those (like me) unfamiliar with Solaris, version 9 achieved EOL in October 2014, version 10 was released in January 2005.

krader1961 added a commit that referenced this issue Mar 8, 2016
There is no longer a good reason to detect whether or not getopt_long()
is available. All UNIX implementations we're likely to run on have it. And
if we ever find one that doesn't the right thing to do is not fallback to
getopt() but to include the getopt_long() source in our package like we
do with the pcre2 library. Since it's licensed under LGPL we can legally
do so if it becomes necessary.

This partially addresses issue #2790.
floam pushed a commit to floam/fish-shell that referenced this issue Mar 15, 2016
There is no longer a good reason to detect whether or not getopt_long()
is available. All UNIX implementations we're likely to run on have it. And
if we ever find one that doesn't the right thing to do is not fallback to
getopt() but to include the getopt_long() source in our package like we
do with the pcre2 library. Since it's licensed under LGPL we can legally
do so if it becomes necessary.

This partially addresses issue fish-shell#2790.
@krader1961 krader1961 added this to the fish-future milestone Mar 24, 2016
@zanchey zanchey modified the milestones: 2.3.0, fish-future Mar 25, 2016
floam pushed a commit to floam/fish-shell that referenced this issue Apr 3, 2016
There is no longer a good reason to detect whether or not getopt_long()
is available. All UNIX implementations we're likely to run on have it. And
if we ever find one that doesn't the right thing to do is not fallback to
getopt() but to include the getopt_long() source in our package like we
do with the pcre2 library. Since it's licensed under LGPL we can legally
do so if it becomes necessary.

This partially addresses issue fish-shell#2790.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants