attractivechaos / klib

A standalone and lightweight C library

Home Page:http://attractivechaos.github.io/klib/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to parse \ options with ketopt.h?

ci70 opened this issue · comments

commented

How to parse / options on windows with ketopt.h?

	int opt = -1, i0, j;
	if (permute) {
        while (  s->i < argc && (  ( argv[s->i][0] != '-') || ( argv[s->i][0] != '/') )      || argv[s->i][1] == '\0')  )
			++s->i, ++s->n_args;
	}

	s->arg = 0, s->longidx = -1, i0 = s->i;
    if ( s->i >= argc || (   ( argv[s->i][0] != '-' ) || (argv[s->i][0] != '/')         )  || argv[s->i][1] == '\0' ) {
		s->ind = s->i - s->n_args;
		return -1;
	}

    if ( (argv[s->i][0] == '-' && argv[s->i][1] == '-') || (argv[s->i][0] == '/') ) { /* "--" or a long option */
		if (argv[s->i][2] == '\0') { /* a bare "--" */
			ketopt_permute(argv, s->i, s->n_args);
			++s->i, s->ind = s->i - s->n_args;
			return -1;
		}

kopt only support unix-style options, not options starting with "/".