From 16fda0825a0c6a51f800c225e66adce65e5f327c Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 18 Apr 2024 12:00:43 -0700 Subject: Add -v1.6 & -v1.7 to recognized version flags Also adds missing -v1.4 & -v1.5 to the man page. Signed-off-by: Alan Coopersmith Part-of: --- man/x11perf.man | 12 ++++++++ x11perf.c | 87 ++++++++++++++++++++++++++++++--------------------------- x11perf.h | 15 ++++++---- 3 files changed, 68 insertions(+), 46 deletions(-) diff --git a/man/x11perf.man b/man/x11perf.man index 39e4735..843215f 100644 --- a/man/x11perf.man +++ b/man/x11perf.man @@ -236,6 +236,18 @@ Perform only x11perf Version 1.2 tests using Version 1.2 semantics. .B \-v1.3 Perform only x11perf Version 1.3 tests using Version 1.3 semantics. .TP 14 +.B \-v1.4 +Perform only x11perf Version 1.4 tests using Version 1.4 semantics. +.TP 14 +.B \-v1.5 +Perform only x11perf Version 1.5 tests using Version 1.5 semantics. +.TP 14 +.B \-v1.6 +Perform only x11perf Version 1.6 tests using Version 1.6 semantics. +.TP 14 +.B \-v1.7 +Perform only x11perf Version 1.7 tests using Version 1.7 semantics. +.TP 14 .B \-su Set the save_under window attribute to True on all windows created by x11perf. Default is False. diff --git a/x11perf.c b/x11perf.c index 3939f02..8018bf7 100644 --- a/x11perf.c +++ b/x11perf.c @@ -356,8 +356,9 @@ Get_Display_Name(int *pargc, /* MODIFIED */ /* - * GetVersion (argc, argv) Look for -v1.2, -v1.3, or -v1.4. + * GetVersion (argc, argv) Look for -v followed by a version number. * If found remove it from command line. Don't go past a lone -. + * Leave -v followed by non-numbers as it could be -vclass. */ static Version @@ -366,49 +367,53 @@ GetVersion(int *pargc, /* MODIFIED */ { int argc = *pargc; char **pargv = argv+1; - Version version = VERSION1_6; + Version version = VERSION1_7; Bool found = False; for (int i = 1; i != argc; i++) { char *arg = argv[i]; - if (!strcmp (arg, "-v1.2")) { - version = VERSION1_2; - *pargc -= 1; - if (found) { - fprintf(stderr, "Warning: multiple version specifications\n"); - } - found = True; - continue; - } - if (!strcmp (arg, "-v1.3")) { - version = VERSION1_3; - *pargc -= 1; - if (found) { - fprintf(stderr, "Warning: multiple version specifications\n"); - } - found = True; - continue; - } - if (!strcmp (arg, "-v1.4")) { - version = VERSION1_4; - *pargc -= 1; - if (found) { - fprintf(stderr, "Warning: multiple version specifications\n"); - } - found = True; - continue; - } - if (!strcmp (arg, "-v1.5")) { - version = VERSION1_5; - *pargc -= 1; - if (found) { - fprintf(stderr, "Warning: multiple version specifications\n"); + if (arg[0] == '-' && arg[1] == 'v') { + if (arg[2] == '1' && arg[3] == '.' && arg[5] == '\0') { + switch (arg[4]) { + case '2': + version = VERSION1_2; + break; + case '3': + version = VERSION1_3; + break; + case '4': + version = VERSION1_4; + break; + case '5': + version = VERSION1_5; + break; + case '6': + version = VERSION1_6; + break; + case '7': + version = VERSION1_7; + break; + default: + goto unknown_version; + } + + if (found) { + fprintf(stderr, "Warning: multiple version specifications\n"); + } + found = True; + + /* reduce arg count and skip copying this arg to pargv */ + *pargc -= 1; + continue; + } else if (isdigit(arg[2])) { + unknown_version: + fprintf(stderr, "Error: unknown version specification: %s\n", + arg); + exit(1); } - found = True; - continue; } - if (!strcmp(arg,"-")) { + else if (!strcmp(arg,"-")) { while (i a list of the number of sub-windows to use\n" " -v1.2 perform only v1.2 tests using old semantics\n" " -v1.3 perform only v1.3 tests using old semantics\n" +" -v1.4 perform only v1.4 tests using old semantics\n" +" -v1.5 perform only v1.5 tests using old semantics\n" +" -v1.6 perform only v1.6 tests using old semantics\n" +" -v1.7 perform only v1.7 tests using old semantics\n" " -su request save unders on windows\n" " -bs WhenMapped or Always (default = NotUseful)\n" ; @@ -1049,10 +1058,6 @@ main(int argc, char *argv[]) } else if (strcmp(argv[i], "-subs") == 0) { skip = GetNumbers (i+1, argc, argv, subWindows, &numSubWindows); i += skip; - } else if (strcmp(argv[i], "-v1.2") == 0) { - xparms.version = VERSION1_2; - } else if (strcmp(argv[i], "-v1.3") == 0) { - xparms.version = VERSION1_3; } else if (strcmp(argv[i], "-su") == 0) { xparms.save_under = True; } else if (strcmp(argv[i], "-bs") == 0) { diff --git a/x11perf.h b/x11perf.h index 396f6a0..c755e07 100644 --- a/x11perf.h +++ b/x11perf.h @@ -61,12 +61,17 @@ typedef unsigned char Version; #define VERSION1_4 ((Version)(1 << 2)) #define VERSION1_5 ((Version)(1 << 3)) #define VERSION1_6 ((Version)(1 << 4)) +#define VERSION1_7 ((Version)(1 << 5)) + #define V1_2ONLY VERSION1_2 -#define V1_2FEATURE (VERSION1_2 | VERSION1_3 | VERSION1_4 | VERSION1_5 | VERSION1_6) -#define V1_3FEATURE (VERSION1_3 | VERSION1_4 | VERSION1_5 | VERSION1_6) -#define V1_4FEATURE (VERSION1_4 | VERSION1_5 | VERSION1_6) -#define V1_5FEATURE (VERSION1_5 | VERSION1_6) -#define V1_6FEATURE (VERSION1_6) + +/* Each V1_*FEATURE flag includes all later versions */ +#define V1_7FEATURE (VERSION1_7) +#define V1_6FEATURE (VERSION1_6 | V1_7FEATURE) +#define V1_5FEATURE (VERSION1_5 | V1_6FEATURE) +#define V1_4FEATURE (VERSION1_4 | V1_5FEATURE) +#define V1_3FEATURE (VERSION1_3 | V1_4FEATURE) +#define V1_2FEATURE (VERSION1_2 | V1_3FEATURE) typedef struct _Parms { /* Required fields */ -- cgit v1.2.3