Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[xsrc/trunk]: xsrc/external/mit/xwininfo/include merge xinput 1.6.4, xrdb 1.2...



details:   https://anonhg.NetBSD.org/xsrc/rev/888075d2ccf9
branches:  trunk
changeset: 7551:888075d2ccf9
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Jun 19 08:02:08 2023 +0000

description:
merge xinput 1.6.4, xrdb 1.2.2, xwd 1.0.9, and xwininfo 1.1.6

diffstat:

 external/mit/xinput/dist/src/xinput.c  |    7 +-
 external/mit/xrdb/dist/xrdb.c          |  163 ++++++++++++++++----------------
 external/mit/xwininfo/dist/xwininfo.c  |   66 ++++++------
 external/mit/xwininfo/include/config.h |    8 +-
 4 files changed, 124 insertions(+), 120 deletions(-)

diffs (truncated from 718 to 300 lines):

diff -r 8f471db2cd8a -r 888075d2ccf9 external/mit/xinput/dist/src/xinput.c
--- a/external/mit/xinput/dist/src/xinput.c     Mon Jun 19 08:00:21 2023 +0000
+++ b/external/mit/xinput/dist/src/xinput.c     Mon Jun 19 08:02:08 2023 +0000
@@ -105,7 +105,7 @@ static entry drivers[] =
       test_xi2,
     },
     { "map-to-output",
-      "<device> <output name>",
+      "<device> <output name>|all",
       map_to_output,
     },
 #endif
