[PATCH 2/4] xprop: add condition for the number of fields
Bert Wesarg
bert.wesarg at googlemail.com
Thu Oct 20 07:23:26 PDT 2011
This adds $# to the gramma to ask for the number of fields.
Signed-off-by: Bert Wesarg <bert.wesarg at googlemail.com>
---
xprop.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/xprop.c b/xprop.c
index 04b4301..9203f08 100644
--- a/xprop.c
+++ b/xprop.c
@@ -1221,10 +1221,15 @@ Scan_Term (const char *string, thunk *thunks, const char *format, long *value)
string = Scan_Long(string, value);
else if (*string == '$') {
const char *bad_string = string++;
- string = Scan_Long(string, &i);
- if (i >= thunks->thunk_count)
- Fatal_Error("Bad field reference %d in conditional %s", (int) i, bad_string);
- *value = thunks[i].value;
+ if (*string == '#') {
+ *value = thunks->thunk_count;
+ ++string;
+ } else {
+ string = Scan_Long(string, &i);
+ if (i >= thunks->thunk_count)
+ Fatal_Error("Bad field reference %d in conditional %s", (int) i, bad_string);
+ *value = thunks[i].value;
+ }
} else if (*string == 'm') {
string = Scan_Long(++string, &i);
*value = Mask_Bit_I(thunks, format, (int) i);
--
1.7.7.759.gfc8c6
More information about the xorg-devel
mailing list