From 47770a9bd7b8af662ebaeb56911bfd4ee7ca5b9b Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 10 Feb 2022 12:01:57 -0500 Subject: xdpyinfo: Fix printing the X.Org release version for xserver >= 21 Without this you'd get 1.21.1.4 instead of 21.1.4. --- xdpyinfo.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xdpyinfo.c b/xdpyinfo.c index dda04c7..b201ad3 100644 --- a/xdpyinfo.c +++ b/xdpyinfo.c @@ -245,12 +245,19 @@ print_display_info(Display *dpy) int vendrel = VendorRelease(dpy); printf("X.Org version: "); - printf("%d.%d.%d", vendrel / 10000000, + if (vendrel >= 12100000) { + vendrel -= 10000000; /* Y2.1K compliant */ + printf("%d.%d", (vendrel / 100000) % 100, (vendrel / 1000) % 100); - if (vendrel % 1000) - printf(".%d", vendrel % 1000); - printf("\n"); + } else { + printf("%d.%d.%d", vendrel / 10000000, + (vendrel / 100000) % 100, + (vendrel / 1000) % 100); + } + if (vendrel % 1000) + printf(".%d", vendrel % 1000); + printf("\n"); } else if (strstr(ServerVendor (dpy), "XFree86")) { int vendrel = VendorRelease(dpy); -- cgit v1.2.3