Module Name:    xsrc
Committed By:   mrg
Date:           Sun Mar  3 09:18:36 UTC 2019

Modified Files:
        xsrc/external/mit/mkfontscale/dist: ident.c mkfontscale.c
Removed Files:
        xsrc/external/mit/bitmap/dist: README
        xsrc/external/mit/mkfontscale/dist: README

Log Message:
merge bitmap 1.0.9 and mkfontscale 1.2.0.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r0 xsrc/external/mit/bitmap/dist/README
cvs rdiff -u -r1.1.1.3 -r0 xsrc/external/mit/mkfontscale/dist/README
cvs rdiff -u -r1.6 -r1.7 xsrc/external/mit/mkfontscale/dist/ident.c \
    xsrc/external/mit/mkfontscale/dist/mkfontscale.c

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/mkfontscale/dist/ident.c
diff -u xsrc/external/mit/mkfontscale/dist/ident.c:1.6 xsrc/external/mit/mkfontscale/dist/ident.c:1.7
--- xsrc/external/mit/mkfontscale/dist/ident.c:1.6	Sun Mar 11 08:02:46 2018
+++ xsrc/external/mit/mkfontscale/dist/ident.c	Sun Mar  3 09:18:36 2019
@@ -76,12 +76,12 @@ typedef struct {
 	gzFile gz;
 	BZFILE *bz2;
     } f;
-    unsigned pos;
+    unsigned long pos;
 } fontFile;
 
 static inline void *
 fontFileOpen(fontFile *ff, const char *filename) {
-    int n = strlen(filename);
+    size_t n = strlen(filename);
 
     if (n > 4 && strcmp(filename + n - 4, ".bz2") == 0) {
 	ff->type = bz2FontFile;
@@ -123,7 +123,7 @@ fontFileGetc(fontFile *ff)
     }
 }
 
