MCPcopy Create free account
hub / github.com/Singular/Singular / _fe_getopt_internal

Function _fe_getopt_internal

resources/fegetopt.c:325–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323 long-named options. */
324
325int _fe_getopt_internal (
326 int argc,
327 char *const *argv,
328 const char *optstring,
329 const struct fe_option *longopts,
330 int *longind,
331 int long_only)
332{
333 int option_index;
334
335 fe_optarg = 0;
336
337 /* Initialize the internal data when the first call is made.
338 Start processing options with ARGV-element 1 (since ARGV-element 0
339 is the program name); the sequence of previously skipped
340 non-option ARGV-elements is empty. */
341
342 if (fe_optind == 0)
343 {
344 first_nonopt = last_nonopt = fe_optind = 1;
345
346 nextchar = NULL;
347
348 /* Determine how to handle the ordering of options and nonoptions. */
349
350 if (optstring[0] == '-')
351 {
352 ordering = RETURN_IN_ORDER;
353 ++optstring;
354 }
355 else if (optstring[0] == '+')
356 {
357 ordering = REQUIRE_ORDER;
358 ++optstring;
359 }
360 else if (getenv ("POSIXLY_CORRECT") != NULL)
361 ordering = REQUIRE_ORDER;
362 else
363 ordering = PERMUTE;
364 }
365
366 if (nextchar == NULL || *nextchar == '\0')
367 {
368 if (ordering == PERMUTE)
369 {
370 /* If we have just processed some options following some non-options,
371 exchange them so that the options come first. */
372
373 if (first_nonopt != last_nonopt && last_nonopt != fe_optind)
374 exchange ((char **) argv);
375 else if (last_nonopt != fe_optind)
376 first_nonopt = fe_optind;
377
378 /* Now skip any additional non-options
379 and extend the range of non-options previously skipped. */
380
381 while (fe_optind < argc
382 && (argv[fe_optind][0] != '-' || argv[fe_optind][1] == '\0')

Callers 3

fe_getoptFunction · 0.85
fe_getopt_longFunction · 0.85
fe_getopt_long_onlyFunction · 0.85

Calls 3

exchangeFunction · 0.85
my_strlenFunction · 0.85
my_indexFunction · 0.85

Tested by

no test coverage detected