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

Add support for GNU-style command line options #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions xclip.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ int clean_requestors() {
static void
doOptMain(int argc, char *argv[])
{
/* Support both -option and --option form. */
int i;
for (i = 1; i < argc; ++i) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For code hygiene, I suggest declaring the counter variable within the for loop. E.g., for (int i = 1 ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it should be compiled with ANSI C compiler. I'll use for (int i =... style if it allowed.

if (!strncmp(argv[i], "--", 2)) {
argv[i]++;
}
}

/* Initialise resource manager and parse options into database */
XrmInitialize();
XrmParseCommand(&opt_db, opt_tab, opt_tab_size, PACKAGE_NAME, &argc,
Expand Down