On Mon, Sep 03, 2007 at 05:20:57PM +0800, Li Zefan wrote:
> > * TODO: add long options for all flags
>
> I've done this, and the manpage also has been updated. But I'm not sure that
> the names of long options are appropriate.
Cool! Cannot we use getopt_long()?
> for (argv++, argc--; argc && argv[0][0] == '-'; argv++, argc--) {
> - int n, unknown = 1;
> + int n, f, unknown = 1;
> const char *arg = argv[0];
>
> if (!strcmp(arg, "--help"))
> show_help();
>
> /* compatibitity with an old Debian setarch implementation
> - * TODO: add long options for all flags
> */
> - if (!strcmp(arg, "--3gb"))
> - arg="-3";
> - else if (!strcmp(arg, "--4gb"))
> + if (!strcmp(arg, "--4gb"))
> continue; /* just ignore this one */
>
> - for (n = 1; arg[n]; n++) {
> - int f;
> + /* long option name */
> + if (arg[1] == '-') {
if (arg[1] == '-' && arg[2] != '\0')
> + arg += 2;
> +
> + if (!strcmp(arg, "verbose")) {
> + verbose = 1;
> + continue;
> +
> + for (f = 0; f < sizeof(flags) / sizeof(flags[0]); f++) {
> + if (!strcmp(arg, flags[f].long_opt)) {
> + if (verbose)
> + fprintf(stderr, _("Switching on %s.\n"), flags[f].name);
> + options |= flags[f].option;
> + unknown = 0;
> + break;
> + }
> + }
> + if (unknown)
> + error(0, 0, _("Unknown option `%c' ignored"), arg[n]);
error(0, 0, _("Unknown option `%c' ignored"), arg);
Karel
--
Karel Zak <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html