Module Name:    xsrc
Committed By:   mrg
Date:           Thu Jul  4 08:18:12 UTC 2024

Modified Files:
        xsrc/external/mit/imake/include: config.h
        xsrc/external/mit/mkfontscale/dist: hash.c ident.c list.c mkfontscale.c
        xsrc/external/mit/xkbcomp/dist: expr.c utils.h

Log Message:
merge imake 1.0.10, mkfontscale 1.2.3, and xkbcomp 1.4.7.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 xsrc/external/mit/imake/include/config.h
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/mkfontscale/dist/hash.c \
    xsrc/external/mit/mkfontscale/dist/list.c
cvs rdiff -u -r1.7 -r1.8 xsrc/external/mit/mkfontscale/dist/ident.c
cvs rdiff -u -r1.10 -r1.11 xsrc/external/mit/mkfontscale/dist/mkfontscale.c
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/xkbcomp/dist/expr.c
cvs rdiff -u -r1.6 -r1.7 xsrc/external/mit/xkbcomp/dist/utils.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/imake/include/config.h
diff -u xsrc/external/mit/imake/include/config.h:1.7 xsrc/external/mit/imake/include/config.h:1.8
--- xsrc/external/mit/imake/include/config.h:1.7	Fri Nov 11 07:55:19 2022
+++ xsrc/external/mit/imake/include/config.h	Thu Jul  4 08:18:11 2024
@@ -41,7 +41,7 @@
 #define PACKAGE_NAME "imake"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "imake 1.0.9"
+#define PACKAGE_STRING "imake 1.0.10"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "imake"
@@ -50,7 +50,7 @@
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "1.0.9"
+#define PACKAGE_VERSION "1.0.10"
 
 /* Major version of this package */
 #define PACKAGE_VERSION_MAJOR 1
@@ -59,10 +59,10 @@
 #define PACKAGE_VERSION_MINOR 0
 
 /* Patch version of this package */
-#define PACKAGE_VERSION_PATCHLEVEL 9
+#define PACKAGE_VERSION_PATCHLEVEL 10
 
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
 
 /* Version number of package */
-#define VERSION "1.0.9"
+#define VERSION "1.0.10"

