garya@garya.UUCP (Gary Aitken) (04/21/89)
I'd like to make a close to trivial proposal. The X resource posting mechanism, via XrmOptionDescRec structures, provides two mechanisms for preventing an argument(s) from being examined: XrmoptionSkipArg XrmoptionSkipLine The first skips the option and one following argument; the second skips the option and the remainder of the command line. What's missing is a general ability to skip an option only (e.g. "-s"), or an option and more than one trailing argument. I propose that an additional type be added to XrmOptionKind: XrmoptionSkipN specifying that the option and N following arguments be skipped. The value of N would be passed as the "value" field in the XrmOptionDescRec: static XrmOptionDescRec opTable[] = { {"-s", "", XrmoptionSkipN, (caddr_t)0}, /* skip option alone */ {"-o", "", XrmoptionSkipN, (caddr_t)1}, /* equiv to XrmoptionSkipArg */ {"-x", "", XrmoptionSkipN, (caddr_t)2}, /* skip option + 2 args */ } ; This is particularly important when X applications are written to provide interfaces to existing commands; many of these use single character flags which conflict with the "standard" options provided by Xt (e.g. "-s" is treated as an abbreviation for "-synchronous"). The following changes to Xlib will implement this proposal: ========================== Xresource.h ====================================== *** /x/x/MIT/lib/X/Xresource.h Sat Nov 5 01:39:20 1988 --- Xresource.h Thu Apr 20 18:08:51 1989 *************** *** 252,258 **** XrmoptionSepArg, /* Value is next argument in argv */ XrmoptionResArg, /* Resource and value in next argument in argv */ XrmoptionSkipArg, /* Ignore this option and the next argument in argv */ ! XrmoptionSkipLine /* Ignore this option and the rest of argv */ } XrmOptionKind; typedef struct { --- 252,259 ---- XrmoptionSepArg, /* Value is next argument in argv */ XrmoptionResArg, /* Resource and value in next argument in argv */ XrmoptionSkipArg, /* Ignore this option and the next argument in argv */ ! XrmoptionSkipLine, /* Ignore this option and the rest of argv */ ! XrmoptionSkipN /* Ignore this option and the next N argument in argv */ } XrmOptionKind; typedef struct { ========================== ParseCmd.c ======================================= *** /x/x/MIT/lib/X/ParseCmd.c Fri Nov 4 17:10:09 1988 --- ParseCmd.c Fri Apr 21 09:05:24 1989 *************** *** 69,74 **** --- 69,75 ---- int matches; enum {DontCare, Check, NotSorted, Sorted} table_is_sorted; char **argend; + int n_skip ; /* # arguments to skip for XrmoptionSkipN */ #define PutCommandResource(value_str) \ { \ *************** *** 167,172 **** --- 168,183 ---- case XrmoptionSkipLine: for (; myargc > 0; myargc--) (*argsave++) = (*argv++); + break; + + case XrmoptionSkipN: + n_skip = min((int)options[i].value, myargc) ; + *argsave++ = *argv ; + while (n_skip--) { + --myargc ; + argv++ ; + *argsave++ = *argv ; + } break; default: