another undo patch: a feature request and implementation, should it be of interest

Matthew Dillon dillon at apollo.backplane.com
Fri Mar 27 23:40:55 PDT 2009


:orm.
:I guess trying to use immediate number options with multiple
:characters is simply not possible to get clean as opposed to merely
:working when getopt is used for options. While slightly more verbose
:in usage, the code for using a standard option with argument is rather
:much nicer, yes.
:
:...
:Should I send such a patch? Alternatively, if you copy the main()
:function from before the feature patch, move the initiation of the
:"flags" variable to before the option-reading loop, then such code can
:simply be inserted for case 't'.

    Send a complete patch w/ everything, using the new scheme, and I'll
    commit it.

    I'm not sure the logic you posted will properly sequence ts1 and
    ts2.  I suggest just tracking the sequencing separately instead
    of using ts1.tid and the flags variable.

    Then for updating the flags just pass additional arguments
    to parse_delta_time() and let parse_delta_time() make the
    distinction and adjust the flags  e.g.:

    case 't':
	++count_t;
	if (count_t == 1)
		ts1.tid = parse_delta_time(optarg, &flags, UNDO_FLAG_SETTID1);
	else
		ts2.tid = parse_delta_time(optarg, &flags, UNDO_FLAG_SETTID2);
	else
		usage();
	break;
    ...

    Or something like that.

					-Matt
					Matthew Dillon 
					<dillon at backplane.com>





More information about the Submit mailing list