Hack to bring back support for "-q"-style short command-line args.

This commit is contained in:
William Kendrick 2011-04-14 06:02:48 +00:00
parent f8450479e1
commit c314c49927

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - January 8, 2011 June 14, 2002 - April 13, 2011
*/ */
@ -20964,33 +20964,42 @@ static void parse_file_options(struct cfginfo *restrict tmpcfg, const char *file
static void parse_argv_options(struct cfginfo *restrict tmpcfg, char *argv[]) static void parse_argv_options(struct cfginfo *restrict tmpcfg, char *argv[])
{ {
char *str, *arg; char *str, *arg;
const char * short_synonyms[][2] = {
/* FIXME: Bring back support for single-dash options: {"-c", "copying"},
-c (--copying) {"-h", "help"},
-h (--help) {"-u", "usage"},
-u (--usage) {"-v", "version"},
-v (--version) {"-vv", "version-verbose"},
-vv (--version-verbose) {"-l", "lang"},
{"-L", "locale"},
-l (--lang) {"-b", "startblank"},
-L (--locale) {"-f", "fullscreen"},
{"-m", "mixedcase"},
-b (--startblank) {"-p", "noprint"},
-f (--fullscreen) {"-q", "nosound"},
-m (--mixedcase) {"-s", "simpleshapes"},
-p (--noprint) {"-w", "windowed"},
-q (--nosound) {"-x", "noquit"},
-s (--simpleshapes) {NULL, NULL}
-w (--windowed) };
-x (--noquit)
Especially the ones I use a lot: -w -q -f -x -v -h -l -bjk 2009.11.11
*/
while(( str = *++argv )) while(( str = *++argv ))
{ {
if(str[0]=='-' && str[1]=='-' && str[2]) if(str[0]=='-' && str[1]!='-' && str[1]!='\0') {
{ int i, found = 0;
for (i = 0; short_synonyms[i][0] != NULL && !found; i++) {
if (strcmp(short_synonyms[i][0], str) == 0) {
if(argv[1] && argv[1][0]!='-')
arg = *++argv;
else
arg = NULL;
parse_one_option(tmpcfg, short_synonyms[i][1], arg, NULL);
found = 1;
}
}
if (found)
continue;
} else if(str[0]=='-' && str[1]=='-' && str[2]) {
str += 2; str += 2;
arg = strchr(str,'='); arg = strchr(str,'=');
if(arg) if(arg)
@ -21002,6 +21011,7 @@ static void parse_argv_options(struct cfginfo *restrict tmpcfg, char *argv[])
} }
fprintf(stderr, "%s is not understood\n", *argv); fprintf(stderr, "%s is not understood\n", *argv);
show_usage(63); show_usage(63);
exit(1);
} }
// These interact in horrid ways. // These interact in horrid ways.