This is the mail archive of the libc-help@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]

Re: argp parser


Karin en Edwin wrote:

> I am using the argp parser and I would like to make sure the argument
> always gets parsed before the options (default behaviour is the
> opposite). I have looked in the argp documentation, but cannot find
> anything.
> Anyone have an idea how I could do this?

I'm more familiar with getopt than argp, so others may have better
advice.  I'd suggest enqueueing options (possibly in parsed form) for
later handling, then dealing with nonoptions, then popping options
from the queue.  getopt (and hence argp) permutes the elements of argv
as it scans, so the non-option arguments are not necessarily
contiguous until it is done.

Another possibility is to use '-' (the RETURN_IN_ORDER flag) in the
option specification to learn about nonoptions as soon as possible,
(intermixed with options).  That would seem to me to just complicate
life further, but it could speed up argument parsing by some miniscule
amount, which may or may not be important for your application.
AFAICT this is exposed in argp as ARGP_IN_ORDER.

Hope that helps,
Jonathan


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