@@ -352,7 +352,7 @@ usage(void)
 {
     entry      *pdriver = drivers;
 
-    fprintf(stderr, "usage :\n");
+    fprintf(stderr, "usage:\n");
 
     while(pdriver->func_name) {
        fprintf(stderr, "\txinput %s %s\n", pdriver->func_name,
@@ -388,6 +388,7 @@ main(int argc, char * argv[])
     entry      *driver = drivers;
     char        *func;
     int event, error;
+    int xwl_op, xwl_ev, xwl_err;
 
     if (argc > 1) {
        func = argv[1];
@@ -422,7 +423,7 @@ main(int argc, char * argv[])
        goto out;
     }
 
-    if (is_xwayland(display))
+    if (XQueryExtension(display, "XWAYLAND", &xwl_op, &xwl_ev, &xwl_err) || is_xwayland(display))
         fprintf(stderr, "WARNING: running xinput against an Xwayland server. See the xinput man page for details.\n");
 
     while(driver->func_name) {
diff -r 8f471db2cd8a -r 888075d2ccf9 external/mit/xrdb/dist/xrdb.c
--- a/external/mit/xrdb/dist/xrdb.c     Mon Jun 19 08:00:21 2023 +0000
+++ b/external/mit/xrdb/dist/xrdb.c     Mon Jun 19 08:02:08 2023 +0000
@@ -168,25 +168,24 @@ asprintf(char **ret, const char *format,
     if (len < 0)
         return -1;
 
+    *ret = malloc(len + 1); /* snprintf doesn't count trailing '\0' */
+    if (*ret == NULL)
+        return -1;
+
     if (len < sizeof(buf)) {
-        *ret = strdup(buf);
+        memcpy(*ret, buf, len + 1);
     }
     else {
-        *ret = malloc(len + 1); /* snprintf doesn't count trailing '\0' */
-        if (*ret != NULL) {
-            va_start(ap, format);
-            len = vsnprintf(*ret, len + 1, format, ap);
-            va_end(ap);
-            if (len < 0) {
-                free(*ret);
-                *ret = NULL;
-            }
+        va_start(ap, format);
+        len = vsnprintf(*ret, len + 1, format, ap);
+        va_end(ap);
+        if (len < 0) {
+            free(*ret);
+            *ret = NULL;
+            return -1;
         }
     }
 
-    if (*ret == NULL)
-        return -1;
-
     return len;
 }
 #endif                          /* HAVE_ASPRINTF */
@@ -249,9 +248,7 @@ InitEntries(Entries *e)
 static void
 FreeEntries(Entries *e)
 {
-    size_t i;
-
-    for (i = 0; i < e->used; i++) {
+    for (size_t i = 0; i < e->used; i++) {
         if (e->entry[i].usable) {
             free(e->entry[i].tag);
             free(e->entry[i].value);
@@ -263,9 +260,7 @@ FreeEntries(Entries *e)
 static void
 AddEntry(Entries *e, Entry *entry)
 {
-    size_t n;
-
-    for (n = 0; n < e->used; n++) {
+    for (size_t n = 0; n < e->used; n++) {
         if (!strcmp(e->entry[n].tag, entry->tag)) {
             /* overwrite old entry */
             if (e->entry[n].lineno && !quiet) {
@@ -403,11 +398,12 @@ GetEntries(Entries *entries, Buffer *buf
 static void
 GetEntriesString(Entries *entries, char *str)
 {
-    Buffer buff;
+    if (str && *str) {
+        Buffer buff = {
+            .buff = str,
+            .used = strlen(str)
+        };
 
-    if (str && *str) {
-        buff.buff = str;
-        buff.used = strlen(str);
         GetEntries(entries, &buff, 1);
     }
 }
@@ -512,13 +508,12 @@ AddDefTok(String *buff, const char *pref
 static void
 AddDefHostname(String *buff, const char *title, const char *value)
 {
-    char *s;
     char name[512];
     char c;
 
     strncpy(name, value, sizeof(name) - 1);
     name[sizeof(name) - 1] = '\0';
-    for (s = name; (c = *s); s++) {
+    for (char *s = name; (c = *s); s++) {
         if (!isalpha(c) && !isdigit(c) &&
             c != '_' && c != '.' && c != ':' && c != '-')
             *s = '_';
@@ -550,13 +545,10 @@ AddUndef(String *buff, const char *title
 static void
 DoCmdDefines(String *buff)
 {
-    int i;
-    char *arg, *val;
-
-    for (i = 0; i < num_cmd_defines; i++) {
-        arg = cmd_defines[i];
+    for (int i = 0; i < num_cmd_defines; i++) {
+        char *arg = cmd_defines[i];
         if (arg[1] == 'D') {
-            val = strchr(arg, '=');
+            char *val = strchr(arg, '=');
             if (val) {
                 *val = '\0';
                 AddDefQ(buff, arg + 2, val + 1);
@@ -647,8 +639,7 @@ DoScreenDefines(Display *display, int sc
     Screen *screen;
     Visual *visual;
     XVisualInfo vinfo, *vinfos;
-    int nv, i, j;
-    char name[50];
+    int nv;
 
     screen = ScreenOfDisplay(display, scrno);
     visual = DefaultVisualOfScreen(screen);
@@ -662,6 +653,8 @@ DoScreenDefines(Display *display, int sc
     AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
     AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
     if (visual->class >= 0 && visual->class < NUM_CLASS_NAMES) {
+        char name[50];
+
         AddDefQ(defs, "CLASS", ClassNames[visual->class]);
         snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
         AddNum(defs, name, (int) visual->visualid);
@@ -679,7 +672,9 @@ DoScreenDefines(Display *display, int sc
         AddSimpleDef(defs, "COLOR");
         break;
     }
-    for (i = 0; i < nv; i++) {
+    for (int i = 0; i < nv; i++) {
+        int j;
+
         for (j = i; --j >= 0;) {
             if (vinfos[j].class == vinfos[i].class &&
                 vinfos[j].depth == vinfos[i].depth)
@@ -687,6 +682,8 @@ DoScreenDefines(Display *display, int sc
         }
         if (j < 0) {
             if (vinfos[i].class >= 0 && vinfos[i].class < NUM_CLASS_NAMES) {
+                char name[50];
+
                 snprintf(name, sizeof(name), "CLASS_%s_%d",
                          ClassNames[vinfos[i].class], vinfos[i].depth);
                 AddNum(defs, name, (int) vinfos[i].visualid);
@@ -704,22 +701,23 @@ DoScreenDefines(Display *display, int sc
 static Entry *
 FindEntry(Entries *db, Buffer *b)
 {
-    size_t i;
-    register Entry *e;
-    Entries phoney;
-    Entry entry;
+    Entry entry = {
+        .usable = False,
+        .tag = NULL,
+        .value = NULL
+    };
+    Entries phoney = {
+        .used = 0,
+        .room = 1,
+        .entry = &entry
+    };
 
-    entry.usable = False;
-    entry.tag = NULL;
-    entry.value = NULL;
-    phoney.used = 0;
-    phoney.room = 1;
-    phoney.entry = &entry;
     GetEntries(&phoney, b, 1);
     if (phoney.used < 1)
         return NULL;
-    for (i = 0; i < db->used; i++) {
-        e = &db->entry[i];
+    for (size_t i = 0; i < db->used; i++) {
+        Entry *e = &db->entry[i];
+
         if (!e->usable)
             continue;
         if (strcmp(e->tag, entry.tag))
@@ -736,15 +734,16 @@ static void
 EditFile(Entries *new, FILE *in, FILE *out)
 {
     Buffer b;
-    char buff[BUFSIZ];
-    register Entry *e;
-    register char *c;
-    size_t i;
 
     InitBuffer(&b);
     while (in) {
+        Entry *e;
+
         b.used = 0;
         while (1) {
+            char *c;
+            char buff[BUFSIZ];
+
             buff[0] = '\0';
             if (!fgets(buff, BUFSIZ, in))
                 goto cleanup;
@@ -761,8 +760,8 @@ EditFile(Entries *new, FILE *in, FILE *o
             fwrite(b.buff, 1, b.used, out);
     }
  cleanup:
-    for (i = 0; i < new->used; i++) {
-        e = &new->entry[i];
+    for (size_t i = 0; i < new->used; i++) {
+        Entry *e = &new->entry[i];
         if (e->usable)
             fprintf(out, "%s:\t%s\n", e->tag, e->value);
     }
@@ -896,7 +895,6 @@ addtokstring(String *arg, const char *s)
 int
 main(int argc, char *argv[])
 {
-    int i;
     char *displayname = NULL;
     int whichResources = RALL;
     int retainProp = 0;
@@ -917,28 +915,27 @@ main(int argc, char *argv[])
     if (cpp_program == NULL) {
         int number_of_elements
             = (sizeof cpp_locations) / (sizeof cpp_locations[0]);
-        int j;
 
-        for (j = 0; j < number_of_elements; j++) {
-            char *end, *dup;
+        for (int j = 0; j < number_of_elements; j++) {
+            char *end, *cmd;
 
             /* cut off arguments */
-            dup = strdup(cpp_locations[j]);
-            end = strchr(dup, ' ');
+            cmd = strdup(cpp_locations[j]);
+            end = strchr(cmd, ' ');
             if (end)
                 *end = '\0';
-            if (access(dup, X_OK) == 0) {
+            if (access(cmd, X_OK) == 0) {
                 cpp_program = cpp_locations[j];
-                free(dup);
+                free(cmd);
                 break;
             }
-            free(dup);
+            free(cmd);
         }
     }
 
     /* needs to be replaced with XrmParseCommand */
 
-    for (i = 1; i < argc; i++) {
+    for (int i = 1; i < argc; i++) {
         char *arg = argv[i];



Home | Main Index | Thread Index | Old Index