-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor e-command argument code #44
Open
tcunha
wants to merge
42
commits into
ryanflannery:master
Choose a base branch
from
tcunha:ecmd-args
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Just use / in this specific case which might already happen if the user's home directory is blank in the passwd(5) file.
More to come. Namely, error context which changes throughout the program (ie output to either stderr or to the command/status window) and consolidating the debug code, as well.
Specific "modules" should include what they really need and not rely on some other header including files. Obviously, now, headers need to be explicitly included.
Might be better, in the future, to append -Wformat=2 to CFLAGS and also use the printf format attribute.
Which, in my opinion, is a good thing because, as a consequence, there's less pre-processor goo in the tree.
From now on, there's no need to specify the relative path of local header files.
It might generate a SIGSEGV exception if it's accessed. Caught by the new wrapper function.
Now, with error contexts, the execute function can, also, be called when parsing the configuration file, without having to worry about where to output its messages. That is, when parsing the configuration file, the messages are printed to standard error and, afterwards, they get painted to the command/status window.
The fparseln(3) function already returns NULL on EOF. Check it and move the ferror(3) call outside the loop.
It already gets printed by the error functions.
Not used, yet. However, it will allow to get rid of the e-command parse function. All e-commands (when applicable), will then use the generic parse function and the to be added arguments functions to check options and retrieve values. Idea taken from tmux.
This uses the red-black tree implementation from OpenBSD. Other data structures should probably be converted in the future, accordingly, instead of rolling our own and sticking only to arrays. Not working for other operating systems, yet.
From now on, when implementing a new e-command, there's no need to duplicate code (ie call getopt, set flags and values). It's just a matter of calling the arguments functions.
On other operating systems, the local tree.h file is included. Not tested, though. The compat code probably needs some rework.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.