Index: xsrc/external/mit/mkfontscale/dist/hash.c
diff -u xsrc/external/mit/mkfontscale/dist/hash.c:1.2 xsrc/external/mit/mkfontscale/dist/hash.c:1.3
--- xsrc/external/mit/mkfontscale/dist/hash.c:1.2	Mon Mar 17 09:01:38 2014
+++ xsrc/external/mit/mkfontscale/dist/hash.c	Thu Jul  4 08:18:11 2024
@@ -37,17 +37,17 @@
 static unsigned
 hash(const char *string)
 {
-    int i;
     unsigned u = 0;
-    for(i = 0; string[i] != '\0'; i++)
-        u = (u<<5) + (u >> (LOG2_NUMBUCKETS - 5)) + (unsigned char)string[i];
+
+    for (int i = 0; string[i] != '\0'; i++)
+        u = (u << 5) + (u >> (LOG2_NUMBUCKETS - 5)) + (unsigned char) string[i];
     return (u & (NUMBUCKETS - 1));
 }
 
 static void
 str_tolower(char *s)
 {
-    while(*s != '\0') {
+    while (*s != '\0') {
         *s = tolower(*s);
         s++;
     }
@@ -62,12 +62,9 @@ makeHashTable(void)
 void
 destroyHashTable(HashTablePtr table)
 {
-    int i;
-    HashBucketPtr bp;
-
-    for(i = 0; i < NUMBUCKETS; i++) {
-        while(table[i]) {
-            bp = table[i];
+    for (int i = 0; i < NUMBUCKETS; i++) {
+        while (table[i]) {
+            HashBucketPtr bp = table[i];
             table[i] = table[i]->next;
             free(bp->key);
             free(bp->value);
@@ -81,9 +78,9 @@ char *
 getHash(HashTablePtr table, const char *key)
 {
     unsigned int i = hash(key);
-    HashBucketPtr bp;
-    for(bp = table[i]; bp; bp = bp->next) {
-        if(strcasecmp(bp->key, key) == 0)
+
+    for (HashBucketPtr bp = table[i]; bp; bp = bp->next) {
+        if (strcasecmp(bp->key, key) == 0)
             return bp->value;
     }
     return NULL;
@@ -95,14 +92,17 @@ putHash(HashTablePtr table, char *key, c
     unsigned int i = hash(key);
     char *keycopy = NULL, *valuecopy = NULL;
     HashBucketPtr bp;
-    for(bp = table[i]; bp; bp = bp->next) {
-        if(strcasecmp(bp->key, key) == 0) {
-            if(prio > bp->prio) {
+
+    for (bp = table[i]; bp; bp = bp->next) {
+        if (strcasecmp(bp->key, key) == 0) {
+            if (prio > bp->prio) {
                 keycopy = strdup(key);
-                if(keycopy == NULL) goto fail;
+                if (keycopy == NULL)
+                    goto fail;
                 str_tolower(keycopy);
                 valuecopy = strdup(value);
-                if(valuecopy == NULL) goto fail;
+                if (valuecopy == NULL)
+                    goto fail;
                 free(bp->key);
                 free(bp->value);
                 bp->key = keycopy;
@@ -112,14 +112,14 @@ putHash(HashTablePtr table, char *key, c
         }
     }
     keycopy = strdup(key);
-    if(keycopy == NULL)
+    if (keycopy == NULL)
         goto fail;
     str_tolower(keycopy);
     valuecopy = strdup(value);
-    if(valuecopy == NULL)
+    if (valuecopy == NULL)
         goto fail;
     bp = malloc(sizeof(HashBucketRec));
-    if(bp == NULL)
+    if (bp == NULL)
         goto fail;
     bp->key = keycopy;
     bp->value = valuecopy;
@@ -129,20 +129,20 @@ putHash(HashTablePtr table, char *key, c
     return 1;
 
  fail:
-    if(keycopy) free(keycopy);
-    if(valuecopy) free(valuecopy);
+    if (keycopy)
+        free(keycopy);
+    if (valuecopy)
+        free(valuecopy);
     return -1;
 }
 
 int
 hashElements(HashTablePtr table)
 {
-    int i, n;
-    HashBucketPtr bp;
+    int n = 0;
 
-    n = 0;
-    for(i = 0; i < NUMBUCKETS; i++) {
-        for(bp = table[i]; bp; bp = bp->next) {
+    for (int i = 0; i < NUMBUCKETS; i++) {
+        for (HashBucketPtr bp = table[i]; bp; bp = bp->next) {
             n++;
         }
     }
@@ -154,7 +154,9 @@ key_first_cmp(const void *v1, const void
 {
     const HashBucketPtr *b1 = v1, *b2 = v2;
     int c1 = strcasecmp((*b1)->key, (*b2)->key);
-    if(c1 != 0) return c1;
+
+    if (c1 != 0)
+        return c1;
     return strcmp((*b1)->value, (*b2)->value);
 }
 
@@ -163,24 +165,24 @@ value_first_cmp(const void *v1, const vo
 {
     const HashBucketPtr *b1 = v1, *b2 = v2;
     int c1 = strcmp((*b1)->value, (*b2)->value);
-    if(c1 != 0) return c1;
+
+    if (c1 != 0)
+        return c1;
     return strcasecmp((*b1)->key, (*b2)->key);
 }
 
 HashBucketPtr *
 hashArray(HashTablePtr table, int value_first)
 {
-    int i, j, n;
-    HashBucketPtr *dst;
-
-    n = hashElements(table);
-    dst = malloc((n + 1) * sizeof(HashBucketPtr));
-    if(dst == NULL)
+    unsigned int j;
+    int n = hashElements(table);
+    HashBucketPtr *dst = malloc((n + 1) * sizeof(HashBucketPtr));
+    if (dst == NULL)
         return NULL;
 
     j = 0;
-    for(i = 0; i < NUMBUCKETS; i++) {
-        while(table[i]) {
+    for (unsigned int i = 0; i < NUMBUCKETS; i++) {
+        while (table[i]) {
             dst[j++] = table[i];
             table[i] = table[i]->next;
         }
@@ -196,8 +198,9 @@ hashArray(HashTablePtr table, int value_
 void
 destroyHashArray(HashBucketPtr *array)
 {
-    int i = 0;
-    while(array[i]) {
+    unsigned int i = 0;
+
+    while (array[i]) {
         free(array[i]->key);
         free(array[i]->value);
         free(array[i]);
Index: xsrc/external/mit/mkfontscale/dist/list.c
diff -u xsrc/external/mit/mkfontscale/dist/list.c:1.2 xsrc/external/mit/mkfontscale/dist/list.c:1.3
--- xsrc/external/mit/mkfontscale/dist/list.c:1.2	Sun Mar  3 09:27:12 2019
+++ xsrc/external/mit/mkfontscale/dist/list.c	Thu Jul  4 08:18:11 2024
@@ -33,8 +33,8 @@
 int
 listMember(const char *elt, ListPtr list)
 {
-    while(list != NULL) {
-        if(strcmp(elt, list->value) == 0)
+    while (list != NULL) {
+        if (strcmp(elt, list->value) == 0)
             return 1;
         list = list->next;
     }
@@ -45,17 +45,18 @@ ListPtr
 listCons(char *car, ListPtr cdr)
 {
     ListPtr lcar = malloc(sizeof(ListRec));
-    if(!lcar)
+
+    if (!lcar)
         return NULL;
-    lcar -> value = car;
-    lcar -> next = cdr;
+    lcar->value = car;
+    lcar->next = cdr;
     return lcar;
 }
 
 ListPtr
 listAdjoin(char *car, ListPtr cdr)
 {
-    if(listMember(car, cdr)) {
+    if (listMember(car, cdr)) {
         free(car);
         return cdr;
     }
@@ -67,6 +68,7 @@ dsprintf(const char *f, ...)
 {
     va_list args;
     char *string;
+
 #ifdef HAVE_VASPRINTF
     va_start(args, f);
     if (vasprintf(&string, f, args) == -1)
@@ -75,53 +77,55 @@ dsprintf(const char *f, ...)
     return string;
 #else
     {
-	int n, size = 20;
-	while(1) {
-	    if(size > 4096)
-		return NULL;
-	    string = malloc(size);
-	    if(!string)
-		return NULL;
-	    va_start(args, f);
-	    n = vsnprintf(string, size, f, args);
-	    va_end(args);
-	    if(n >= 0 && n < size)
+        int n, size = 20;
+
+        while (1) {
+            if (size > 4096)
+                return NULL;
+            string = malloc(size);
+            if (!string)
+                return NULL;
+            va_start(args, f);
+            n = vsnprintf(string, size, f, args);
+            va_end(args);
+            if (n >= 0 && n < size)
                 return string;
-	    else if(n >= size)
-		size = n + 1;
-	    else
-		size = size * 3 / 2 + 1;
-	    free(string);
-	}
+            else if (n >= size)
+                size = n + 1;
+            else
+                size = size * 3 / 2 + 1;
+            free(string);
+        }
     }
 #endif
 }
 
-
 ListPtr
 listConsF(ListPtr cdr, const char *f, ...)
 {
     va_list args;
     char *string;
+
     {
-	int n, size = 20;
-	while(1) {
-	    if(size > 4096)
-		return NULL;
-	    string = malloc(size);
-	    if(!string)
-		return NULL;
-	    va_start(args, f);
-	    n = vsnprintf(string, size, f, args);
-	    va_end(args);
-	    if(n >= 0 && n < size)
-		return listCons(string, cdr);
-	    else if(n >= size)
-		size = n + 1;
-	    else
-		size = size * 3 / 2 + 1;
-	    free(string);
-	}
+        int n, size = 20;
+
+        while (1) {
+            if (size > 4096)
+                return NULL;
+            string = malloc(size);
+            if (!string)
+                return NULL;
+            va_start(args, f);
+            n = vsnprintf(string, size, f, args);
+            va_end(args);
+            if (n >= 0 && n < size)
+                return listCons(string, cdr);
+            else if (n >= size)
+                size = n + 1;
+            else
+                size = size * 3 / 2 + 1;
+            free(string);
+        }
     }
 }
 
@@ -130,25 +134,27 @@ listAdjoinF(ListPtr cdr, const char *f, 
 {
     va_list args;
     char *string;
+
     {
-	int n, size = 20;
-	while(1) {
-	    if(size > 4096)
-		return NULL;
-	    string = malloc(size);
-	    if(!string)
-		return NULL;
-	    va_start(args, f);
-	    n = vsnprintf(string, size, f, args);
-	    va_end(args);
-	    if(n >= 0 && n < size)
-		return listAdjoin(string, cdr);
-	    else if(n >= size)
-		size = n + 1;
-	    else
-		size = size * 3 / 2 + 1;
-	    free(string);
-	}
+        int n, size = 20;
+
+        while (1) {
+            if (size > 4096)
+                return NULL;
+            string = malloc(size);
+            if (!string)
+                return NULL;
+            va_start(args, f);
+            n = vsnprintf(string, size, f, args);
+            va_end(args);
+            if (n >= 0 && n < size)
+                return listAdjoin(string, cdr);
+            else if (n >= size)
+                size = n + 1;
+            else
+                size = size * 3 / 2 + 1;
+            free(string);
+        }
     }
 }
 
@@ -156,7 +162,8 @@ int
 listLength(ListPtr list)
 {
     int n = 0;
-    while(list) {
+
+    while (list) {
         n++;
         list = list->next;
     }
@@ -168,14 +175,13 @@ appendList(ListPtr first, ListPtr second
 {
     ListPtr current;
 
-    if(second == NULL)
+    if (second == NULL)
         return first;
 
-    if(first == NULL)
+    if (first == NULL)
         return second;
 
-    for(current = first; current->next; current = current->next)
-        ;
+    for (current = first; current->next; current = current->next);
 
     current->next = second;
     return first;
@@ -187,20 +193,20 @@ makeList(char **a, int n, ListPtr old, i
     ListPtr first, current, next;
     int i;
 
-    if(n == 0)
+    if (n == 0)
         return old;
 
     first = malloc(sizeof(ListRec));
-    if(!first)
+    if (!first)
         return NULL;
 
     first->value = a[0];
     first->next = NULL;
 
     current = first;
-    for(i = 1; i < n; i++) {
+    for (i = 1; i < n; i++) {
         next = malloc(sizeof(ListRec));
-        if(!next) {
+        if (!next) {
             destroyList(first);
             return NULL;
         }
@@ -210,10 +216,11 @@ makeList(char **a, int n, ListPtr old, i
         current->next = next;
         current = next;
     }
-    if(begin) {
+    if (begin) {
         current->next = old;
         return first;
-    } else {
+    }
+    else {
         return appendList(old, first);
     }
 }
@@ -222,7 +229,8 @@ ListPtr
 reverseList(ListPtr old)
 {
     ListPtr new = NULL, current;
-    while(old) {
+
+    while (old) {
         current = old;
         old = old->next;
         current->next = new;
@@ -263,7 +271,7 @@ sortList(ListPtr old)
     qsort(sorted, i, sizeof(ListPtr), compareListEntries);
     n = sorted[0];
     for (i = 0; i < (l - 1); i++) {
-        sorted[i]->next = sorted[i+1];
+        sorted[i]->next = sorted[i + 1];
     }
     sorted[i]->next = NULL;
     free(sorted);
@@ -274,9 +282,10 @@ void
 destroyList(ListPtr old)
 {
     ListPtr next;
-    if(!old)
+
+    if (!old)
         return;
-    while(old) {
+    while (old) {
         next = old->next;
         free(old);
         old = next;
@@ -287,9 +296,10 @@ void
 deepDestroyList(ListPtr old)
 {
     ListPtr next;
-    if(!old)
+
+    if (!old)
         return;
-    while(old) {
+    while (old) {
         next = old->next;
         free(old->value);
         free(old);

Index: xsrc/external/mit/mkfontscale/dist/ident.c
diff -u xsrc/external/mit/mkfontscale/dist/ident.c:1.7 xsrc/external/mit/mkfontscale/dist/ident.c:1.8
--- xsrc/external/mit/mkfontscale/dist/ident.c:1.7	Sun Mar  3 09:18:36 2019
+++ xsrc/external/mit/mkfontscale/dist/ident.c	Thu Jul  4 08:18:11 2024
@@ -20,7 +20,7 @@
   THE SOFTWARE.
 */
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, Oracle and/or its affiliates.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -57,7 +57,7 @@
 #include "ident.h"
 
 #ifdef X_BZIP2_FONT_COMPRESSION
-# include <bzlib.h>
+#include <bzlib.h>
 #endif
 
 #define PCF_VERSION (('p'<<24)|('c'<<16)|('f'<<8)|1)
@@ -73,25 +73,27 @@ typedef struct _Prop {
 typedef struct {
     enum { gzFontFile, bz2FontFile } type;
     union {
-	gzFile gz;
-	BZFILE *bz2;
+        gzFile gz;
+        BZFILE *bz2;
     } f;
     unsigned long pos;
 } fontFile;
 
 static inline void *
-fontFileOpen(fontFile *ff, const char *filename) {
+fontFileOpen(fontFile *ff, const char *filename)
+{
     size_t n = strlen(filename);
 
     if (n > 4 && strcmp(filename + n - 4, ".bz2") == 0) {
-	ff->type = bz2FontFile;
-	ff->f.bz2 = BZ2_bzopen(filename, "rb");
-	ff->pos = 0;
-	return ff->f.bz2;
-    } else {
-	ff->type = gzFontFile;
-	ff->f.gz = gzopen(filename, "rb");
-	return ff->f.gz;
+        ff->type = bz2FontFile;
+        ff->f.bz2 = BZ2_bzopen(filename, "rb");
+        ff->pos = 0;
+        return ff->f.bz2;
+    }
+    else {
+        ff->type = gzFontFile;
+        ff->f.gz = gzopen(filename, "rb");
+        return ff->f.gz;
     }
 }
 
@@ -99,11 +101,13 @@ static inline int
 fontFileRead(fontFile *ff, void *buf, unsigned len)
 {
     if (ff->type == gzFontFile) {
-	return gzread(ff->f.gz, buf, len);
-    } else {
-	int r = BZ2_bzread(ff->f.bz2, buf, len);
-	ff->pos += r;
-	return r;
+        return gzread(ff->f.gz, buf, len);
+    }
+    else {
+        int r = BZ2_bzread(ff->f.bz2, buf, len);
+
+        ff->pos += r;
+        return r;
     }
 }
 
@@ -111,15 +115,18 @@ static inline int
 fontFileGetc(fontFile *ff)
 {
     if (ff->type == gzFontFile) {
-	return gzgetc(ff->f.gz);
-    } else {
-	char buf;
-	if (BZ2_bzread(ff->f.bz2, &buf, 1) != 1) {
-	    return -1;
-	} else {
-	    ff->pos += 1;
-	    return (int) buf;
-	}
+        return gzgetc(ff->f.gz);
+    }
+    else {
+        char buf;
+
+        if (BZ2_bzread(ff->f.bz2, &buf, 1) != 1) {
+            return -1;
+        }
+        else {
+            ff->pos += 1;
+            return (int) buf;
+        }
     }
 }
 
@@ -127,56 +134,58 @@ static long
 fontFileSeek(fontFile *ff, z_off_t offset, int whence)
 {
     if (ff->type == gzFontFile) {
-	return gzseek(ff->f.gz, offset, whence);
-    } else {
-	/* bzlib has no easy equivalent so we have to fake it,
-	 * fortunately, we only have to handle a couple of cases
-	 */
-	z_off_t n;
-	char buf[BUFSIZ];
-
-	switch (whence) {
-	  case SEEK_SET:
-	    n = offset - ff->pos;
-	    break;
-	  case SEEK_CUR:
-	    n = offset;
-	    break;
-	  default:
-	    return -1;
-	}
-
-	while (n > BUFSIZ) {
-	    if (BZ2_bzread(ff->f.bz2, buf, BUFSIZ) != BUFSIZ)
-		return -1;
-	    n -= BUFSIZ;
-	}
-	if (BZ2_bzread(ff->f.bz2, buf, (int) n) != n)
-	    return -1;
-	ff->pos = offset;
-	return offset;
+        return gzseek(ff->f.gz, offset, whence);
     }
-}
+    else {
+        /* bzlib has no easy equivalent so we have to fake it,
+         * fortunately, we only have to handle a couple of cases
+         */
+        z_off_t n;
+        char buf[BUFSIZ];
+
+        switch (whence) {
+        case SEEK_SET:
+            n = offset - ff->pos;
+            break;
+        case SEEK_CUR:
+            n = offset;
+            break;
+        default:
+            return -1;
+        }
 
+        while (n > BUFSIZ) {
+            if (BZ2_bzread(ff->f.bz2, buf, BUFSIZ) != BUFSIZ)
+                return -1;
+            n -= BUFSIZ;
+        }
+        if (BZ2_bzread(ff->f.bz2, buf, (int) n) != n)
+            return -1;
+        ff->pos = offset;
+        return offset;
+    }
+}
 
 static inline int
 fontFileClose(fontFile *ff)
 {
     if (ff->type == gzFontFile) {
-	return gzclose(ff->f.gz);
-    } else {
-	BZ2_bzclose(ff->f.bz2);
-	return 0;
+        return gzclose(ff->f.gz);
+    }
+    else {
+        BZ2_bzclose(ff->f.bz2);
+        return 0;
     }
 }
 
-#else /* no bzip2, only gzip */
+#else                           /* no bzip2, only gzip */
 typedef gzFile fontFile;
-# define fontFileOpen(ff, filename)	(*(ff) = gzopen(filename, "rb"))
-# define fontFileRead(ff, buf, len)	gzread(*(ff), buf, len)
-# define fontFileGetc(ff)		gzgetc(*(ff))
-# define fontFileSeek(ff, off, whence)	gzseek(*(ff), off, whence)
-# define fontFileClose(ff)		gzclose(*(ff))
+
+#define fontFileOpen(ff, filename)	(*(ff) = gzopen(filename, "rb"))
+#define fontFileRead(ff, buf, len)	gzread(*(ff), buf, len)
+#define fontFileGetc(ff)		gzgetc(*(ff))
+#define fontFileSeek(ff, off, whence)	gzseek(*(ff), off, whence)
+#define fontFileClose(ff)		gzclose(*(ff))
 #endif
 
 static int pcfIdentify(fontFile *f, char **name);
@@ -189,7 +198,7 @@ getLSB32(fontFile *f)
     unsigned char c[4];
 
     rc = fontFileRead(f, c, 4);
-    if(rc != 4)
+    if (rc != 4)
         return -1;
     return (c[0]) | (c[1] << 8) | (c[2] << 16) | (c[3] << 24);
 }
@@ -201,7 +210,7 @@ getInt8(fontFile *f, int format)
     int rc;
 
     rc = fontFileRead(f, &c, 1);
-    if(rc != 1)
+    if (rc != 1)
         return -1;
     return c;
 }
@@ -213,13 +222,17 @@ getInt32(fontFile *f, int format)
     unsigned char c[4];
 
     rc = fontFileRead(f, c, 4);
-    if(rc != 4)
+    if (rc != 4)
         return -1;
+    else {
+        unsigned int u[4] = { c[0], c[1], c[2], c[3] };
 
-    if(format & (1 << 2)) {
-        return (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | (c[3]);
-    } else {
-        return (c[0]) | (c[1] << 8) | (c[2] << 16) | (c[3] << 24);
+        if (format & (1 << 2)) {
+            return (int) ((u[0] << 24) | (u[1] << 16) | (u[2] << 8) | (u[3]));
+        }
+        else {
+            return (int) ((u[0]) | (u[1] << 8) | (u[2] << 16) | (u[3] << 24));
+        }
     }
 }
 
@@ -230,12 +243,12 @@ bitmapIdentify(const char *filename, cha
     int magic;
 
     if (fontFileOpen(&ff, filename) == NULL)
-	return -1;
+        return -1;
 
     magic = getLSB32(&ff);
-    if(magic == PCF_VERSION)
+    if (magic == PCF_VERSION)
         return pcfIdentify(&ff, name);
-    else if(magic == ('S' | ('T' << 8) | ('A' << 16) | ('R') << 24))
+    else if (magic == ('S' | ('T' << 8) | ('A' << 16) | ('R') << 24))
         return bdfIdentify(&ff, name);
 
     fontFileClose(&ff);
@@ -252,74 +265,74 @@ pcfIdentify(fontFile *f, char **name)
     char *strings = NULL, *s;
 
     count = getLSB32(f);
-    if(count <= 0)
+    if (count <= 0)
         goto fail;
 
     prop_position = -1;
-    for(i = 0; i < count; i++) {
+    for (i = 0; i < count; i++) {
         int type, offset;
+
         type = getLSB32(f);
         (void) getLSB32(f);
         (void) getLSB32(f);
         offset = getLSB32(f);
-        if(type == PCF_PROPERTIES) {
+        if (type == PCF_PROPERTIES) {
             prop_position = offset;
             break;
         }
     }
-    if(prop_position < 0)
+    if (prop_position < 0)
         goto fail;
 
     rc = fontFileSeek(f, prop_position, SEEK_SET);
-    if(rc < 0)
+    if (rc < 0)
         goto fail;
 
     format = getLSB32(f);
-    if((format & 0xFFFFFF00) != 0)
+    if ((format & 0xFFFFFF00) != 0)
         goto fail;
     nprops = getInt32(f, format);
-    if(nprops <= 0 || nprops > 1000)
+    if (nprops <= 0 || nprops > 1000)
         goto fail;
     props = malloc(nprops * sizeof(PropRec));
-    if(props == NULL)
+    if (props == NULL)
         goto fail;
 
-    for(i = 0; i < nprops; i++) {
+    for (i = 0; i < nprops; i++) {
         props[i].name = getInt32(f, format);
         props[i].isString = getInt8(f, format);
         props[i].value = getInt32(f, format);
     }
-    if(nprops & 3) {
-	rc = fontFileSeek(f, 4 - (nprops & 3), SEEK_CUR);
-        if(rc < 0)
+    if (nprops & 3) {
+        rc = fontFileSeek(f, 4 - (nprops & 3), SEEK_CUR);
+        if (rc < 0)
             goto fail;
     }
 
     string_size = getInt32(f, format);
-    if(string_size < 0 || string_size > 100000)
+    if (string_size < 0 || string_size > 100000)
         goto fail;
     strings = malloc(string_size);
-    if(!strings)
+    if (!strings)
         goto fail;
 
     rc = fontFileRead(f, strings, string_size);
-    if(rc != string_size)
+    if (rc != string_size)
         goto fail;
 
-    for(i = 0; i < nprops; i++) {
-        if(!props[i].isString ||
-           props[i].name >= string_size - 4 ||
-           props[i].value >= string_size)
+    for (i = 0; i < nprops; i++) {
+        if (!props[i].isString ||
+            props[i].name >= string_size - 4 || props[i].value >= string_size)
             continue;
-        if(strcmp(strings + props[i].name, "FONT") == 0)
+        if (strcmp(strings + props[i].name, "FONT") == 0)
             break;
     }
 
-    if(i >= nprops)
+    if (i >= nprops)
         goto fail;
 
     s = strdup(strings + props[i].value);
-    if(s == NULL)
+    if (s == NULL)
         goto fail;
     *name = s;
     free(strings);
@@ -328,31 +341,33 @@ pcfIdentify(fontFile *f, char **name)
     return 1;
 
  fail:
-    if(strings) free(strings);
-    if(props) free(props);
+    if (strings)
+        free(strings);
+    if (props)
+        free(props);
     fontFileClose(f);
     return 0;
 }
 
 #define NKEY 20
 
-static char*
+static char *
 getKeyword(fontFile *f, int *eol)
 {
     static char keyword[NKEY + 1];
-    int c, i;
-    i = 0;
-    while(i < NKEY) {
-        c = fontFileGetc(f);
-        if(c == ' ' || c == '\n') {
-            if(i <= 0)
+    int i = 0;
+
+    while (i < NKEY) {
+        int c = fontFileGetc(f);
+        if (c == ' ' || c == '\n') {
+            if (i <= 0)
                 return NULL;
-            if(eol)
+            if (eol)
                 *eol = (c == '\n');
             keyword[i] = '\0';
             return keyword;
         }
-        if(c < 'A' || c > 'Z')
+        if (c < 'A' || c > 'Z')
             return NULL;
         keyword[i++] = c;
     }
@@ -363,10 +378,11 @@ static int
 bdfskip(fontFile *f)
 {
     int c;
+
     do {
         c = fontFileGetc(f);
-    } while(c >= 0 && c != '\n');
-    if(c < 0)
+    } while (c >= 0 && c != '\n');
+    if (c < 0)
         return -1;
     return 1;
 }
@@ -376,31 +392,33 @@ bdfend(fontFile *f)
 {
     int c;
     char *buf = NULL;
-    int bufsize = 0;
-    int i = 0;
+    size_t bufsize = 0;
+    unsigned int i = 0;
 
     do {
         c = fontFileGetc(f);
     } while (c == ' ');
 
-    while(i < 1000) {
-        if(c < 0 || (c == '\n' && i == 0)) {
+    while (i < 1000) {
+        if (c < 0 || (c == '\n' && i == 0)) {
             goto fail;
         }
-        if(bufsize < i + 1) {
+        if (bufsize < i + 1) {
             char *newbuf;
-            if(bufsize == 0) {
+
+            if (bufsize == 0) {
                 bufsize = 20;
                 newbuf = malloc(bufsize);
-            } else {
+            }
+            else {
                 bufsize = 2 * bufsize;
                 newbuf = realloc(buf, bufsize);
             }
-            if(newbuf == NULL)
+            if (newbuf == NULL)
                 goto fail;
             buf = newbuf;
         }
-        if(c == '\n') {
+        if (c == '\n') {
             buf[i] = '\0';
             return buf;
         }
@@ -409,7 +427,7 @@ bdfend(fontFile *f)
     }
 
  fail:
-    if(buf)
+    if (buf)
         free(buf);
     return NULL;
 }
@@ -418,34 +436,35 @@ static int
 bdfIdentify(fontFile *f, char **name)
 {
     char *k;
-    int rc;
     int eol;
+
     /* bitmapIdentify already read "STAR", so we need to check for
        "TFONT" */
     k = getKeyword(f, &eol);
-    if(k == NULL || eol)
+    if (k == NULL || eol)
         goto fail;
-    if(strcmp(k, "TFONT") != 0)
+    if (strcmp(k, "TFONT") != 0)
         goto fail;
-    while(1) {
-        if(!eol) {
-            rc = bdfskip(f);
-            if(rc < 0)
+    while (1) {
+        if (!eol) {
+            int rc = bdfskip(f);
+            if (rc < 0)
                 goto fail;
         }
         k = getKeyword(f, &eol);
-        if(k == NULL)
+        if (k == NULL)
             goto fail;
-        else if(strcmp(k, "FONT") == 0) {
-            if(eol)
+        else if (strcmp(k, "FONT") == 0) {
+            if (eol)
                 goto fail;
             k = bdfend(f);
-            if(k == NULL)
+            if (k == NULL)
                 goto fail;
             *name = k;
             fontFileClose(f);
             return 1;
-        } else if(strcmp(k, "CHARS") == 0)
+        }
+        else if (strcmp(k, "CHARS") == 0)
             goto fail;
     }
  fail:

Index: xsrc/external/mit/mkfontscale/dist/mkfontscale.c
diff -u xsrc/external/mit/mkfontscale/dist/mkfontscale.c:1.10 xsrc/external/mit/mkfontscale/dist/mkfontscale.c:1.11
--- xsrc/external/mit/mkfontscale/dist/mkfontscale.c:1.10	Mon Jul 11 09:13:30 2022
+++ xsrc/external/mit/mkfontscale/dist/mkfontscale.c	Thu Jul  4 08:18:11 2024
@@ -68,24 +68,24 @@
 #define QUOTE(x)	#x
 #define STRINGIFY(x)	QUOTE(x)
 
-static const char *encodings_array[] =
-    { "ascii-0",
-      "iso8859-1", "iso8859-2", "iso8859-3", "iso8859-4", "iso8859-5",
-      "iso8859-6", "iso8859-6.8", "iso8859-6.8x", "iso8859-6.16",
-      "iso8859-7", "iso8859-8", "iso8859-9", "iso8859-10",
-      "iso8859-11", "iso8859-12", "iso8859-13", "iso8859-14",
-      "iso8859-15", "iso8859-16",
-      "ansi-1251", "koi8-r", "koi8-u", "koi8-ru", "koi8-e", "koi8-uni",
-      "tis620-2",
-      "sun.unicode.india-0", "suneu-greek",
-      "adobe-standard", "adobe-symbol",
-      "ibm-cp437", "ibm-cp850", "ibm-cp852", "ibm-cp866", "microsoft-cp1252",
-      /* But not "adobe-dingbats", as it uses generic glyph names. */
-      "cns11643-1", "cns11643-2", "cns11643-3",
-      "jisx0201.1976-0", "jisx0208.1983-0", "jisx0208.1990-0",
-      "jisx0212.1990-0", "big5-0", "big5.eten-0", "big5hkscs-0",
-      "gb2312.1980-0", "gb18030.2000-0", "gb18030.2000-1",
-      "ksc5601.1987-0", "ksc5601.1992-3"};
+static const char *encodings_array[] = { "ascii-0",
+    "iso8859-1", "iso8859-2", "iso8859-3", "iso8859-4", "iso8859-5",
+    "iso8859-6", "iso8859-6.8", "iso8859-6.8x", "iso8859-6.16",
+    "iso8859-7", "iso8859-8", "iso8859-9", "iso8859-10",
+    "iso8859-11", "iso8859-12", "iso8859-13", "iso8859-14",
+    "iso8859-15", "iso8859-16",
+    "ansi-1251", "koi8-r", "koi8-u", "koi8-ru", "koi8-e", "koi8-uni",
+    "tis620-2",
+    "sun.unicode.india-0", "suneu-greek",
+    "adobe-standard", "adobe-symbol",
+    "ibm-cp437", "ibm-cp850", "ibm-cp852", "ibm-cp866", "microsoft-cp1252",
+    /* But not "adobe-dingbats", as it uses generic glyph names. */
+    "cns11643-1", "cns11643-2", "cns11643-3",
+    "jisx0201.1976-0", "jisx0208.1983-0", "jisx0208.1990-0",
+    "jisx0212.1990-0", "big5-0", "big5.eten-0", "big5hkscs-0",
+    "gb2312.1980-0", "gb18030.2000-0", "gb18030.2000-1",
+    "ksc5601.1987-0", "ksc5601.1992-3"
+};
 
 static const char *extra_encodings_array[] =
     { "iso10646-1", "adobe-fontspecific", "microsoft-symbol" };
@@ -95,25 +95,25 @@ static const char *outfilename;
 
 #define countof(_a) (sizeof(_a)/sizeof((_a)[0]))
 
-static int doDirectory(const char*, int, ListPtr);
+static int doDirectory(const char *, int, ListPtr);
 static int checkEncoding(FT_Face face, const char *encoding_name);
-static int checkExtraEncoding(FT_Face face, const char *encoding_name, int found);
+static int checkExtraEncoding(FT_Face face, const char *encoding_name,
+                              int found);
 static int find_cmap(int type, int pid, int eid, FT_Face face);
-static const char* notice_foundry(const char *notice);
-static const char* vendor_foundry(const signed char *vendor);
+static const char *notice_foundry(const char *notice);
+static const char *vendor_foundry(const signed char *vendor);
 static int readFontScale(HashTablePtr entries, char *dirname);
 ListPtr makeXLFD(char *filename, FT_Face face, int);
-static int readEncodings(ListPtr encodings, char *dirname);
+static int readEncodings(ListPtr *encodingsToDo, char *dirname);
 
 static FT_Library ft_library;
-static float bigEncodingFuzz = 0.02;
+static float bigEncodingFuzz = 0.02f;
 
 static int relative;
 static int doScalable;
 static int doBitmaps;
 static int doISO10646_1_encoding;
 static int onlyEncodings;
-static ListPtr encodingsToDo;
 static int reencodeLegacy;
 static char *encodingPrefix;
 static char *exclusionSuffix;
@@ -131,7 +131,7 @@ usage(void)
 }
 
 static void _X_NORETURN _X_COLD
-missing_arg (const char *option)
+missing_arg(const char *option)
 {
     fprintf(stderr, "%s: %s requires an argument\n", ProgramName, option);
     usage();
@@ -142,29 +142,30 @@ main(int argc, char **argv)
 {
     int argn;
     FT_Error ftrc;
-    int rc, ll = 0;
+    int ll = 0;
+    ListPtr encodingsToDo;
     char prefix[NPREFIX];
 
     ProgramName = argv[0];
     encodingPrefix = NULL;
     exclusionSuffix = NULL;
 
-    if(getcwd(prefix, NPREFIX - 1) == NULL) {
+    if (getcwd(prefix, NPREFIX - 1) == NULL) {
         perror("Couldn't get cwd");
         exit(1);
     }
-    if(prefix[strlen(prefix) - 1] != '/')
+    if (prefix[strlen(prefix) - 1] != '/')
         encodingPrefix = dsprintf("%s/", prefix);
     else
         encodingPrefix = strdup(prefix);
 
     outfilename = NULL;
 
-    encodings = makeConstList(encodings_array, countof(encodings_array), NULL, 0);
+    encodings =
+        makeConstList(encodings_array, countof(encodings_array), NULL, 0);
 
     extra_encodings = makeConstList(extra_encodings_array,
-				    countof(extra_encodings_array),
-				    NULL, 0);
+                                    countof(extra_encodings_array), NULL, 0);
     doBitmaps = 0;
     doISO10646_1_encoding = 1;
     doScalable = 1;
@@ -174,29 +175,32 @@ main(int argc, char **argv)
     encodingsToDo = NULL;
 
     argn = 1;
-    while(argn < argc) {
-        if(argv[argn][0] == '\0' || argv[argn][0] != '-')
+    while (argn < argc) {
+        if (argv[argn][0] == '\0' || argv[argn][0] != '-')
             break;
-        if(argv[argn][1] == '-') {
+        if (argv[argn][1] == '-') {
             argn++;
             break;
-        } else if (strcmp(argv[argn], "-x") == 0) {
-            if(argn >= argc - 1) {
+        }
+        else if (strcmp(argv[argn], "-x") == 0) {
+            if (argn >= argc - 1) {
                 missing_arg("-x");
             }
             exclusionSuffix = argv[argn + 1];
             argn += 2;
-        } else if(strcmp(argv[argn], "-a") == 0) {
-            if(argn >= argc - 1) {
+        }
+        else if (strcmp(argv[argn], "-a") == 0) {
+            if (argn >= argc - 1) {
                 missing_arg("-a");
             }
-            makeConstList((const char **)&argv[argn + 1], 1, encodings, 0);
+            makeConstList((const char **) &argv[argn + 1], 1, encodings, 0);
             argn += 2;
-        } else if(strcmp(argv[argn], "-p") == 0) {
-            if(argn >= argc - 1) {
+        }
+        else if (strcmp(argv[argn], "-p") == 0) {
+            if (argn >= argc - 1) {
                 missing_arg("-p");
             }
-            if(strlen(argv[argn + 1]) > NPREFIX - 1) {
+            if (strlen(argv[argn + 1]) > NPREFIX - 1) {
                 fprintf(stderr, "%s: argument to -p cannot be longer than "
                         "%d characters\n", ProgramName, NPREFIX - 1);
                 usage();
@@ -204,64 +208,78 @@ main(int argc, char **argv)
             free(encodingPrefix);
             encodingPrefix = strdup(argv[argn + 1]);
             argn += 2;
-        } else if(strcmp(argv[argn], "-e") == 0) {
-            if(argn >= argc - 1) {
+        }
+        else if (strcmp(argv[argn], "-e") == 0) {
+            int rc;
+
+            if (argn >= argc - 1) {
                 missing_arg("-e");
             }
-            rc = readEncodings(encodingsToDo, argv[argn + 1]);
-            if(rc < 0)
+            rc = readEncodings(&encodingsToDo, argv[argn + 1]);
+            if (rc < 0)
                 exit(1);
             argn += 2;
-        } else if(strcmp(argv[argn], "-b") == 0) {
+        }
+        else if (strcmp(argv[argn], "-b") == 0) {
             doBitmaps = 1;
             argn++;
-        } else if(strcmp(argv[argn], "-u") == 0) {
+        }
+        else if (strcmp(argv[argn], "-u") == 0) {
             doISO10646_1_encoding = 0;
             argn++;
-        } else if(strcmp(argv[argn], "-U") == 0) {
+        }
+        else if (strcmp(argv[argn], "-U") == 0) {
             doISO10646_1_encoding = 1;
             argn++;
-        } else if(strcmp(argv[argn], "-s") == 0) {
+        }
+        else if (strcmp(argv[argn], "-s") == 0) {
             doScalable = 0;
             argn++;
-        } else if(strcmp(argv[argn], "-n") == 0) {
+        }
+        else if (strcmp(argv[argn], "-n") == 0) {
             onlyEncodings = 1;
             argn++;
-        } else if(strcmp(argv[argn], "-r") == 0) {
+        }
+        else if (strcmp(argv[argn], "-r") == 0) {
             relative = 1;
             argn++;
-        } else if(strcmp(argv[argn], "-l") == 0) {
+        }
+        else if (strcmp(argv[argn], "-l") == 0) {
             reencodeLegacy = !reencodeLegacy;
             argn++;
-        } else if(strcmp(argv[argn], "-o") == 0) {
-            if(argn >= argc - 1) {
+        }
+        else if (strcmp(argv[argn], "-o") == 0) {
+            if (argn >= argc - 1) {
                 missing_arg("-o");
             }
             outfilename = argv[argn + 1];
             argn += 2;
-        } else if(strcmp(argv[argn], "-f") == 0) {
-            if(argn >= argc - 1) {
+        }
+        else if (strcmp(argv[argn], "-f") == 0) {
+            if (argn >= argc - 1) {
                 missing_arg("-f");
             }
-            bigEncodingFuzz = atof(argv[argn + 1]) / 100.0;
+            bigEncodingFuzz = strtof(argv[argn + 1], NULL) / 100.0f;
             argn += 2;
-	} else if (strcmp(argv[argn], "-v") == 0) {
-	    printf("%s\n", PACKAGE_STRING);
-	    exit(0);
-	} else {
+        }
+        else if (strcmp(argv[argn], "-v") == 0) {
+            printf("%s\n", PACKAGE_STRING);
+            exit(0);
+        }
+        else {
             usage();
         }
     }
 
-    if(outfilename == NULL) {
-        if(doBitmaps)
+    if (outfilename == NULL) {
+        if (doBitmaps)
             outfilename = "fonts.dir";
         else
             outfilename = "fonts.scale";
     }
 
     ftrc = FT_Init_FreeType(&ft_library);
-    if(ftrc) {
+    if (ftrc) {
         fprintf(stderr, "Could not initialise FreeType library: %d\n", ftrc);
         exit(1);
     }
@@ -271,7 +289,7 @@ main(int argc, char **argv)
     if (argn == argc)
         doDirectory(".", ll, encodingsToDo);
     else
-        while(argn < argc) {
+        while (argn < argc) {
             doDirectory(argv[argn], ll, encodingsToDo);
             argn++;
         }
@@ -283,33 +301,32 @@ getNameHelper(FT_Face face, int nid, int
               FT_SfntName *name_return)
 {
     FT_SfntName name;
-    int n, i;
+    int n;
 
     n = FT_Get_Sfnt_Name_Count(face);
-    if(n <= 0)
+    if (n <= 0)
         return 0;
 
-    for(i = 0; i < n; i++) {
-        if(FT_Get_Sfnt_Name(face, i, &name))
+    for (int i = 0; i < n; i++) {
+        if (FT_Get_Sfnt_Name(face, i, &name))
             continue;
-        if(name.name_id == nid &&
-           name.platform_id == pid &&
-           (eid < 0 || name.encoding_id == eid)) {
-            switch(name.platform_id) {
+        if (name.name_id == nid &&
+            name.platform_id == pid && (eid < 0 || name.encoding_id == eid)) {
+            switch (name.platform_id) {
             case TT_PLATFORM_APPLE_UNICODE:
             case TT_PLATFORM_MACINTOSH:
-                if(name.language_id != TT_MAC_LANGID_ENGLISH)
+                if (name.language_id != TT_MAC_LANGID_ENGLISH)
                     continue;
                 break;
             case TT_PLATFORM_MICROSOFT:
-                if(name.language_id != TT_MS_LANGID_ENGLISH_UNITED_STATES &&
-                   name.language_id != TT_MS_LANGID_ENGLISH_UNITED_KINGDOM)
+                if (name.language_id != TT_MS_LANGID_ENGLISH_UNITED_STATES &&
+                    name.language_id != TT_MS_LANGID_ENGLISH_UNITED_KINGDOM)
                     continue;
                 break;
             default:
                 continue;
             }
-            if(name.string_len > 0) {
+            if (name.string_len > 0) {
                 *name_return = name;
                 return 1;
             }
@@ -322,20 +339,18 @@ static char *
 getName(FT_Face face, int nid)
 {
     FT_SfntName name;
-    char *string;
-    unsigned int i;
 
-    if(getNameHelper(face, nid,
-                     TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, &name) ||
-       getNameHelper(face, nid,
-                     TT_PLATFORM_APPLE_UNICODE, -1, &name)) {
-        string = malloc(name.string_len / 2 + 1);
-        if(string == NULL) {
+    if (getNameHelper(face, nid,
+                      TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, &name) ||
+        getNameHelper(face, nid, TT_PLATFORM_APPLE_UNICODE, -1, &name)) {
+        unsigned int i;
+        char *string = malloc(name.string_len / 2 + 1);
+        if (string == NULL) {
             fprintf(stderr, "Couldn't allocate name\n");
             exit(1);
         }
-        for(i = 0; i < name.string_len / 2; i++) {
-            if(name.string[2 * i] != 0)
+        for (i = 0; i < name.string_len / 2; i++) {
+            if (name.string[2 * i] != 0)
                 string[i] = '?';
             else
                 string[i] = name.string[2 * i + 1];
@@ -345,10 +360,9 @@ getName(FT_Face face, int nid)
     }
 
     /* Pretend that Apple Roman is ISO 8859-1. */
-    if(getNameHelper(face, nid, TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN,
-                     &name)) {
-        string = malloc(name.string_len + 1);
-        if(string == NULL) {
+    if (getNameHelper(face, nid, TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, &name)) {
+        char *string = malloc(name.string_len + 1);
+        if (string == NULL) {
             fprintf(stderr, "Couldn't allocate name\n");
             exit(1);
         }
@@ -360,47 +374,47 @@ getName(FT_Face face, int nid)
     return NULL;
 }
 
-static const char*
+static const char *
 os2Weight(int weight)
 {
-    if(weight < 150)
+    if (weight < 150)
         return "thin";
-    else if(weight < 250)
+    else if (weight < 250)
         return "extralight";
-    else if(weight < 350)
+    else if (weight < 350)
         return "light";
-    else if(weight < 450)
+    else if (weight < 450)
         return "medium";        /* officially "normal" */
-    else if(weight < 550)
+    else if (weight < 550)
         return "medium";
-    else if(weight < 650)
+    else if (weight < 650)
         return "semibold";
-    else if(weight < 750)
+    else if (weight < 750)
         return "bold";
-    else if(weight < 850)
+    else if (weight < 850)
         return "extrabold";
     else
         return "black";
 }
 
-static const char*
+static const char *
 os2Width(int width)
 {
-    if(width <= 1)
+    if (width <= 1)
         return "ultracondensed";
-    else if(width <= 2)
+    else if (width <= 2)
         return "extracondensed";
-    else if(width <= 3)
+    else if (width <= 3)
         return "condensed";
-    else if(width <= 4)
+    else if (width <= 4)
         return "semicondensed";
-    else if(width <= 5)
+    else if (width <= 5)
         return "normal";
-    else if(width <= 6)
+    else if (width <= 6)
         return "semiexpanded";
-    else if(width <= 7)
+    else if (width <= 7)
         return "expanded";
-    else if(width <= 8)
+    else if (width <= 8)
         return "extraexpanded";
     else
         return "ultraexpanded";
@@ -413,60 +427,61 @@ static const char *widths[] = {
 
 #define NUMWIDTHS (sizeof(widths) / sizeof(widths[0]))
 
-static const char*
+static const char *
 nameWidth(const char *name)
 {
     char buf[500];
     unsigned int i;
     size_t n = strlen(name);
 
-    if(n >= 499) return NULL;
-    for(i = 0; i < n; i++)
+    if (n >= 499)
+        return NULL;
+    for (i = 0; i < n; i++)
         buf[i] = tolower(name[i]);
     buf[i] = '\0';
 
-    for(i = 0; i < NUMWIDTHS; i++)
-        if(strstr(buf, widths[i]))
+    for (i = 0; i < NUMWIDTHS; i++)
+        if (strstr(buf, widths[i]))
             return widths[i];
     return NULL;
 }
 
-static const char*
+static const char *
 t1Weight(const char *weight)
 {
-    if(!weight)
+    if (!weight)
         return NULL;
-    if(strcasecmp(weight, "Thin") == 0)
+    if (strcasecmp(weight, "Thin") == 0)
         return "thin";
-    if(strcasecmp(weight, "ExtraLight") == 0) /* FontForge uses this for 200*/
+    if (strcasecmp(weight, "ExtraLight") == 0)  /* FontForge uses this for 200 */
         return "extralight";
-    if(strcasecmp(weight, "Light") == 0)
+    if (strcasecmp(weight, "Light") == 0)
         return "light";
-    if(strcasecmp(weight, "Regular") == 0)
+    if (strcasecmp(weight, "Regular") == 0)
         return "medium";
-    if(strcasecmp(weight, "Normal") == 0)
+    if (strcasecmp(weight, "Normal") == 0)
         return "medium";
-    if(strcasecmp(weight, "Plain") == 0)
+    if (strcasecmp(weight, "Plain") == 0)
         return "medium";
-    if(strcasecmp(weight, "Medium") == 0)
+    if (strcasecmp(weight, "Medium") == 0)
         return "medium";
-    if(strcasecmp(weight, "Book") == 0)
+    if (strcasecmp(weight, "Book") == 0)
         return "medium";
-    if(strcasecmp(weight, "Roman") == 0) /* Some URW++ fonts do that! */
+    if (strcasecmp(weight, "Roman") == 0)       /* Some URW++ fonts do that! */
         return "medium";
-    if(strcasecmp(weight, "Demi") == 0)
+    if (strcasecmp(weight, "Demi") == 0)
         return "semibold";
-    if(strcasecmp(weight, "DemiBold") == 0)
+    if (strcasecmp(weight, "DemiBold") == 0)
         return "semibold";
-    if(strcasecmp(weight, "SemiBold") == 0) /* some TeX fonts apparently do that */
+    if (strcasecmp(weight, "SemiBold") == 0)    /* some TeX fonts apparently do that */
         return "semibold";
-    else if(strcasecmp(weight, "Bold") == 0)
+    else if (strcasecmp(weight, "Bold") == 0)
         return "bold";
-    else if(strcasecmp(weight, "ExtraBold") == 0) /* freefonts uses this */
+    else if (strcasecmp(weight, "ExtraBold") == 0)      /* freefonts uses this */
         return "extrabold";
-    else if(strcasecmp(weight, "Heavy") == 0) /* FontForge uses this for 800*/
+    else if (strcasecmp(weight, "Heavy") == 0)  /* FontForge uses this for 800 */
         return "extrabold";
-    else if(strcasecmp(weight, "Black") == 0)
+    else if (strcasecmp(weight, "Black") == 0)
         return "black";
     else {
         fprintf(stderr, "Unknown Type 1 weight \"%s\"\n", weight);
@@ -483,29 +498,30 @@ unsafe(char c)
 }
 
 static const char *
-safe(const char* s)
+safe(const char *s)
 {
-    int i, len, safe_flag = 1;
+    unsigned int i, len, safe_flag = 1;
     char *t;
 
     i = 0;
-    while(s[i] != '\0') {
-        if(unsafe(s[i]))
+    while (s[i] != '\0') {
+        if (unsafe(s[i]))
             safe_flag = 0;
         i++;
     }
 
-    if(safe_flag) return strdup(s);
+    if (safe_flag)
+        return strdup(s);
 
     len = i;
     t = malloc(len + 1);
-    if(t == NULL) {
+    if (t == NULL) {
         perror("Couldn't allocate string");
         exit(1);
     }
 
-    for(i = 0; i < len; i++) {
-        if(unsafe(s[i]))
+    for (i = 0; i < len; i++) {
+        if (unsafe(s[i]))
             t[i] = ' ';
         else
             t[i] = s[i];
@@ -542,66 +558,68 @@ makeXLFD(char *filename, FT_Face face, i
     post = FT_Get_Sfnt_Table(face, ft_sfnt_post);
 
     rc = FT_Get_PS_Font_Info(face, &t1info_rec);
-    if(rc == 0)
+    if (rc == 0)
         t1info = &t1info_rec;
     else
         t1info = NULL;
 
-    if(!family)
+    if (!family)
         family = getName(face, TT_NAME_ID_FONT_FAMILY);
-    if(!family)
+    if (!family)
         family = getName(face, TT_NAME_ID_FULL_NAME);
-    if(!family)
+    if (!family)
         family = getName(face, TT_NAME_ID_PS_NAME);
 
-    if(!full_name)
+    if (!full_name)
         full_name = getName(face, TT_NAME_ID_FULL_NAME);
-    if(!full_name)
+    if (!full_name)
         full_name = getName(face, TT_NAME_ID_PS_NAME);
 
-    if(os2 && os2->version != 0xFFFF) {
-        if(!weight)
+    if (os2 && os2->version != 0xFFFF) {
+        if (!weight)
             weight = os2Weight(os2->usWeightClass);
-        if(!sWidth)
+        if (!sWidth)
             sWidth = os2Width(os2->usWidthClass);
-        if(!foundry)
+        if (!foundry)
             foundry = vendor_foundry(os2->achVendID);
-        if(!slant)
+        if (!slant)
             slant = os2->fsSelection & 1 ? "i" : "r";
     }
 
-    if(post) {
-        if(!spacing) {
-            if(post->isFixedPitch) {
-                if(hhea->min_Left_Side_Bearing >= 0 &&
-                   hhea->xMax_Extent <= hhea->advance_Width_Max) {
+    if (post) {
+        if (!spacing) {
+            if (post->isFixedPitch) {
+                if (hhea->min_Left_Side_Bearing >= 0 &&
+                    hhea->xMax_Extent <= hhea->advance_Width_Max) {
                     spacing = "c";
-                } else {
+                }
+                else {
                     spacing = "m";
                 }
-            } else {
+            }
+            else {
                 spacing = "p";
             }
         }
     }
 
-    if(t1info) {
-        if(!family && t1info->family_name)
+    if (t1info) {
+        if (!family && t1info->family_name)
             family = strdup(t1info->family_name);
-        if(!family && t1info->full_name)
+        if (!family && t1info->full_name)
             family = strdup(t1info->full_name);
         /* Hershey fonts miss /FamilyName */
-        if(!family && face->family_name)
+        if (!family && face->family_name)
             family = strdup(face->family_name);
-        if(!full_name && t1info->full_name)
+        if (!full_name && t1info->full_name)
             full_name = strdup(t1info->full_name);
-        if(!foundry)
+        if (!foundry)
             foundry = notice_foundry(t1info->notice);
-        if(!weight)
+        if (!weight)
             weight = t1Weight(t1info->weight);
-        if(!spacing)
+        if (!spacing)
             spacing = t1info->is_fixed_pitch ? "m" : "p";
-        if(!slant) {
+        if (!slant) {
             /* Bitstream fonts have positive italic angle. */
             slant =
                 t1info->italic_angle <= -4 || t1info->italic_angle >= 4 ?
@@ -609,97 +627,103 @@ makeXLFD(char *filename, FT_Face face, i
         }
     }
 
-    if(!full_name) {
+    if (!full_name) {
         fprintf(stderr, "Couldn't determine full name for %s\n", filename);
         full_name = strdup(filename);
     }
 
-    if(head) {
-        if(!slant)
+    if (head) {
+        if (!slant)
             slant = head->Mac_Style & 2 ? "i" : "r";
-        if(!weight)
+        if (!weight)
             weight = head->Mac_Style & 1 ? "bold" : "medium";
     }
 
-    if(!slant) {
+    if (!slant) {
         fprintf(stderr, "Couldn't determine slant for %s\n", filename);
         slant = "r";
     }
 
-    if(!weight) {
+    if (!weight) {
         fprintf(stderr, "Couldn't determine weight for %s\n", filename);
         weight = "medium";
     }
 
-    if(!foundry) {
+    if (!foundry) {
         char *notice;
+
         notice = getName(face, TT_NAME_ID_TRADEMARK);
-        if(notice) {
+        if (notice) {
             foundry = notice_foundry(notice);
             free(notice);
         }
-        if(!foundry) {
+        if (!foundry) {
             notice = getName(face, TT_NAME_ID_MANUFACTURER);
-            if(notice) {
+            if (notice) {
                 foundry = notice_foundry(notice);
                 free(notice);
             }
         }
     }
 
-    if(strcmp(slant, "i") == 0) {
-        if(strstr(full_name, "Oblique"))
+    if (strcmp(slant, "i") == 0) {
+        if (strstr(full_name, "Oblique"))
             slant = "o";
-        if(strstr(full_name, "Slanted"))
+        if (strstr(full_name, "Slanted"))
             slant = "o";
     }
 
-    if(!sWidth)
+    if (!sWidth)
         sWidth = nameWidth(full_name);
 
-    if(!foundry) foundry = "misc";
-    if(!family) {
+    if (!foundry)
+        foundry = "misc";
+    if (!family) {
         fprintf(stderr, "Couldn't get family name for %s\n", filename);
         family = strdup(filename);
     }
 
-    if(!weight) weight = "medium";
-    if(!slant) slant = "r";
-    if(!sWidth) sWidth = "normal";
-    if(!adstyle) adstyle = "";
-    if(!spacing) spacing = "p";
+    if (!weight)
+        weight = "medium";
+    if (!slant)
+        slant = "r";
+    if (!sWidth)
+        sWidth = "normal";
+    if (!adstyle)
+        adstyle = "";
+    if (!spacing)
+        spacing = "p";
 
     foundry = safe(foundry);
 
     tmp = family;
     family = safe(family);
-    free((void *)tmp);
+    free((void *) tmp);
 
-    if(!isBitmap) {
+    if (!isBitmap) {
         xlfd = listConsF(xlfd,
                          "-%s-%s-%s-%s-%s-%s-0-0-0-0-%s-0",
                          foundry, family,
                          weight, slant, sWidth, adstyle, spacing);
-    } else {
-        int i, w, h, xres, yres;
-        for(i = 0; i < face->num_fixed_sizes; i++) {
-            w = face->available_sizes[i].width;
-            h = face->available_sizes[i].height;
-            xres = 75;
-            yres = (double)h / w * xres;
+    }
+    else {
+        for (int i = 0; i < face->num_fixed_sizes; i++) {
+            int w = face->available_sizes[i].width;
+            int h = face->available_sizes[i].height;
+            int xres = 75;
+            int yres = (double) h / w * xres;
             xlfd = listConsF(xlfd,
                              "-%s-%s-%s-%s-%s-%s-%d-%d-%d-%d-%s-%d",
                              foundry, family,
                              weight, slant, sWidth, adstyle,
-                             h, (int)(h / (double)yres * 72.27 * 10 + 0.5),
-                             xres, yres,
-                             spacing, 60);
+                             h, (int) (h / (double) yres * 72.27 * 10 + 0.5),
+                             xres, yres, spacing, 60);
         }
     }
 
-    free((void *)family);
-    free((void *)foundry);
-    free((void *)full_name);
+    free((void *) family);
+    free((void *) foundry);
+    free((void *) full_name);
     return xlfd;
 }
 
@@ -709,37 +733,37 @@ readFontScale(HashTablePtr entries, char
     size_t n = strlen(dirname);
     char *filename;
     FILE *in;
-    int rc, count, i;
-    char file[MAXFONTFILENAMELEN+1], font[MAXFONTNAMELEN+1];
+    int rc, count;
+    char file[MAXFONTFILENAMELEN + 1], font[MAXFONTNAMELEN + 1];
 
-    if(dirname[n - 1] == '/')
+    if (dirname[n - 1] == '/')
         filename = dsprintf("%sfonts.scale", dirname);
     else
         filename = dsprintf("%s/fonts.scale", dirname);
-    if(filename == NULL)
+    if (filename == NULL)
         return -1;
 
     in = fopen(filename, "r");
     free(filename);
-    if(in == NULL) {
-        if(errno != ENOENT)
+    if (in == NULL) {
+        if (errno != ENOENT)
             perror("open(fonts.scale)");
         return -1;
     }
 
     rc = fscanf(in, "%d\n", &count);
-    if(rc != 1) {
+    if (rc != 1) {
         fprintf(stderr, "Invalid fonts.scale in %s.\n", dirname);
         fclose(in);
         return -1;
     }
 
-    for(i = 0; i < count; i++) {
+    for (int i = 0; i < count; i++) {
         rc = fscanf(in,
-		    "%" STRINGIFY(MAXFONTFILENAMELEN) "s "
-		    "%" STRINGIFY(MAXFONTNAMELEN) "[^\n]\n",
-		    file, font);
-        if(rc != 2)
+                    "%" STRINGIFY(MAXFONTFILENAMELEN) "s "
+                    "%" STRINGIFY(MAXFONTNAMELEN) "[^\n]\n",
+                    file, font);
+        if (rc != 2)
             break;
         putHash(entries, font, file, 100);
     }
@@ -751,31 +775,32 @@ static int
 filePrio(char *filename)
 {
     size_t n = strlen(filename);
-    if(n < 4)
+
+    if (n < 4)
         return 0;
-    if(strcmp(filename + n - 4, ".otf") == 0)
+    if (strcmp(filename + n - 4, ".otf") == 0)
         return 6;
-    if(strcmp(filename + n - 4, ".OTF") == 0)
+    if (strcmp(filename + n - 4, ".OTF") == 0)
         return 6;
-    if(strcmp(filename + n - 4, ".ttf") == 0)
+    if (strcmp(filename + n - 4, ".ttf") == 0)
         return 5;
-    if(strcmp(filename + n - 4, ".TTF") == 0)
+    if (strcmp(filename + n - 4, ".TTF") == 0)
         return 5;
-    if(strcmp(filename + n - 4, ".pcf") == 0)
+    if (strcmp(filename + n - 4, ".pcf") == 0)
         return 4;
-    if(strcmp(filename + n - 4, ".PCF") == 0)
+    if (strcmp(filename + n - 4, ".PCF") == 0)
         return 4;
-    if(strcmp(filename + n - 3, ".gz") == 0)
+    if (strcmp(filename + n - 3, ".gz") == 0)
         return 3;
 #ifdef X_BZIP2_FONT_COMPRESSION
-    if(strcmp(filename + n - 4, ".bz2") == 0)
+    if (strcmp(filename + n - 4, ".bz2") == 0)
         return 2;
 #endif
-    if(strcmp(filename + n - 2, ".Z") == 0)
+    if (strcmp(filename + n - 2, ".Z") == 0)
         return 2;
-    if(strcmp(filename + n - 4, ".bdf") == 0)
+    if (strcmp(filename + n - 4, ".bdf") == 0)
         return 1;
-    if(strcmp(filename + n - 4, ".BDF") == 0)
+    if (strcmp(filename + n - 4, ".BDF") == 0)
         return 1;
     return 0;
 }
@@ -785,7 +810,7 @@ doDirectory(const char *dirname_given, i
 {
     char *dirname, *fontscale_name, *filename, *encdir;
     FILE *fontscale, *encfile;
-    struct dirent** namelist;
+    struct dirent **namelist;
     FT_Error ftrc;
     FT_Face face;
     ConstListPtr encoding;
@@ -793,206 +818,222 @@ doDirectory(const char *dirname_given, i
     HashTablePtr entries;
     HashBucketPtr *array;
     int i, n, dirn, diri, found, rc;
-    int isBitmap=0;
-    size_t d, xl=0;
+    int isBitmap = 0;
+    size_t d, xl = 0;
 
     if (exclusionSuffix)
-        xl = strlen (exclusionSuffix);
+        xl = strlen(exclusionSuffix);
 
     d = strlen(dirname_given);
-    if(d == 0)
+    if (d == 0)
         dirname = dsprintf("./");
-    else if(dirname_given[d - 1] != '/')
+    else if (dirname_given[d - 1] != '/')
         dirname = dsprintf("%s/", dirname_given);
     else
         dirname = strdup(dirname_given);
 
-    if(dirname == NULL) {
+    if (dirname == NULL) {
         perror("dirname");
         exit(1);
     }
 
     if (onlyEncodings)
-	goto encodings;
+        goto encodings;
 
     entries = makeHashTable();
-    if(doBitmaps && !doScalable) {
+    if (doBitmaps && !doScalable) {
         readFontScale(entries, dirname);
     }
 
-    if(strcmp(outfilename, "-") == 0)
+    if (strcmp(outfilename, "-") == 0)
         fontscale_name = NULL;
     else {
-        if(outfilename[0] == '/')
+        if (outfilename[0] == '/')
             fontscale_name = strdup(outfilename);
         else
             fontscale_name = dsprintf("%s%s", dirname, outfilename);
-        if(fontscale_name == NULL) {
+        if (fontscale_name == NULL) {
             perror("fontscale_name");
             exit(1);
         }
     }
 
     dirn = scandir(dirname, &namelist, NULL, alphasort);
-    if(dirn < 0) {
+    if (dirn < 0) {
         fprintf(stderr, "%s: ", dirname);
         perror("scandir");
         return 0;
     }
 
-    if(fontscale_name == NULL)
+    if (fontscale_name == NULL)
         fontscale = stdout;
     else
         fontscale = fopen(fontscale_name, "wb");
 
-    if(fontscale == NULL) {
+    if (fontscale == NULL) {
         fprintf(stderr, "%s: ", fontscale_name);
         perror("fopen(w)");
         return 0;
     }
 
-    for(diri = dirn - 1; diri >= 0; diri--) {
+    for (diri = dirn - 1; diri >= 0; diri--) {
         struct dirent *entry = namelist[diri];
         int have_face = 0;
         char *xlfd_name = NULL;
-	struct stat f_stat;
-	int tprio = 1;
+        struct stat f_stat;
+        int tprio = 1;
 
         xlfd = NULL;
 
-	if (xl) {
-	    size_t dl = strlen (entry->d_name);
-	    if (strcmp (entry->d_name + dl - xl, exclusionSuffix) == 0)
-		continue;
-	}
+        if (xl) {
+            size_t dl = strlen(entry->d_name);
+
+            if (strcmp(entry->d_name + dl - xl, exclusionSuffix) == 0)
+                continue;
+        }
 
         filename = dsprintf("%s%s", dirname, entry->d_name);
 
 #define PRIO(x) ((x << 1) + tprio)
 #ifdef DT_LNK
-	if (entry->d_type != DT_UNKNOWN) {
-	    if (entry->d_type == DT_LNK)
-		tprio = 0;
-	} else
+        if (entry->d_type != DT_UNKNOWN) {
+            if (entry->d_type == DT_LNK)
+                tprio = 0;
+        }
+        else
 #endif
 #ifdef S_ISLNK
-	{
-	    if (lstat(filename, &f_stat))
-		goto done;
-	    if (S_ISLNK(f_stat.st_mode))
-		tprio = 0;
-	}
+        {
+            if (lstat(filename, &f_stat))
+                goto done;
+            if (S_ISLNK(f_stat.st_mode))
+                tprio = 0;
+        }
 #else
-	;
+            ;
 #endif
-        if(doBitmaps)
+        if (doBitmaps)
             rc = bitmapIdentify(filename, &xlfd_name);
         else
             rc = 0;
 
-        if(rc < 0)
+        if (rc < 0)
             goto done;
 
-        if(rc == 0) {
+        if (rc == 0) {
             ftrc = FT_New_Face(ft_library, filename, 0, &face);
-            if(ftrc)
+            if (ftrc)
                 goto done;
             have_face = 1;
 
             isBitmap = ((face->face_flags & FT_FACE_FLAG_SCALABLE) == 0);
 
-            if(!isBitmap) {
+            if (!isBitmap) {
                 /* Workaround for bitmap-only SFNT fonts */
-                if(FT_IS_SFNT(face) && face->num_fixed_sizes > 0 &&
-                   strcmp(FT_Get_X11_Font_Format(face), "TrueType") == 0) {
+                if (FT_IS_SFNT(face) && face->num_fixed_sizes > 0 &&
+                    strcmp(FT_Get_X11_Font_Format(face), "TrueType") == 0) {
                     TT_MaxProfile *maxp;
+
                     maxp = FT_Get_Sfnt_Table(face, ft_sfnt_maxp);
-                    if(maxp != NULL && maxp->maxContours == 0)
+                    if (maxp != NULL && maxp->maxContours == 0)
                         isBitmap = 1;
                 }
             }
 
-            if(isBitmap) {
-                if(!doBitmaps)
+            if (isBitmap) {
+                if (!doBitmaps)
                     goto done;
-            } else {
-                if(!doScalable)
+            }
+            else {
+                if (!doScalable)
                     goto done;
             }
 
-            if(isBitmap) {
+            if (isBitmap) {
                 BDF_PropertyRec prop;
+
                 rc = FT_Get_BDF_Property(face, "FONT", &prop);
-                if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) {
+                if (rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) {
                     xlfd_name = strdup(prop.u.atom);
-                    if(xlfd_name == NULL)
+                    if (xlfd_name == NULL)
                         goto done;
                 }
             }
         }
 
-        if(xlfd_name) {
+        if (xlfd_name) {
             /* We know it's a bitmap font, and we know its XLFD */
             size_t l = strlen(xlfd_name);
-            if(reencodeLegacy &&
-               l >= 12 && strcasecmp(xlfd_name + l - 11, "-iso10646-1") == 0) {
+
+            if (reencodeLegacy &&
+                l >= 12 && strcasecmp(xlfd_name + l - 11, "-iso10646-1") == 0) {
                 char *s;
 
                 s = malloc(l - 10);
+                if (s == NULL) {
+                    fprintf(stderr, "Couldn't allocate xlfd name\n");
+                    exit(1);
+                }
                 memcpy(s, xlfd_name, l - 11);
                 s[l - 11] = '\0';
                 xlfd = listCons(s, xlfd);
-            } else {
+            }
+            else {
                 /* Not a reencodable font -- skip all the rest of the loop body */
-                putHash(entries, xlfd_name, entry->d_name, PRIO(filePrio(entry->d_name)));
+                putHash(entries, xlfd_name, entry->d_name,
+                        PRIO(filePrio(entry->d_name)));
                 goto done;
             }
         }
 
-        if(!have_face) {
+        if (!have_face) {
             ftrc = FT_New_Face(ft_library, filename, 0, &face);
-            if(ftrc)
+            if (ftrc)
                 goto done;
             have_face = 1;
             isBitmap = ((face->face_flags & FT_FACE_FLAG_SCALABLE) == 0);
 
-            if(!isBitmap) {
-                if(face->num_fixed_sizes > 0) {
+            if (!isBitmap) {
+                if (face->num_fixed_sizes > 0) {
                     TT_MaxProfile *maxp;
+
                     maxp = FT_Get_Sfnt_Table(face, ft_sfnt_maxp);
-                    if(maxp != NULL && maxp->maxContours == 0)
+                    if (maxp != NULL && maxp->maxContours == 0)
                         isBitmap = 1;
                 }
             }
         }
 
-        if(xlfd == NULL)
+        if (xlfd == NULL)
             xlfd = makeXLFD(entry->d_name, face, isBitmap);
 
         found = 0;
 
-        for(lp = xlfd; lp; lp = lp->next) {
+        for (lp = xlfd; lp; lp = lp->next) {
             char buf[MAXFONTNAMELEN];
-            for(encoding = encodings; encoding; encoding = encoding->next) {
-                if(checkEncoding(face, encoding->value)) {
+
+            for (encoding = encodings; encoding; encoding = encoding->next) {
+                if (checkEncoding(face, encoding->value)) {
                     found = 1;
                     snprintf(buf, MAXFONTNAMELEN, "%s-%s",
-                            lp->value, encoding->value);
-                    putHash(entries, buf, entry->d_name, PRIO(filePrio(entry->d_name)));
+                             lp->value, encoding->value);
+                    putHash(entries, buf, entry->d_name,
+                            PRIO(filePrio(entry->d_name)));
                 }
             }
-            for(encoding = extra_encodings; encoding;
-                encoding = encoding->next) {
-                if(checkExtraEncoding(face, encoding->value, found)) {
+            for (encoding = extra_encodings; encoding;
+                 encoding = encoding->next) {
+                if (checkExtraEncoding(face, encoding->value, found)) {
                     /* Do not set found! */
                     snprintf(buf, MAXFONTNAMELEN, "%s-%s",
-                            lp->value, encoding->value);
-                    putHash(entries, buf, entry->d_name, PRIO(filePrio(entry->d_name)));
+                             lp->value, encoding->value);
+                    putHash(entries, buf, entry->d_name,
+                            PRIO(filePrio(entry->d_name)));
                 }
             }
         }
-    done:
-        if(have_face)
+ done:
+        if (have_face)
             FT_Done_Face(face);
         deepDestroyList(xlfd);
         xlfd = NULL;
@@ -1000,17 +1041,17 @@ doDirectory(const char *dirname_given, i
 #undef PRIO
     }
 
-    while(dirn--)
+    while (dirn--)
         free(namelist[dirn]);
     free(namelist);
     n = hashElements(entries);
     fprintf(fontscale, "%d\n", n);
     array = hashArray(entries, 1);
-    for(i = 0; i < n; i++)
+    for (i = 0; i < n; i++)
         fprintf(fontscale, "%s %s\n", array[i]->value, array[i]->key);
     destroyHashArray(array);
     entries = NULL;
-    if(fontscale_name) {
+    if (fontscale_name) {
         fclose(fontscale);
         free(fontscale_name);
     }
@@ -1018,24 +1059,24 @@ doDirectory(const char *dirname_given, i
  encodings:
     encdir = dsprintf("%s%s", dirname, "encodings.dir");
 
-    if(encdir == NULL) {
-	perror("encodings");
-	exit(1);
+    if (encdir == NULL) {
+        perror("encodings");
+        exit(1);
     }
     unlink(encdir);
 
     if (numEncodings) {
-	encfile = fopen(encdir, "w");
-	if(encfile == NULL) {
-	    perror("open(encodings.dir)");
-	    exit(1);
-	}
+        encfile = fopen(encdir, "w");
+        if (encfile == NULL) {
+            perror("open(encodings.dir)");
+            exit(1);
+        }
         fprintf(encfile, "%d\n", numEncodings);
         encodingsToDo = sortList(encodingsToDo);
-        for(lp = encodingsToDo; lp; lp = lp->next) {
+        for (lp = encodingsToDo; lp; lp = lp->next) {
             fprintf(encfile, "%s\n", lp->value);
         }
-	fclose (encfile);
+        fclose(encfile);
     }
 
     free(dirname);
@@ -1051,16 +1092,14 @@ checkEncoding(FT_Face face, const char *
 {
     FontEncPtr encoding;
     FontMapPtr mapping;
-    int i, j, c, koi8;
-    char *n;
 
     encoding = FontEncFind(encoding_name, NULL);
-    if(!encoding)
+    if (!encoding)
         return 0;
 
     /* An encoding is ``small'' if one of the following is true:
-         - it is linear and has no more than 256 codepoints; or
-         - it is a matrix encoding and has no more than one column.
+       - it is linear and has no more than 256 codepoints; or
+       - it is a matrix encoding and has no more than one column.
 
        For small encodings using Unicode indices, we require perfect
        coverage except for CODE_IGNORED and KOI-8 IBM-PC compatibility.
@@ -1070,26 +1109,25 @@ checkEncoding(FT_Face face, const char *
        For encodings using PS names (currently Adobe Standard and
        Adobe Symbol only), we require perfect coverage. */
 
-
-    if(FT_Has_PS_Glyph_Names(face)) {
-        for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
-            if(mapping->type == FONT_ENCODING_POSTSCRIPT) {
-                if(encoding->row_size > 0) {
-                    for(i = encoding->first; i < encoding->size; i++) {
-                        for(j = encoding->first_col;
-                            j < encoding->row_size;
-                            j++) {
-                            n = FontEncName((i<<8) | j, mapping);
-                            if(n && FT_Get_Name_Index(face, n) == 0) {
+    if (FT_Has_PS_Glyph_Names(face)) {
+        for (mapping = encoding->mappings; mapping; mapping = mapping->next) {
+            if (mapping->type == FONT_ENCODING_POSTSCRIPT) {
+                if (encoding->row_size > 0) {
+                    for (int i = encoding->first; i < encoding->size; i++) {
+                        for (int j = encoding->first_col;
+                             j < encoding->row_size; j++) {
+                            char *n = FontEncName((i << 8) | j, mapping);
+                            if (n && FT_Get_Name_Index(face, n) == 0) {
                                 return 0;
                             }
                         }
                     }
                     return 1;
-                } else {
-                    for(i = encoding->first; i < encoding->size; i++) {
-                        n = FontEncName(i, mapping);
-                        if(n && FT_Get_Name_Index(face, n) == 0) {
+                }
+                else {
+                    for (int i = encoding->first; i < encoding->size; i++) {
+                        char *n = FontEncName(i, mapping);
+                        if (n && FT_Get_Name_Index(face, n) == 0) {
                             return 0;
                         }
                     }
@@ -1099,61 +1137,68 @@ checkEncoding(FT_Face face, const char *
         }
     }
 
-    for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
-        if(find_cmap(mapping->type, mapping->pid, mapping->eid, face)) {
+    for (mapping = encoding->mappings; mapping; mapping = mapping->next) {
+        if (find_cmap(mapping->type, mapping->pid, mapping->eid, face)) {
             int total = 0, failed = 0;
-            if(encoding->row_size > 0) {
+
+            if (encoding->row_size > 0) {
                 int estimate =
                     (encoding->size - encoding->first) *
                     (encoding->row_size - encoding->first_col);
-                for(i = encoding->first; i < encoding->size; i++) {
-                    for(j = encoding->first_col;
-                        j < encoding->row_size;
-                        j++) {
-                        c = FontEncRecode((i<<8) | j, mapping);
-                        if(CODE_IGNORED(c)) {
+                for (int i = encoding->first; i < encoding->size; i++) {
+                    for (int j = encoding->first_col; j < encoding->row_size;
+                         j++) {
+                        int c = FontEncRecode((i << 8) | j, mapping);
+                        if (CODE_IGNORED(c)) {
                             continue;
-                        } else {
-                            if(FT_Get_Char_Index(face, c) == 0) {
+                        }
+                        else {
+                            if (FT_Get_Char_Index(face, c) == 0) {
                                 failed++;
                             }
                             total++;
-                            if((encoding->size <= 1 && failed > 0) ||
-                               ((float)failed >= bigEncodingFuzz * estimate)) {
+                            if ((encoding->size <= 1 && failed > 0) ||
+                                ((float) failed >=
+                                 bigEncodingFuzz * estimate)) {
                                 return 0;
                             }
                         }
                     }
                 }
-                if((float)failed >= total * bigEncodingFuzz)
+                if ((float) failed >= total * bigEncodingFuzz)
                     return 0;
                 else
                     return 1;
-            } else {
+            }
+            else {
                 int estimate = encoding->size - encoding->first;
+                int koi8;
+
                 /* For the KOI8 encodings, we ignore the lack of
                    linedrawing and pseudo-math characters */
-                if(strncmp(encoding->name, "koi8-", 5) == 0)
+                if (strncmp(encoding->name, "koi8-", 5) == 0)
                     koi8 = 1;
                 else
                     koi8 = 0;
-                for(i = encoding->first; i < encoding->size; i++) {
-                    c = FontEncRecode(i, mapping);
-                    if(CODE_IGNORED(c) ||
-                       (koi8 && ((c >= 0x2200 && c < 0x2600) || c == 0x00b2))) {
+                for (int i = encoding->first; i < encoding->size; i++) {
+                    unsigned int c = FontEncRecode(i, mapping);
+                    if (CODE_IGNORED(c) ||
+                        (koi8 &&
+                         ((c >= 0x2200 && c < 0x2600) || c == 0x00b2))) {
                         continue;
-                    } else {
-                        if(FT_Get_Char_Index(face, c) == 0) {
+                    }
+                    else {
+                        if (FT_Get_Char_Index(face, c) == 0) {
                             failed++;
                         }
                         total++;
-                        if((encoding->size <= 256 && failed > 0) ||
-                           ((float)failed >= bigEncodingFuzz * estimate)) {
+                        if ((encoding->size <= 256 && failed > 0) ||
+                            ((float) failed >= bigEncodingFuzz * estimate)) {
                             return 0;
                         }
                     }
                 }
-                if((float)failed >= total * bigEncodingFuzz)
+                if ((float) failed >= total * bigEncodingFuzz)
                     return 0;
                 else
                     return 1;
@@ -1166,48 +1211,45 @@ checkEncoding(FT_Face face, const char *
 static int
 find_cmap(int type, int pid, int eid, FT_Face face)
 {
-    int i, n, rc;
-    FT_CharMap cmap = NULL;
-
-    n = face->num_charmaps;
+    int n = face->num_charmaps;
 
-    switch(type) {
-    case FONT_ENCODING_TRUETYPE:  /* specific cmap */
-        for(i=0; i<n; i++) {
-            cmap = face->charmaps[i];
-            if(cmap->platform_id == pid && cmap->encoding_id == eid) {
-                rc = FT_Set_Charmap(face, cmap);
-                if(rc == 0)
+    switch (type) {
+    case FONT_ENCODING_TRUETYPE:       /* specific cmap */
+        for (int i = 0; i < n; i++) {
+            FT_CharMap cmap = face->charmaps[i];
+            if (cmap->platform_id == pid && cmap->encoding_id == eid) {
+                int rc = FT_Set_Charmap(face, cmap);
+                if (rc == 0)
                     return 1;
             }
         }
         break;
-    case FONT_ENCODING_UNICODE:   /* any Unicode cmap */
+    case FONT_ENCODING_UNICODE:        /* any Unicode cmap */
         /* prefer Microsoft Unicode */
-        for(i=0; i<n; i++) {
-            cmap = face->charmaps[i];
-            if(cmap->platform_id == TT_PLATFORM_MICROSOFT &&
-               cmap->encoding_id == TT_MS_ID_UNICODE_CS) {
-                rc = FT_Set_Charmap(face, cmap);
-                if(rc == 0)
+        for (int i = 0; i < n; i++) {
+            FT_CharMap cmap = face->charmaps[i];
+            if (cmap->platform_id == TT_PLATFORM_MICROSOFT &&
+                cmap->encoding_id == TT_MS_ID_UNICODE_CS) {
+                int rc = FT_Set_Charmap(face, cmap);
+                if (rc == 0)
                     return 1;
             }
         }
         /* Try Apple Unicode */
-        for(i=0; i<n; i++) {
-            cmap = face->charmaps[i];
-            if(cmap->platform_id == TT_PLATFORM_APPLE_UNICODE) {
-                rc = FT_Set_Charmap(face, cmap);
-                if(rc == 0)
+        for (int i = 0; i < n; i++) {
+            FT_CharMap cmap = face->charmaps[i];
+            if (cmap->platform_id == TT_PLATFORM_APPLE_UNICODE) {
+                int rc = FT_Set_Charmap(face, cmap);
+                if (rc == 0)
                     return 1;
             }
         }
         /* ISO Unicode? */
-        for(i=0; i<n; i++) {
-            cmap = face->charmaps[i];
-            if(cmap->platform_id == TT_PLATFORM_ISO) {
-                rc = FT_Set_Charmap(face, cmap);
-                if(rc == 0)
+        for (int i = 0; i < n; i++) {
+            FT_CharMap cmap = face->charmaps[i];
+            if (cmap->platform_id == TT_PLATFORM_ISO) {
+                int rc = FT_Set_Charmap(face, cmap);
+                if (rc == 0)
                     return 1;
             }
         }
@@ -1221,51 +1263,54 @@ find_cmap(int type, int pid, int eid, FT
 static int
 checkExtraEncoding(FT_Face face, const char *encoding_name, int found)
 {
-    int c;
-
-    if(strcasecmp(encoding_name, "iso10646-1") == 0) {
-        if(doISO10646_1_encoding && find_cmap(FONT_ENCODING_UNICODE, -1, -1, face)) {
+    if (strcasecmp(encoding_name, "iso10646-1") == 0) {
+        if (doISO10646_1_encoding &&
+            find_cmap(FONT_ENCODING_UNICODE, -1, -1, face)) {
             int cfound = 0;
-             /* Export as Unicode if there are at least 15 BMP
+
+            /* Export as Unicode if there are at least 15 BMP
                characters that are not a space or ignored. */
-            for(c = 0x21; c < 0x10000; c++) {
-                if(CODE_IGNORED(c))
+            for (unsigned int c = 0x21; c < 0x10000; c++) {
+                if (CODE_IGNORED(c))
                     continue;
-                if(FT_Get_Char_Index(face, c) > 0)
+                if (FT_Get_Char_Index(face, c) > 0)
                     cfound++;
-                if(cfound >= 15)
+                if (cfound >= 15)
                     return 1;
             }
             return 0;
-        } else
+        }
+        else
             return 0;
-    } else if(strcasecmp(encoding_name, "microsoft-symbol") == 0) {
-        if(find_cmap(FONT_ENCODING_TRUETYPE,
-                     TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS,
-                     face))
+    }
+    else if (strcasecmp(encoding_name, "microsoft-symbol") == 0) {
+        if (find_cmap(FONT_ENCODING_TRUETYPE,
+                      TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, face))
             return 1;
         else
             return 0;
-    } else if(strcasecmp(encoding_name, "adobe-fontspecific") == 0) {
-        if(!found) {
-            if(FT_Has_PS_Glyph_Names(face))
+    }
+    else if (strcasecmp(encoding_name, "adobe-fontspecific") == 0) {
+        if (!found) {
+            if (FT_Has_PS_Glyph_Names(face))
                 return 1;
             else
                 return 0;
-        } else
+        }
+        else
             return 0;
-    } else {
+    }
+    else {
         fprintf(stderr, "Unknown extra encoding %s\n", encoding_name);
         return 0;
     }
 }
 
-static const char*
+static const char *
 notice_foundry(const char *notice)
 {
-    unsigned int i;
-    for(i = 0; i < countof(notice_foundries); i++)
-        if(notice && strstr(notice, notice_foundries[i][0]))
+    for (unsigned int i = 0; i < countof(notice_foundries); i++)
+        if (notice && strstr(notice, notice_foundries[i][0]))
             return notice_foundries[i][1];
     return NULL;
 }
@@ -1275,70 +1320,72 @@ vendor_match(const signed char *vendor, 
 {
     /* vendor is not necessarily NUL-terminated. */
     size_t i, len;
+
     len = strlen(vendor_string);
-    if(memcmp(vendor, vendor_string, len) != 0)
+    if (memcmp(vendor, vendor_string, len) != 0)
         return 0;
-    for(i = len; i < 4; i++)
-        if(vendor[i] != ' ' && vendor[i] != '\0')
+    for (i = len; i < 4; i++)
+        if (vendor[i] != ' ' && vendor[i] != '\0')
             return 0;
     return 1;
 }
 
-static const char*
+static const char *
 vendor_foundry(const signed char *vendor)
 {
-    unsigned int i;
-    for(i = 0; i < countof(vendor_foundries); i++)
-        if(vendor_match(vendor, vendor_foundries[i][0]))
+    for (unsigned int i = 0; i < countof(vendor_foundries); i++)
+        if (vendor_match(vendor, vendor_foundries[i][0]))
             return vendor_foundries[i][1];
     return NULL;
 }
 
 static int
-readEncodings(ListPtr encodings, char *dirname)
+readEncodings(ListPtr *encodingsToDo, char *dirname)
 {
-    char *fullname;
     DIR *dirp;
     struct dirent *file;
-    char **names, **name;
 
-    if(strlen(dirname) > 1 && dirname[strlen(dirname) - 1] == '/')
+    if (strlen(dirname) > 1 && dirname[strlen(dirname) - 1] == '/')
         dirname[strlen(dirname) - 1] = '\0';
 
     dirp = opendir(dirname);
-    if(dirp == NULL) {
+    if (dirp == NULL) {
         perror("opendir");
         return -1;
     }
 
-    while((file = readdir(dirp)) != NULL) {
-        fullname = dsprintf("%s/%s", dirname, file->d_name);
-        if(fullname == NULL) {
+    while ((file = readdir(dirp)) != NULL) {
+        char *fullname = dsprintf("%s/%s", dirname, file->d_name);
+        char **names;
+
+        if (fullname == NULL) {
             fprintf(stderr, "Couldn't allocate fullname\n");
             closedir(dirp);
             return -1;
         }
 
         names = FontEncIdentify(fullname);
-        if(!names)
+        if (!names)
             continue;
 
-        for(name = names; *name; name++) {
-            if(fullname[0] != '/' && !relative) {
+        for (char **name = names; *name; name++) {
+            if (fullname[0] != '/' && !relative) {
                 char *n;
+
                 n = dsprintf("%s%s", encodingPrefix, fullname);
-                if(n == NULL) {
+                if (n == NULL) {
                     fprintf(stderr, "Couldn't allocate name\n");
                     closedir(dirp);
                     return -1;
                 }
-                encodingsToDo = listConsF(encodingsToDo, "%s %s", *name, n);
+                *encodingsToDo = listConsF(*encodingsToDo, "%s %s", *name, n);
                 free(n);
-            } else {
-                encodingsToDo =
-                    listConsF(encodingsToDo, "%s %s", *name, fullname);
             }
-            if(encodingsToDo == NULL) {
+            else {
+                *encodingsToDo =
+                    listConsF(*encodingsToDo, "%s %s", *name, fullname);
+            }
+            if (*encodingsToDo == NULL) {
                 fprintf(stderr, "Couldn't allocate encodings\n");
                 closedir(dirp);
                 return -1;

Index: xsrc/external/mit/xkbcomp/dist/expr.c
diff -u xsrc/external/mit/xkbcomp/dist/expr.c:1.4 xsrc/external/mit/xkbcomp/dist/expr.c:1.5
--- xsrc/external/mit/xkbcomp/dist/expr.c:1.4	Tue Apr 27 01:47:40 2021
+++ xsrc/external/mit/xkbcomp/dist/expr.c	Thu Jul  4 08:18:12 2024
@@ -94,7 +94,7 @@ exprOpText(unsigned type)
     return buf;
 }
 
-char *
+static char *
 exprTypeText(unsigned type)
 {
     static char buf[20];
@@ -127,9 +127,8 @@ exprTypeText(unsigned type)
 }
 
 int
-ExprResolveLhs(ExprDef * expr,
-               ExprResult * elem_rtrn,
-               ExprResult * field_rtrn, ExprDef ** index_rtrn)
+ExprResolveLhs(const ExprDef *expr, ExprResult *elem_rtrn,
+               ExprResult *field_rtrn, ExprDef **index_rtrn)
 {
     switch (expr->op)
     {
@@ -154,11 +153,10 @@ ExprResolveLhs(ExprDef * expr,
 }
 
 Bool
-SimpleLookup(XPointer priv,
-             Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
+SimpleLookup(const XPointer priv,
+             Atom elem, Atom field, unsigned type, ExprResult *val_rtrn)
 {
-    LookupEntry *entry;
-    register char *str;
+    char *str;
 
     if ((priv == NULL) ||
         (field == None) || (elem != None) ||
@@ -167,7 +165,7 @@ SimpleLookup(XPointer priv,
         return False;
     }
     str = XkbAtomGetString(NULL, field);
-    for (entry = (LookupEntry *) priv;
+    for (const LookupEntry *entry = (const LookupEntry *) priv;
          (entry != NULL) && (entry->name != NULL); entry++)
     {
         if (uStrCaseCmp(str, entry->name) == 0)
@@ -182,10 +180,10 @@ SimpleLookup(XPointer priv,
 }
 
 Bool
-RadioLookup(XPointer priv,
-            Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
+RadioLookup(const XPointer priv,
+            Atom elem, Atom field, unsigned type, ExprResult *val_rtrn)
 {
-    register char *str;
+    char *str;
     int rg;
 
     if ((field == None) || (elem != None) || (type != TypeInt))
@@ -209,12 +207,13 @@ RadioLookup(XPointer priv,
     return True;
 }
 
-int
+#if 0
+static int
 TableLookup(XPointer priv,
             Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
 {
     LookupTable *tbl = (LookupTable *) priv;
-    register char *str;
+    char *str;
 
     if ((priv == NULL) || (field == None) || (type != TypeInt))
         return False;
@@ -234,6 +233,7 @@ TableLookup(XPointer priv,
     priv = (XPointer) tbl->entries;
     return SimpleLookup(priv, (Atom) None, field, type, val_rtrn);
 }
+#endif
 
 static LookupEntry modIndexNames[] = {
     {"shift", ShiftMapIndex},
@@ -248,15 +248,15 @@ static LookupEntry modIndexNames[] = {
     {NULL, 0}
 };
 
-int
-LookupModIndex(XPointer priv,
-               Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
+Bool
+LookupModIndex(const XPointer priv,
+               Atom elem, Atom field, unsigned type, ExprResult *val_rtrn)
 {
     return SimpleLookup((XPointer) modIndexNames, elem, field, type,
                         val_rtrn);
 }
 
-int
+static int
 LookupModMask(XPointer priv,
               Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
 {
@@ -272,7 +272,7 @@ LookupModMask(XPointer priv,
     else if (uStrCaseCmp(str, "none") == 0)
         val_rtrn->uval = 0;
     else if (LookupModIndex(priv, elem, field, type, val_rtrn))
-        val_rtrn->uval = (1 << val_rtrn->uval);
+        val_rtrn->uval = (1U << val_rtrn->uval);
     else if (priv != NULL)
     {
         LookupPriv *lpriv = (LookupPriv *) priv;
@@ -286,8 +286,9 @@ LookupModMask(XPointer priv,
     return True;
 }
 
+#if 0
 int
-ExprResolveModIndex(ExprDef * expr,
+ExprResolveModIndex(const ExprDef *expr,
                     ExprResult * val_rtrn,
                     IdentLookupFunc lookup, XPointer lookupPriv)
 {
@@ -362,23 +363,23 @@ ExprResolveModIndex(ExprDef * expr,
     }
     return ok;
 }
+#endif
 
 int
-ExprResolveModMask(ExprDef * expr,
-                   ExprResult * val_rtrn,
+ExprResolveModMask(const ExprDef *expr, ExprResult *val_rtrn,
                    IdentLookupFunc lookup, XPointer lookupPriv)
 {
-    LookupPriv priv;
+    LookupPriv priv = {
+        .priv = NULL,
+        .chain = lookup,
+        .chainPriv = lookupPriv
+    };
 
-    priv.priv = NULL;
-    priv.chain = lookup;
-    priv.chainPriv = lookupPriv;
-    return ExprResolveMask(expr, val_rtrn, LookupModMask, (XPointer) & priv);
+    return ExprResolveMask(expr, val_rtrn, LookupModMask, (XPointer) &priv);
 }
 
 int
-ExprResolveBoolean(ExprDef * expr,
-                   ExprResult * val_rtrn,
+ExprResolveBoolean(const ExprDef *expr, ExprResult *val_rtrn,
                    IdentLookupFunc lookup, XPointer lookupPriv)
 {
     int ok = 0;
@@ -443,23 +444,24 @@ ExprResolveBoolean(ExprDef * expr,
             val_rtrn->uval = !val_rtrn->uval;
         return ok;
     case OpAdd:
-        if (bogus == NULL)
-            bogus = "Addition";
+        bogus = "Addition";
+        goto boolean;
     case OpSubtract:
-        if (bogus == NULL)
-            bogus = "Subtraction";
+        bogus = "Subtraction";
+        goto boolean;
     case OpMultiply:
-        if (bogus == NULL)
-            bogus = "Multiplication";
+        bogus = "Multiplication";
+        goto boolean;
     case OpDivide:
-        if (bogus == NULL)
-            bogus = "Division";
+        bogus = "Division";
+        goto boolean;
     case OpAssign:
-        if (bogus == NULL)
-            bogus = "Assignment";
+        bogus = "Assignment";
+        goto boolean;
     case OpNegate:
-        if (bogus == NULL)
-            bogus = "Negation";
+        bogus = "Negation";
+        goto boolean;
+    boolean:
         ERROR("%s of boolean values not permitted\n", bogus);
         break;
     case OpUnaryPlus:
@@ -473,8 +475,7 @@ ExprResolveBoolean(ExprDef * expr,
 }
 
 int
-ExprResolveFloat(ExprDef * expr,
-                 ExprResult * val_rtrn,
+ExprResolveFloat(const ExprDef *expr, ExprResult *val_rtrn,
                  IdentLookupFunc lookup, XPointer lookupPriv)
 {
     int ok = 0;
@@ -486,7 +487,7 @@ ExprResolveFloat(ExprDef * expr,
     case ExprValue:
         if (expr->type == TypeString)
         {
-            register char *str;
+            char *str;
             str = XkbAtomGetString(NULL, expr->value.str);
             if ((str != NULL) && (strlen(str) == 1))
             {
@@ -586,8 +587,7 @@ ExprResolveFloat(ExprDef * expr,
 }
 
 int
-ExprResolveInteger(ExprDef * expr,
-                   ExprResult * val_rtrn,
+ExprResolveInteger(const ExprDef *expr, ExprResult *val_rtrn,
                    IdentLookupFunc lookup, XPointer lookupPriv)
 {
     int ok = 0;
@@ -599,7 +599,7 @@ ExprResolveInteger(ExprDef * expr,
     case ExprValue:
         if (expr->type == TypeString)
         {
-            register char *str;
+            char *str;
             str = XkbAtomGetString(NULL, expr->value.str);
             if (str != NULL)
                 switch (strlen(str))
@@ -707,8 +707,7 @@ ExprResolveInteger(ExprDef * expr,
 }
 
 int
-ExprResolveString(ExprDef * expr,
-                  ExprResult * val_rtrn,
+ExprResolveString(const ExprDef *expr, ExprResult *val_rtrn,
                   IdentLookupFunc lookup, XPointer lookupPriv)
 {
     int ok = 0;
@@ -761,36 +760,44 @@ ExprResolveString(ExprDef * expr,
         if (ExprResolveString(left, &leftRtrn, lookup, lookupPriv) &&
             ExprResolveString(right, &rightRtrn, lookup, lookupPriv))
         {
-            int len;
             char *new;
-            len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
-            new = (char *) uAlloc(len);
+
+#ifdef HAVE_ASPRINTF
+            if (asprintf(&new, "%s%s", leftRtrn.str, rightRtrn.str) < 0)
+                new = NULL;
+#else
+            size_t len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
+            new = malloc(len);
+#endif
             if (new)
             {
+#ifndef HAVE_ASPRINTF
                 snprintf(new, len, "%s%s", leftRtrn.str, rightRtrn.str);
+#endif
                 val_rtrn->str = new;
                 return True;
             }
         }
         return False;
     case OpSubtract:
-        if (bogus == NULL)
-            bogus = "Subtraction";
+        bogus = "Subtraction";
+        goto string;
     case OpMultiply:
-        if (bogus == NULL)
-            bogus = "Multiplication";
+        bogus = "Multiplication";
+        goto string;
     case OpDivide:
-        if (bogus == NULL)
-            bogus = "Division";
+        bogus = "Division";
+        goto string;
     case OpAssign:
-        if (bogus == NULL)
-            bogus = "Assignment";
+        bogus = "Assignment";
+        goto string;
     case OpNegate:
-        if (bogus == NULL)
-            bogus = "Negation";
+        bogus = "Negation";
+        goto string;
     case OpInvert:
-        if (bogus == NULL)
-            bogus = "Bitwise complement";
+        bogus = "Bitwise complement";
+        goto string;
+    string:
         ERROR("%s of string values not permitted\n", bogus);
         return False;
     case OpNot:
@@ -815,8 +822,7 @@ ExprResolveString(ExprDef * expr,
 }
 
 int
-ExprResolveKeyName(ExprDef * expr,
-                   ExprResult * val_rtrn,
+ExprResolveKeyName(const ExprDef *expr, ExprResult *val_rtrn,
                    IdentLookupFunc lookup, XPointer lookupPriv)
 {
     int ok = 0;
@@ -858,26 +864,27 @@ ExprResolveKeyName(ExprDef * expr,
                    XkbAtomText(NULL, expr->value.field.field, XkbMessage));
         return ok;
     case OpAdd:
-        if (bogus == NULL)
-            bogus = "Addition";
+        bogus = "Addition";
+        goto keyname;
     case OpSubtract:
-        if (bogus == NULL)
-            bogus = "Subtraction";
+        bogus = "Subtraction";
+        goto keyname;
     case OpMultiply:
-        if (bogus == NULL)
-            bogus = "Multiplication";
+        bogus = "Multiplication";
+        goto keyname;
     case OpDivide:
-        if (bogus == NULL)
-            bogus = "Division";
+        bogus = "Division";
+        goto keyname;
     case OpAssign:
-        if (bogus == NULL)
-            bogus = "Assignment";
+        bogus = "Assignment";
+        goto keyname;
     case OpNegate:
-        if (bogus == NULL)
-            bogus = "Negation";
+        bogus = "Negation";
+        goto keyname;
     case OpInvert:
-        if (bogus == NULL)
-            bogus = "Bitwise complement";
+        bogus = "Bitwise complement";
+        goto keyname;
+    keyname:
         ERROR("%s of key name values not permitted\n", bogus);
         return False;
     case OpNot:
@@ -904,7 +911,8 @@ ExprResolveKeyName(ExprDef * expr,
 /***====================================================================***/
 
 int
-ExprResolveEnum(ExprDef * expr, ExprResult * val_rtrn, LookupEntry * values)
+ExprResolveEnum(const ExprDef *expr, ExprResult *val_rtrn,
+                const LookupEntry *values)
 {
     if (expr->op != ExprIdent)
     {
@@ -934,13 +942,12 @@ ExprResolveEnum(ExprDef * expr, ExprResu
 }
 
 int
-ExprResolveMask(ExprDef * expr,
-                ExprResult * val_rtrn,
+ExprResolveMask(const ExprDef *expr, ExprResult *val_rtrn,
                 IdentLookupFunc lookup, XPointer lookupPriv)
 {
     int ok = 0;
     ExprResult leftRtrn, rightRtrn;
-    ExprDef *left, *right;
+    const ExprDef *left, *right;
     const char *bogus = NULL;
 
     switch (expr->op)
@@ -979,9 +986,11 @@ ExprResolveMask(ExprDef * expr,
         return ok;
     case ExprArrayRef:
         bogus = "array reference";
+        goto unexpected_mask;
     case ExprActionDecl:
-        if (bogus == NULL)
-            bogus = "function use";
+        bogus = "function use";
+        goto unexpected_mask;
+    unexpected_mask:
         ERROR("Unexpected %s in mask expression\n", bogus);
         ACTION("Expression ignored\n");
         return False;
@@ -1041,16 +1050,16 @@ ExprResolveMask(ExprDef * expr,
 }
 
 int
-ExprResolveKeySym(ExprDef * expr,
-                  ExprResult * val_rtrn,
+ExprResolveKeySym(const ExprDef *expr, ExprResult *val_rtrn,
                   IdentLookupFunc lookup, XPointer lookupPriv)
 {
     int ok = 0;
-    KeySym sym;
 
     if (expr->op == ExprIdent)
     {
-        char *str;
+        const char *str;
+        KeySym sym;
+
         str = XkbAtomGetString(NULL, expr->value.str);
         if ((str != NULL) && ((sym = XStringToKeysym(str)) != NoSymbol))
         {

Index: xsrc/external/mit/xkbcomp/dist/utils.h
diff -u xsrc/external/mit/xkbcomp/dist/utils.h:1.6 xsrc/external/mit/xkbcomp/dist/utils.h:1.7
--- xsrc/external/mit/xkbcomp/dist/utils.h:1.6	Tue Apr 27 01:47:40 2021
+++ xsrc/external/mit/xkbcomp/dist/utils.h	Thu Jul  4 08:18:12 2024
@@ -29,15 +29,17 @@
 
 /***====================================================================***/
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include 	<stdio.h>
+#include 	<stdlib.h>
 #include	<X11/Xos.h>
 #include	<X11/Xfuncproto.h>
 #include	<X11/Xfuncs.h>
 
 #include <stddef.h>
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
 
 #ifndef NUL
 #define	NUL	'\0'
@@ -45,13 +47,6 @@
 
 /***====================================================================***/
 
-#ifndef OPAQUE_DEFINED
-typedef void *Opaque;
-#endif
-#ifndef NullOpaque
-#define	NullOpaque	((Opaque)NULL)
-#endif
-
 #ifndef BOOLEAN_DEFINED
 typedef char Boolean;
 #endif
@@ -74,37 +69,23 @@ typedef int Comparison;
 
 /***====================================================================***/
 
-extern Opaque uAlloc(unsigned   /* size */
-    );
-extern Opaque uCalloc(unsigned /* n */ ,
-                      unsigned  /* size */
-    );
-extern Opaque uRealloc(Opaque /* old */ ,
-                       unsigned /* newSize */
-    );
-extern Opaque uRecalloc(Opaque /* old */ ,
-                        unsigned /* nOld */ ,
-                        unsigned /* nNew */ ,
-                        unsigned        /* newSize */
-    );
-extern void uFree(Opaque        /* ptr */
-    );
+#ifndef HAVE_REALLOCARRAY
+#define reallocarray(p, n, s) realloc(p, (n) * (s))
+#endif
 
-#define	uTypedAlloc(t)		((t *)uAlloc((unsigned)sizeof(t)))
-#define	uTypedCalloc(n,t)	((t *)uCalloc((unsigned)n,(unsigned)sizeof(t)))
-#define	uTypedRealloc(pO,n,t)	((t *)uRealloc((Opaque)pO,((unsigned)n)*sizeof(t)))
-#define	uTypedRecalloc(pO,o,n,t) ((t *)uRecalloc((Opaque)pO,((unsigned)o),((unsigned)n),sizeof(t)))
-#if (defined mdHasAlloca) && (mdHasAlloca)
-#define	uTmpAlloc(n)	((Opaque)alloca((unsigned)n))
-#define	uTmpFree(p)
-#else
-#define	uTmpAlloc(n)	uAlloc(n)
-#define	uTmpFree(p)	uFree(p)
+#ifndef HAVE_RECALLOCARRAY
+#define recallocarray uRecalloc
+
+extern void *uRecalloc(void * /* old */ ,
+                       size_t /* nOld */ ,
+                       size_t /* nNew */ ,
+                       size_t /* newSize */
+    );
 #endif
 
 /***====================================================================***/
 
-extern Boolean uSetErrorFile(char *     /* name */
+extern Boolean uSetErrorFile(const char * /* name */
     );
 
 #define INFO 			uInformation
@@ -139,13 +120,13 @@ uInformation(const char * /* s */ , ...
      extern void uInternalError(const char * /* s  */ , ...
     ) _X_ATTRIBUTE_PRINTF(1, 2);
 
-     extern void uSetPreErrorMessage(char *     /* msg */
+     extern void uSetPreErrorMessage(const char * /* msg */
     );
 
-     extern void uSetPostErrorMessage(char *    /* msg */
+     extern void uSetPostErrorMessage(const char * /* msg */
     );
 
-     extern void uSetErrorPrefix(char * /* void */
+     extern void uSetErrorPrefix(const char * /* void */
     );
 
      extern void uFinishUp(void);
@@ -183,40 +164,28 @@ uInformation(const char * /* s */ , ...
 
 /***====================================================================***/
 
+#ifdef DEBUG
 #ifndef DEBUG_VAR
 #define	DEBUG_VAR	debugFlags
 #endif
 
-extern
-     unsigned int DEBUG_VAR;
+extern unsigned int DEBUG_VAR;
 
-     extern void uDebug(char * /* s  */ , ...
-    ) _X_ATTRIBUTE_PRINTF(1, 2);
+extern void uDebug(const char *, ...)  _X_ATTRIBUTE_PRINTF(1, 2);
 
-     extern void uDebugNOI(     /* no indent */
-                              char * /* s  */ , ...
-    ) _X_ATTRIBUTE_PRINTF(1, 2);
+extern Boolean uSetDebugFile(const char *name);
 
-     extern Boolean uSetDebugFile(char *name);
+extern int uDebugIndentLevel;
 
-     extern FILE *uDebugFile;
-     extern int uDebugIndentLevel;
-     extern int uDebugIndentSize;
 #define	uDebugIndent(l)		(uDebugIndentLevel+=(l))
 #define	uDebugOutdent(l)	(uDebugIndentLevel-=(l))
-#ifdef DEBUG
+
 #define	uDEBUG(f,s)		{ if (DEBUG_VAR&(f)) uDebug(s);}
 #define	uDEBUG1(f,s,a)		{ if (DEBUG_VAR&(f)) uDebug(s,a);}
 #define	uDEBUG2(f,s,a,b)	{ if (DEBUG_VAR&(f)) uDebug(s,a,b);}
 #define	uDEBUG3(f,s,a,b,c)	{ if (DEBUG_VAR&(f)) uDebug(s,a,b,c);}
 #define	uDEBUG4(f,s,a,b,c,d)	{ if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d);}
 #define	uDEBUG5(f,s,a,b,c,d,e)	{ if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d,e);}
-#define	uDEBUG_NOI(f,s)		{ if (DEBUG_VAR&(f)) uDebug(s);}
-#define	uDEBUG_NOI1(f,s,a)	{ if (DEBUG_VAR&(f)) uDebugNOI(s,a);}
-#define	uDEBUG_NOI2(f,s,a,b)	{ if (DEBUG_VAR&(f)) uDebugNOI(s,a,b);}
-#define	uDEBUG_NOI3(f,s,a,b,c)	{ if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c);}
-#define	uDEBUG_NOI4(f,s,a,b,c,d) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d);}
-#define	uDEBUG_NOI5(f,s,a,b,c,d,e) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d,e);}
 #else
 #define	uDEBUG(f,s)
 #define	uDEBUG1(f,s,a)
@@ -224,12 +193,6 @@ extern
 #define	uDEBUG3(f,s,a,b,c)
 #define	uDEBUG4(f,s,a,b,c,d)
 #define	uDEBUG5(f,s,a,b,c,d,e)
-#define	uDEBUG_NOI(f,s)
-#define	uDEBUG_NOI1(f,s,a)
-#define	uDEBUG_NOI2(f,s,a,b)
-#define	uDEBUG_NOI3(f,s,a,b,c)
-#define	uDEBUG_NOI4(f,s,a,b,c,d)
-#define	uDEBUG_NOI5(f,s,a,b,c,d,e)
 #endif
 
 #endif /* UTILS_H */

Reply via email to