search for: long_index

Displaying 8 results from an estimated 8 matches for "long_index".

2018 Nov 14
2
Re: [PATCH 2/2] build: Replace ./nbdkit with a C program.
...w to quote just the things that need quoting, rather than to print everything the same way whether or not that can be reparsed the same as the original input) > + fprintf (stderr, "\n"); > +} > + > +int > +main (int argc, char *argv[]) > +{ > + int c; > + int long_index; > + int verbose = 0; Worth using <stdbool.h> and making this one bool? > + size_t i; > + char *s; > + > + /* If NBDKIT_VALGRIND=1 is set in the environment, then we run the > + * program under valgrind. This is used by the tests. Similarly if > + * NBDKIT_GDB...
2018 Nov 14
0
Re: [PATCH 2/2] build: Replace ./nbdkit with a C program.
...intention is NBDKIT_VALGRIND=1 rather than just is set. [...] > >+ /* Option parsing. We don't really parse options here. We are only > >+ * interested in which options have arguments and which need > >+ * rewriting. > >+ */ > >+ for (;;) { > >+ long_index = -1; > > Why do we need this? > > /me reads ahead... > > Oh, because you are taking the lazy way out by rewriting all user's > input back in long-opt form, regardless of how the user spelled it > on input, rather than duplicating a switch statement that has to be &gt...
2018 Nov 13
3
[PATCH 0/2] build: Replace ./nbdkit with a C program.
This patch series solves the FreeBSD shebang problem in a completely different way, and a few other things besides. I propose that we replace ./nbdkit with a C program. The C program is a straightforward translation of the shell script. Some advantages of this approach are: - We can parse options in exactly the same way as the real program. - Use the more accurate ‘is_short_name’ test for
2018 Nov 14
3
[PATCH nbdkit v2 0/2] build: Replace ./nbdkit with a C program.
v1 was here: https://www.redhat.com/archives/libguestfs/2018-November/msg00147.html v2: - Use stdbool for booleans. - Use __attribute__((format(printf))). - Don't abort on invalid options, exit with failure instead. - Preserve long/short option choices in the output. - Add '=' in long option output, ie. always use --longopt=arg. - Add "--" parameter
2018 Nov 13
0
[PATCH 2/2] build: Replace ./nbdkit with a C program.
...mand (void) +{ + size_t i; + + if (len > 0) + fprintf (stderr, "%s", cmd[0]); + for (i = 1; i < len && cmd[i] != NULL; ++i) + fprintf (stderr, " %s", cmd[i]); + fprintf (stderr, "\n"); +} + +int +main (int argc, char *argv[]) +{ + int c; + int long_index; + int verbose = 0; + size_t i; + char *s; + + /* If NBDKIT_VALGRIND=1 is set in the environment, then we run the + * program under valgrind. This is used by the tests. Similarly if + * NBDKIT_GDB=1 is set, we run the program under GDB, useful during + * development. + */ + s = geten...
2018 Nov 14
0
[PATCH nbdkit v2 2/2] build: Replace ./nbdkit with a C program.
...mand (void) +{ + size_t i; + + if (len > 0) + fprintf (stderr, "%s", cmd[0]); + for (i = 1; i < len && cmd[i] != NULL; ++i) + fprintf (stderr, " %s", cmd[i]); + fprintf (stderr, "\n"); +} + +int +main (int argc, char *argv[]) +{ + int c; + int long_index; + bool verbose = false; + bool is_long_option; + size_t i; + char *s; + + /* If NBDKIT_VALGRIND=1 is set in the environment, then we run the + * program under valgrind. This is used by the tests. Similarly if + * NBDKIT_GDB=1 is set, we run the program under GDB, useful during + * dev...
2018 Nov 14
1
Re: [PATCH 2/2] build: Replace ./nbdkit with a C program.
...ent as a separate patch (whether you stick with enforcing exactly "1" everywhere, or with either of the simpler "is set to anything, even empty" or "is set to anything non-empty"). >>> + } >> >> Still, I wonder if this loop is necessary - if long_index is -1, you >> know the user passed a short opt, AND you know that printf("-%c", c) >> will spell that short opt (except for c == '?' - but you should >> already be special-casing that). So is it really necessary to map >> all the user's short options in...
2018 Nov 14
5
[PATCH nbdkit v3 0/4] build: Replace ./nbdkit with a C program.
v1 was here: https://www.redhat.com/archives/libguestfs/2018-November/msg00147.html v2 was here: https://www.redhat.com/archives/libguestfs/2018-November/msg00152.html v3: - Use optarg != NULL as a sentinel for has_arg. - Moved some variable decls into the inner loop. - Make nbdkit wrapper depend on config.status, so if srcdir or builddir changes then we rebuild the wrapper. It