DragonFly submit List (threaded) for 2009-03
DragonFly BSD
DragonFly submit List (threaded) for 2009-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

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


From: "Joel K. Pettersson" <joelkpettersson@xxxxxxxxx>
Date: Sat, 28 Mar 2009 00:10:31 +0000

>    The 0-9 handling needs some help.  A lot of help.  It's just too messy.
I'm not too surprised.

>    I think it needs to be handled either by giving it its own option
>    (instead of trying to parse 0-9 in getopt), or by integrating the index
>    selection with -t by detecting that the TID values are not in 0x form.
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.

>    My preference is to simply make -t accept non 0x form transaction ids
>    as indices instead of transaction ids.
>
>                                        -Matt
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'.

With a simple test for index numbers, though it may be a bit
quick-and-dirty, here's such code:
               case 't':
                       if (ts1.tid == 0 &&
                           !(flags & UNDO_FLAG_SETTID1)) {
                               ts1.tid = parse_delta_time(optarg);
                               if (optarg[0] >= '0' && optarg[0] <= '9' &&
                                   optarg[1] != 'x')
                                       flags |= UNDO_FLAG_SETTID1;
                       } else if (ts2.tid == 0 &&
                                  !(flags & UNDO_FLAG_SETTID2)) {
                               ts2.tid = parse_delta_time(optarg);
                               if (optarg[0] >= '0' && optarg[0] <= '9' &&
                                   optarg[1] != 'x')
                                       flags |= UNDO_FLAG_SETTID2;
                       } else
                               usage();
                       break;

Where the code for detecting non-TIDs may be replaced, if needed.

--
 -  Joel K. Pettersson



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]