-static int
+static long
 fontFileSeek(fontFile *ff, z_off_t offset, int whence)
 {
     if (ff->type == gzFontFile) {
@@ -132,7 +132,7 @@ fontFileSeek(fontFile *ff, z_off_t offse
 	/* bzlib has no easy equivalent so we have to fake it,
 	 * fortunately, we only have to handle a couple of cases
 	 */
-	int n;
+	z_off_t n;
 	char buf[BUFSIZ];
 
 	switch (whence) {
@@ -151,7 +151,7 @@ fontFileSeek(fontFile *ff, z_off_t offse
 		return -1;
 	    n -= BUFSIZ;
 	}
-	if (BZ2_bzread(ff->f.bz2, buf, n) != n)
+	if (BZ2_bzread(ff->f.bz2, buf, (int) n) != n)
 	    return -1;
 	ff->pos = offset;
 	return offset;
@@ -247,7 +247,8 @@ pcfIdentify(fontFile *f, char **name)
 {
     int prop_position;
     PropPtr props = NULL;
-    int format, count, nprops, i, string_size, rc;
+    int format, count, nprops, i, string_size;
+    long rc;
     char *strings = NULL, *s;
 
     count = getLSB32(f);
Index: xsrc/external/mit/mkfontscale/dist/mkfontscale.c
diff -u xsrc/external/mit/mkfontscale/dist/mkfontscale.c:1.6 xsrc/external/mit/mkfontscale/dist/mkfontscale.c:1.7
--- xsrc/external/mit/mkfontscale/dist/mkfontscale.c:1.6	Sun Mar 11 08:02:46 2018
+++ xsrc/external/mit/mkfontscale/dist/mkfontscale.c	Sun Mar  3 09:18:36 2019
@@ -48,6 +48,7 @@
 #include FT_XFREE86_H
 
 #include "list.h"
+#include "constlist.h"
 #include "hash.h"
 #include "data.h"
 #include "ident.h"
@@ -88,14 +89,14 @@ static char *encodings_array[] =
 static char *extra_encodings_array[] =
     { "iso10646-1", "adobe-fontspecific", "microsoft-symbol" };
 
-static ListPtr encodings, extra_encodings;
+static ConstListPtr encodings, extra_encodings;
 static const char *outfilename;
 
 #define countof(_a) (sizeof(_a)/sizeof((_a)[0]))
 
 static int doDirectory(const char*, int, ListPtr);
-static int checkEncoding(FT_Face face, char *encoding_name);
-static int checkExtraEncoding(FT_Face face, char *encoding_name, int found);
+static int checkEncoding(FT_Face face, const char *encoding_name);
+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);
@@ -152,16 +153,17 @@ main(int argc, char **argv)
         exit(1);
     }
     if(prefix[strlen(prefix) - 1] != '/')
-        strcat(prefix, "/");
-    encodingPrefix = dsprintf("%s", prefix);
+        encodingPrefix = dsprintf("%s/", prefix);
+    else
+        encodingPrefix = strdup(prefix);
 
     outfilename = NULL;
 
-    encodings = makeList(encodings_array, countof(encodings_array), NULL, 0);
+    encodings = makeConstList(encodings_array, countof(encodings_array), NULL, 0);
 
-    extra_encodings = makeList(extra_encodings_array,
-                               countof(extra_encodings_array),
-                               NULL, 0);
+    extra_encodings = makeConstList(extra_encodings_array,
+				    countof(extra_encodings_array),
+				    NULL, 0);
     doBitmaps = 0;
     doISO10646_1_encoding = 1;
     doScalable = 1;
@@ -187,7 +189,7 @@ main(int argc, char **argv)
             if(argn >= argc - 1) {
                 missing_arg("-a");
             }
-            makeList(&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) {
@@ -199,7 +201,7 @@ main(int argc, char **argv)
                 usage();
             }
             free(encodingPrefix);
-            encodingPrefix = dsprintf("%s", argv[argn + 1]);
+            encodingPrefix = strdup(argv[argn + 1]);
             argn += 2;
         } else if(strcmp(argv[argn], "-e") == 0) {
             if(argn >= argc - 1) {
@@ -320,7 +322,7 @@ getName(FT_Face face, int nid)
 {
     FT_SfntName name;
     char *string;
-    int i;
+    unsigned int i;
 
     if(getNameHelper(face, nid,
                      TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, &name) ||
@@ -414,8 +416,8 @@ static const char*
 nameWidth(const char *name)
 {
     char buf[500];
-    int i;
-    int n = strlen(name);
+    unsigned int i;
+    size_t n = strlen(name);
 
     if(n >= 499) return NULL;
     for(i = 0; i < n; i++)
@@ -699,7 +701,7 @@ makeXLFD(char *filename, FT_Face face, i
 static int
 readFontScale(HashTablePtr entries, char *dirname)
 {
-    int n = strlen(dirname);
+    size_t n = strlen(dirname);
     char *filename;
     FILE *in;
     int rc, count, i;
@@ -743,7 +745,7 @@ readFontScale(HashTablePtr entries, char
 static int
 filePrio(char *filename)
 {
-    int n = strlen(filename);
+    size_t n = strlen(filename);
     if(n < 4)
         return 0;
     if(strcmp(filename + n - 4, ".otf") == 0)
@@ -778,26 +780,27 @@ doDirectory(const char *dirname_given, i
 {
     char *dirname, *fontscale_name, *filename, *encdir;
     FILE *fontscale, *encfile;
-    DIR *dirp;
-    struct dirent *entry;
+    struct dirent** namelist;
     FT_Error ftrc;
     FT_Face face;
-    ListPtr encoding, xlfd, lp;
+    ConstListPtr encoding;
+    ListPtr xlfd, lp;
     HashTablePtr entries;
     HashBucketPtr *array;
-    int i, n, found, rc;
-    int isBitmap=0,xl=0;
+    int i, n, dirn, diri, found, rc;
+    int isBitmap=0;
+    size_t d, xl=0;
 
     if (exclusionSuffix)
         xl = strlen (exclusionSuffix);
 
-    i = strlen(dirname_given);
-    if(i == 0)
+    d = strlen(dirname_given);
+    if(d == 0)
         dirname = dsprintf("./");
-    else if(dirname_given[i - 1] != '/')
+    else if(dirname_given[d - 1] != '/')
         dirname = dsprintf("%s/", dirname_given);
     else
-        dirname = dsprintf("%s", dirname_given);
+        dirname = strdup(dirname_given);
 
     if(dirname == NULL) {
         perror("dirname");
@@ -816,7 +819,7 @@ doDirectory(const char *dirname_given, i
         fontscale_name = NULL;
     else {
         if(outfilename[0] == '/')
-            fontscale_name = dsprintf("%s", outfilename);
+            fontscale_name = strdup(outfilename);
         else
             fontscale_name = dsprintf("%s%s", dirname, outfilename);
         if(fontscale_name == NULL) {
@@ -825,10 +828,10 @@ doDirectory(const char *dirname_given, i
         }
     }
 
-    dirp = opendir(dirname);
-    if(dirp == NULL) {
+    dirn = scandir(dirname, &namelist, NULL, alphasort);
+    if(dirn < 0) {
         fprintf(stderr, "%s: ", dirname);
-        perror("opendir");
+        perror("scandir");
         return 0;
     }
 
@@ -843,7 +846,8 @@ doDirectory(const char *dirname_given, i
         return 0;
     }
 
-    while((entry = readdir(dirp)) != NULL) {
+    for(diri = dirn - 1; diri >= 0; diri--) {
+        struct dirent *entry = namelist[diri];
         int have_face = 0;
         char *xlfd_name = NULL;
 	struct stat f_stat;
@@ -852,7 +856,7 @@ doDirectory(const char *dirname_given, i
         xlfd = NULL;
 
 	if (xl) {
-	    int dl = strlen (entry->d_name);
+	    size_t dl = strlen (entry->d_name);
 	    if (strcmp (entry->d_name + dl - xl, exclusionSuffix) == 0)
 		continue;
 	}
@@ -924,14 +928,14 @@ doDirectory(const char *dirname_given, i
 
         if(xlfd_name) {
             /* We know it's a bitmap font, and we know its XLFD */
-            int n = strlen(xlfd_name);
+            size_t l = strlen(xlfd_name);
             if(reencodeLegacy &&
-               n >= 12 && strcasecmp(xlfd_name + n - 11, "-iso10646-1") == 0) {
+               l >= 12 && strcasecmp(xlfd_name + l - 11, "-iso10646-1") == 0) {
                 char *s;
 
-                s = malloc(n - 10);
-                memcpy(s, xlfd_name, n - 11);
-                s[n - 11] = '\0';
+                s = malloc(l - 10);
+                memcpy(s, xlfd_name, l - 11);
+                s[l - 11] = '\0';
                 xlfd = listCons(s, xlfd);
             } else {
                 /* Not a reencodable font -- skip all the rest of the loop body */
@@ -991,7 +995,9 @@ doDirectory(const char *dirname_given, i
 #undef PRIO
     }
 
-    closedir(dirp);
+    while(dirn--)
+        free(namelist[dirn]);
+    free(namelist);
     n = hashElements(entries);
     fprintf(fontscale, "%d\n", n);
     array = hashArray(entries, 1);
@@ -1036,7 +1042,7 @@ doDirectory(const char *dirname_given, i
                          (c) == 0xAD || (c) == 0xF71B)
 
 static int
-checkEncoding(FT_Face face, char *encoding_name)
+checkEncoding(FT_Face face, const char *encoding_name)
 {
     FontEncPtr encoding;
     FontMapPtr mapping;
@@ -1208,21 +1214,21 @@ find_cmap(int type, int pid, int eid, FT
 }
 
 static int
-checkExtraEncoding(FT_Face face, char *encoding_name, int found)
+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)) {
-            int found = 0;
+            int cfound = 0;
              /* 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))
                     continue;
                 if(FT_Get_Char_Index(face, c) > 0)
-                    found++;
-                if(found >= 15)
+                    cfound++;
+                if(cfound >= 15)
                     return 1;
             }
             return 0;
@@ -1252,7 +1258,7 @@ checkExtraEncoding(FT_Face face, char *e
 static const char*
 notice_foundry(const char *notice)
 {
-    int i;
+    unsigned int i;
     for(i = 0; i < countof(notice_foundries); i++)
         if(notice && strstr(notice, notice_foundries[i][0]))
             return notice_foundries[i][1];
@@ -1263,7 +1269,7 @@ static int
 vendor_match(const signed char *vendor, const char *vendor_string)
 {
     /* vendor is not necessarily NUL-terminated. */
-    int i, len;
+    size_t i, len;
     len = strlen(vendor_string);
     if(memcmp(vendor, vendor_string, len) != 0)
         return 0;
@@ -1276,7 +1282,7 @@ vendor_match(const signed char *vendor, 
 static const char*
 vendor_foundry(const signed char *vendor)
 {
-    int i;
+    unsigned int i;
     for(i = 0; i < countof(vendor_foundries); i++)
         if(vendor_match(vendor, vendor_foundries[i][0]))
             return vendor_foundries[i][1];

Reply via email to