This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

argp and parse_opt: question and possible feature request


Hi glibc (argp) maintainers,

This is my first mail to this mailing list, so sorry if this is off topic or not actually a bug. It is just two questions that might also be feature requests, if they do not already exist. If they do, I am sorry for not noticing.

I am using the argp argument parser to parse the arguments to my program. But there were two things I could not find in the manual which would make my program much more easier and less buggy:

1. Accessing the long version of the option in pars_opt:
The short version of the option that is passed to pars_opt() is simply the `key`, but I could not find if there is a way to access the long format of the option that was called.

2. Checking for wrong usage of the equal sign (`=`).
In my simple tests, when I gave a short option with an equal sign or a long option with spaces before and after the equal sign, I noticed that the equal sign is passed in to parse_opt() as part of the argument. So I added this tiny check at the beginning of parse_opt() to check for this and warn the user:

if(arg && arg[0]=='=')
  argp_error(state, "Incorrect use of the equal sign (`=`). For short "
             "options, `=` should not be used and for long options,
             "there should be no space between the option, equal sign "
              "and value.");

So I wanted to to see if there is already a built in feature in argp that can solve these two issues? If there isn't and the maintainers agree, I think it is very useful to have these two features added.

I have learnt a lot from the glibc manual and made a lot of use of it in my work. Thank you very much for creating and maintaining such a fantastic library and its great documentation.

Thanks again,
Mohammad


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]