added makefile-defnied bit directories
[unix-history] / usr / src / local / ditroff / ditroff.old.okeeffe / driver / makeifont.c
index 9ce083e..13fd242 100644 (file)
@@ -1,20 +1,23 @@
-/* Font description file producer:  David Slattengren
+/*     makeifont.c     (Berkeley)      1.7     85/02/26
+ *
+ * Font description file producer for imagen fonts:  David Slattengren
  * Taken from vfontinfo by Andy Hertzfeld  4/79
  *
  * Taken from vfontinfo by Andy Hertzfeld  4/79
  *
- *     Use:  mkfnt [ -nNAME ]  [ -smial ]  [ "-xs1,s2[;s1,s2...]" ]
+ *  Use:  makeifont [ -nNAME ]  [ -i -s -a -o -l -c ]  [ "-xs1,s2[;s1,s2...]" ]
  *             [ "-ys1,s2[;s1,s2...]" ]  [ -p# ]  [ -r# ]  [ -ddir ]  font
  *
  *     Mkfnt takes the font named "font" and produces a ditroff description
  *     file from it.  The -n option takes the 1 or 2 letter troff name to put
  *             [ "-ys1,s2[;s1,s2...]" ]  [ -p# ]  [ -r# ]  [ -ddir ]  font
  *
  *     Mkfnt takes the font named "font" and produces a ditroff description
  *     file from it.  The -n option takes the 1 or 2 letter troff name to put
- *     the description (default = XX).  The -s, -m, -i, -a options select a
+ *     the description (default = XX).  The -s, -o, -i, -a options select a
  *     different character mapping than for a "roman" font.  s = special;
  *     different character mapping than for a "roman" font.  s = special;
- *     m = math;  i = italics;  a = ascii.  The -l option tells if the font
- *     has ligatures.
+ *     o = math;  i = italics;  a = ascii.  The -l option tells if the font
+ *     has ligatures.  The -c option tells makeifont that the font is a
+ *     constant width one and sets parameters appropriately.
  *
  *     Both -x and -y options allow character name mapping.  A semi-colon
  *     separated list of comma-separated character-name pairs follows the
  *     x or y.  Notice that there are no spaces in the -x or -y command.  It
  *
  *     Both -x and -y options allow character name mapping.  A semi-colon
  *     separated list of comma-separated character-name pairs follows the
  *     x or y.  Notice that there are no spaces in the -x or -y command.  It
- *     is also IMPORTANT to enclose these arguments in double quotes to stop
+ *     is also IMPORTANT to enclose these arguments in single quotes to stop
  *     the cshell from interpretting the contents.  A -x pair REPLACES the
  *     definition for s1 by s2.  A -y pair creates a synonym for s1 and calls
  *     it s2.  -x and -y MUST be sent after -s, -m, -i, or -a  if one of them
  *     the cshell from interpretting the contents.  A -x pair REPLACES the
  *     definition for s1 by s2.  A -y pair creates a synonym for s1 and calls
  *     it s2.  -x and -y MUST be sent after -s, -m, -i, or -a  if one of them
@@ -22,7 +25,7 @@
  *     acter, leave out s2.
  *
  *     The -p# option tells what point size the DESC file has
  *     acter, leave out s2.
  *
  *     The -p# option tells what point size the DESC file has
- *     as it's "unitwidth" argument (default: 36).  The -r# option is the
+ *     as it's "unitwidth" argument (default: 40).  The -r# option is the
  *     resolution of the device (default: 240, in units/inch).  The -d option
  *     tells where to find fonts (default: /usr/src/local/imagen/fonts/raster).
  */
  *     resolution of the device (default: 240, in units/inch).  The -d option
  *     tells where to find fonts (default: /usr/src/local/imagen/fonts/raster).
  */
 #include <ctype.h>
 #include "rst.h"
 
 #include <ctype.h>
 #include "rst.h"
 
-char   sccsid[] = "@(#)makeifont.c     1.2     (Berkeley)      %G%";
+char   sccsid[] = "@(#)makeifont.c     1.7     (Berkeley)      %G%";
 
 #define PCNTUP         62      /* percent of maximum height for an ascender */
 #define PCNTDOWN       73      /* percent of maximum droop for a descender */
 
 #define PCNTUP         62      /* percent of maximum height for an ascender */
 #define PCNTDOWN       73      /* percent of maximum droop for a descender */
-#define FONTDIR                "/usr/src/local/imagen/fonts/raster"
+#ifndef BITDIR
+#define BITDIR         "/usr/src/local/imagen/fonts/raster"
+#endif
 #define POINTSIZE      40      /* this is the "unitwidth" point size */
 #define MINSIZE                6       /* the minimum and maximum point size values */
 #define MAXSIZE                36      /*    acceptible for use as "unitwidth"s */
 #define POINTSIZE      40      /* this is the "unitwidth" point size */
 #define MINSIZE                6       /* the minimum and maximum point size values */
 #define MAXSIZE                36      /*    acceptible for use as "unitwidth"s */
@@ -82,15 +87,16 @@ int psizelist[] = { 40, 36, 28, 24, 22, 20, 18, 16,
                        14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 0 };
 
 char   *fontname = "XX";       /* troff name of font - set on command line */
                        14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 0 };
 
 char   *fontname = "XX";       /* troff name of font - set on command line */
-char   *fontdir = FONTDIR;     /* place to look for fonts */
+char   *fontdir = BITDIR;      /* place to look for fonts */
 char   IName[100];             /* input file name put here */
 char   *rdchar ();             /* function makes strings for ascii */
 char   IName[100];             /* input file name put here */
 char   *rdchar ();             /* function makes strings for ascii */
-int    FID = -1;               /* input file number */
+FILE * FID = NULL;             /* input file number */
 
 int    maxdown = 0;            /* size of the most "droopy" character */
 int    maxup = 0;              /* size of the tallest character */
 int    type;                   /* 1, 2, or 3 for type of ascend/descending */
 int    ligsf = 0;              /* flag "does this font have ligatures?" */
 
 int    maxdown = 0;            /* size of the most "droopy" character */
 int    maxup = 0;              /* size of the tallest character */
 int    type;                   /* 1, 2, or 3 for type of ascend/descending */
 int    ligsf = 0;              /* flag "does this font have ligatures?" */
+int    constant = 0;           /* flag constant width font (spacewidth, etc.)*/
 
                                /* following are the character maps for */
                                /* ascii code-conversion to printables... */
 
                                /* following are the character maps for */
                                /* ascii code-conversion to printables... */
@@ -128,7 +134,7 @@ char *iascii[] = {
        "<", "=", ">", "?",
        "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
        "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[",
        "<", "=", ">", "?",
        "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
        "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[",
-       "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i",
+       "\\", "]", "^", "em", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i",
        "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
        "x", "y", "z", "{", "|", "}", "~", "dm"
 };
        "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
        "x", "y", "z", "{", "|", "}", "~", "dm"
 };
@@ -146,27 +152,27 @@ char *ispecial[] = {
        "?1", "?2", "cr", "", "/", "A", "B", "C", "D", "E", "F", "G", "H", "I",
        "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
        "X", "Y", "Z", "cu", "ca", "c+", "an", "or", "|-", "-|", "lf", "rf",
        "?1", "?2", "cr", "", "/", "A", "B", "C", "D", "E", "F", "G", "H", "I",
        "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
        "X", "Y", "Z", "cu", "ca", "c+", "an", "or", "|-", "-|", "lf", "rf",
-       "lc", "rc", "{", "}", "<", ">", "bv", "||", "[[", "]]", "", "", "sr",
+       "lc", "rc", "{", "}", "<", ">", "br", "||", "[[", "]]", "", "", "sr",
        "#", "gr", "is", "ux", "dx", "rx", "dm", "sc", "dg", "dd", "pp", "@",
        "co", "", "$"
 };
        "#", "gr", "is", "ux", "dx", "rx", "dm", "sc", "dg", "dd", "pp", "@",
        "co", "", "$"
 };
-int    nspecial = 0;
+int    nspecial = 2;
 char *sspecial[SYNON] = {
 char *sspecial[SYNON] = {
-       "",""
+       "lh", "La",     "rh", "Ra"
 };
 
 char *imath[] = {
 };
 
 char *imath[] = {
-       "", "", "", "", "lf", "rf", "lc", "rc", "", "", "", "",
-       "", "", "/", "", "", "", "", "", "", "", "",
-       "", "", "", "", "", "", "", "", "", "", "", "",
-       "", "", "", "", "", "", "", "", "", "", "", "Bl", "Br",
-       "", "", "", "", "", "", "", "", "lt", "rt", "lb", "rb",
-       "lk", "rk", "", "", "", "", "", "", "", "", "", "", "", "", "",
-       "", "", "", "", "", "", "", "", "", "", "", "",
-       "", "", "", "", "", "", "", "", "", "", "", "", "",
-       "LT", "RT", "LB", "RB", "", "", "", "", "", "", "", "", "",
-       "", "", "", "", "", "", "",
-       "", "?0", "", "", "", "", "?1", "?2"
+       "Bl", "Br", "LT", "RT", "LB", "RB", "rt", "rk", "rb", "lt", "lk", "lb",
+       "rc", "lc", "rf", "lf", "bv", "ci", "^R", "^S", "^T", "^U", "^V", "^W",
+       "^X", "^Y", "^Z", "^[", "^\\", "^]", "^^", "^_",
+       " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-",
+       ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";",
+       "<", "=", ">", "?",
+       "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
+       "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[",
+       "\\", "]", "^", "em", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i",
+       "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
+       "x", "y", "z", "{", "|", "}", "~", "dm"
 };
 int    nmath = 0;
 char *smath[SYNON] = {
 };
 int    nmath = 0;
 char *smath[SYNON] = {
@@ -177,14 +183,14 @@ char *iitalics[] = {
        "*G", "*D", "*H", "*L", "*C", "*P", "*S", "*U", "*F", "*Q", "*W",
        "*a", "*b", "*g", "*d", "*e", "*z", "*y", "*h", "*i", "*k", "*l",
        "*m", "*n", "*c", "*p", "*r", "*s", "*t", "*u", "*f", "*x", "id",
        "*G", "*D", "*H", "*L", "*C", "*P", "*S", "*U", "*F", "*Q", "*W",
        "*a", "*b", "*g", "*d", "*e", "*z", "*y", "*h", "*i", "*k", "*l",
        "*m", "*n", "*c", "*p", "*r", "*s", "*t", "*u", "*f", "*x", "id",
-       "!", "\"", "el", "?0", "pd", "&", "'", "(", ")", "*", "+", ",", "hy",
+       "!", "\"", "el", "Fi", "pd", "&", "'", "(", ")", "*", "+", ",", "hy",
        ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";",
        "<", "=", ">", "?",
        "id", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
        "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[",
        ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";",
        "<", "=", ">", "?",
        "id", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
        "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[",
-       "", "]", "", "", "`", "a", "b", "c", "d", "e", "f", "g", "h",
+       "ff", "]", "fi", "fl", "`", "a", "b", "c", "d", "e", "f", "g", "h",
        "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
        "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
-       "w", "x", "y", "z", "*q", "*w", "?2", "?1", "w-"
+       "w", "x", "y", "z", "*q", "*w", "?2", "?1", "Fl"
 };
 int    nitalics = 15;
 char *sitalics[SYNON] = {
 };
 int    nitalics = 15;
 char *sitalics[SYNON] = {
@@ -204,21 +210,24 @@ char **argv;
     register int j;
     register char *ptr;                /* string traveller */
     register char delimit;     /* place for delemiters on command-line */
     register int j;
     register char *ptr;                /* string traveller */
     register char delimit;     /* place for delemiters on command-line */
+    char *replacelist = NULL;  /* list of character-name replacements */
+    char *synonymlist = NULL;  /* list of synonym entries */
     char tostring();           /* function makes string */
     char *nextstring();                /* moves to next string on list */
     char tostring();           /* function makes string */
     char *nextstring();                /* moves to next string on list */
+    char *operand();           /* reads operands from commandline */
 
     charmap = iregular;                        /* default character map */
     synonyms = sregular;
     numsyn = nregular;
 
     charmap = iregular;                        /* default character map */
     synonyms = sregular;
     numsyn = nregular;
-    while (*(*(++argv)) == '-') {      /* do options... */
-       switch (*(++(*argv))) {
+    while (--argc > 0 && *(*(++argv)) == '-') {        /* do options... */
+       switch ((*argv)[1]) {
 
          case 's': charmap = ispecial;         /* special font */
                    synonyms = sspecial;
                    numsyn = nspecial;
                    break;
 
 
          case 's': charmap = ispecial;         /* special font */
                    synonyms = sspecial;
                    numsyn = nspecial;
                    break;
 
-         case 'm': charmap = imath;            /* math font */
+         case 'o': charmap = imath;            /* math font */
                    synonyms = smath;
                    numsyn = nmath;
                    break;
                    synonyms = smath;
                    numsyn = nmath;
                    break;
@@ -233,81 +242,92 @@ char **argv;
                    numsyn = nascii;
                    break;
 
                    numsyn = nascii;
                    break;
 
+         case 'c': constant = 1;               /* constant width font */
+                   break;
+
          case 'l': ligsf = 1;                  /* ascii font */
                    break;
 
          case 'l': ligsf = 1;                  /* ascii font */
                    break;
 
-         case 'n': fontname = ++*argv;         /* troff font name */
+         case 'n': fontname = operand(&argc, &argv);   /* troff font name */
                    break;
 
                    break;
 
-         case 'x': ptr = ++*argv;              /* replacements */
-                   while (delimit = tostring(ptr, ',')) {      /* get s1 */
-                       for (i = 0; i <= MAXLAST; i++)  /* search for match */
-                           if (strcmp (charmap[i], ptr) == 0)
-                               break;
-                       if (i > MAXLAST) error ("-x option: no match");
-                       charmap[i] = ptr = nextstring(ptr);     /* replace s1 */
-                       delimit = tostring(ptr, ';');   /* with string s2 */
-                       if (delimit) ptr = nextstring(ptr);
-                   }
+         case 'x': replacelist = operand(&argc, &argv);   /* replacements */
                    break;
 
                    break;
 
-         case 'y': ptr = ++*argv;              /* synonyms */
-                   while (delimit = tostring(ptr, ',')) {      /* get s1 */
-                       synonyms[2 * numsyn] = ptr;     /* set on end of list */
-                       ptr = nextstring(ptr);          /* get string s2 */
-                       delimit = tostring(ptr, ';');
-                       if (*ptr) {                     /* if something there */
-                           synonyms[2 * numsyn++ + 1] = ptr;  /* add to list */
-                       } else {                        /* otherwise remove */
-                           for (i = 0; i < numsyn; i++)        /* from list */
-                               if (strcmp (synonyms[2 * i], ptr) == 0)
-                                   *synonyms[2 * i] = '\0';
-                       }
-                       if (delimit) ptr = nextstring(ptr);
-                       if (numsyn > SYNON) error ("out of synonym space");
-                   }
+         case 'y': synonymlist = operand(&argc, &argv);        /* synonyms */
                    break;
 
                    break;
 
-         case 'd': fontdir = ++*argv;          /* directory */
+         case 'd': fontdir = operand(&argc, &argv);            /* directory */
                    break;
 
                    break;
 
-         case 'p': pointsize = atoi(++*argv);  /* point size */
-                   if (pointsize < MINSIZE || pointsize > MAXSIZE) {
-                       fprintf(stderr, "Illegal point size: %d\n", pointsize);
-                       exit(1);
-                   }
+         case 'p': pointsize = atoi(operand(&argc, &argv));    /* point size */
+                   if (pointsize < MINSIZE || pointsize > MAXSIZE)
+                       error("illegal point size: %d", pointsize);
                    break;
 
                    break;
 
-         case 'r': res = atoi(++*argv);        /* resolution */
-                   if (res < MINRES || res > MAXRES) {
-                       fprintf(stderr, "Illegal resolution: %d\n", res);
-                       exit(1);
-                   }
+         case 'r': res = atoi(operand(&argc, &argv));  /* resolution */
+                   if (res < MINRES || res > MAXRES)
+                       error("illegal resolution: %d", res);
                    break;
 
                    break;
 
-          default: fprintf(stderr, "Bad option: %c", **argv);
-                   exit(1);
+          default: error("bad option: %c", **argv);
        }
     }
 
        }
     }
 
-                                                       /* open font file */
-    for (i = 0; FID < 0 && (psize = psizelist[i]) > 0; i++) {
-       sprintf (IName, "%s/%s.r%d", fontdir, *argv, psize);
-       FID = open (IName, 0);
+    if (replacelist != NULL) {
+       ptr = replacelist;
+       while (delimit = tostring(ptr, ',')) {          /* get s1 */
+           for (i = 0; i <= MAXLAST; i++)              /* search for match */
+               if (strcmp (charmap[i], ptr) == 0)
+                   break;
+           if (i > MAXLAST) error("-x option: no match");
+           charmap[i] = ptr = nextstring(ptr);         /* replace s1 */
+           delimit = tostring(ptr, ':');               /* with string s2 */
+           if (delimit) ptr = nextstring(ptr);
+       }
     }
     }
-    if (FID < 0) { 
-       fprintf (stderr, "Can't find %s\n", *argv);
-       exit (8); 
+
+    if (synonymlist != NULL) {
+       ptr = synonymlist;
+       while (delimit = tostring(ptr, ',')) {  /* get s1 */
+           synonyms[2 * numsyn] = ptr;         /* set on end of list */
+           ptr = nextstring(ptr);              /* get string s2 */
+           delimit = tostring(ptr, ':');
+           if (*ptr) {                         /* if something there */
+               synonyms[2 * numsyn++ + 1] = ptr;       /* add to list */
+           } else {                            /* otherwise */
+               for (i = 0; i < numsyn; i++) {          /* remove from list */
+                   if (!strcmp(synonyms[2*i],synonyms[2*numsyn])) {
+                       numsyn--;
+                       for (j = i--; j < numsyn; j++) {
+                           synonyms[2 * j] = synonyms[2 * (j+1)];
+                           synonyms[2*j + 1] = synonyms[2*j + 3];
+                       }
+                   }
+               }
+           }
+           if (delimit) ptr = nextstring(ptr);
+           if (numsyn > SYNON) error("out of synonym space");
+       }
     }
 
     }
 
-    i = read(FID, &filemark[0], FMARK);
-    if (strncmp(filemark, "Rast", 4) || i != FMARK)
-           error("Bad File Mark in Font file.");
+    if (argc != 1)                                     /* open font file */
+       error("An RST font filename must be the last option");
+    for (i = 0; FID == NULL && (psize = psizelist[i]) > 0; i++) {
+       sprintf (IName, "%s/%s.r%d", fontdir, *argv, psize);
+       FID = fopen (IName, "r");
+    }
+    if (FID == NULL)
+       error("can't find %s", *argv);
+
+    for (i = 0; i < FMARK; filemark[i++] = getc(FID));
+    if (strncmp(filemark, "Rast", 4))
+           error("bad File Mark in Font file.");
 
     p.p_size = rd2();
     p.p_version = rd1();
     if (p.p_version)
 
     p.p_size = rd2();
     p.p_version = rd1();
     if (p.p_version)
-       error("Wrong version of Font file.");
+       error("wrong version of Font file.");
     p.p_glyph = rd3();
     p.p_first = rd2();
     p.p_last = rd2();
     p.p_glyph = rd3();
     p.p_first = rd2();
     p.p_last = rd2();
@@ -325,13 +345,13 @@ char **argv;
     p.p_id = rd4();
     p.p_res = rd2();
     if (p.p_res != res)
     p.p_id = rd4();
     p.p_res = rd2();
     if (p.p_res != res)
-           error("Wrong resolution in Font file.");
+           error("wrong resolution in Font file.");
 
     i = p.p_glyph - 44;
     idstrings = (unsigned char *) malloc (i);
     endstring = idstrings + i;
 
     i = p.p_glyph - 44;
     idstrings = (unsigned char *) malloc (i);
     endstring = idstrings + i;
-    if (read(FID, idstrings, i) != i)
-           error("Bad preamble in Font file.");
+    while (i--) if (getc(FID) == EOF)
+           error("bad preamble in Font file.");
 
     for (i = p.p_first; i <= p.p_last; i++) {
            g[i].g_height = rd2();
 
     for (i = p.p_first; i <= p.p_last; i++) {
            g[i].g_height = rd2();
@@ -357,9 +377,9 @@ char **argv;
     printf("spacewidth %d\n", i);
     printf ("# char    width   u/d     octal\ncharset\n");
                        /* the octal values for the following characters are */
     printf("spacewidth %d\n", i);
     printf ("# char    width   u/d     octal\ncharset\n");
                        /* the octal values for the following characters are */
-                       /* purposefully OUT of the range for characters (128) */
-    printf ("\\|       %4d      0      0200\n\\^       %4d      0      0200\n",
-                                                               i / 3, i / 6);
+                       /* purposefully OUT of the range of characters (128) */
+    printf ("\\|       %4d      0      0%o\n\\^        %4d      0      0%o\n",
+               (constant ? i : i/3), DIRSIZ, (constant ? 0 : i/6), DIRSIZ);
 
     for (j = p.p_first; j <= p.p_last; j++) {
        if (g[j].g_bitp != 0) {
 
     for (j = p.p_first; j <= p.p_last; j++) {
        if (g[j].g_bitp != 0) {
@@ -379,7 +399,7 @@ char **argv;
 
 *******************************************************************************/
 
 
 *******************************************************************************/
 
-    for (j=0; j<256; j++) {
+    for (j=0; j<DIRSIZ; j++) {
        if (g[j].g_bitp != 0) {
            type = (int) (((g[j].g_up * 100) / maxup) > PCNTUP) * 2 | (int)
                ((((g[j].g_height - (g[j].g_up+1)) * 100)/maxdown) > PCNTDOWN);
        if (g[j].g_bitp != 0) {
            type = (int) (((g[j].g_up * 100) / maxup) > PCNTUP) * 2 | (int)
                ((((g[j].g_height - (g[j].g_up+1)) * 100)/maxdown) > PCNTDOWN);
@@ -391,7 +411,29 @@ char **argv;
                        printf ("%s     \"\n", synonyms[2 * i + 1]);
            }
        }
                        printf ("%s     \"\n", synonyms[2 * i + 1]);
            }
        }
-    }
+    } /* for j */
+    exit(0);
+}
+
+
+/*----------------------------------------------------------------------------*
+ | Routine:    char  * operand (& argc,  & argv)
+ |
+ | Results:    returns address of the operand given with a command-line
+ |             option.  It uses either "-Xoperand" or "-X operand", whichever
+ |             is present.  The program is terminated if no option is present.
+ |
+ | Side Efct:  argc and argv are updated as necessary.
+ *----------------------------------------------------------------------------*/
+
+char *operand(argcp, argvp)
+int * argcp;
+char ***argvp;
+{
+       if ((**argvp)[2]) return(**argvp + 2); /* operand immediately follows */
+       if ((--*argcp) <= 0)                    /* no operand */
+           error("command-line option operand missing.");
+       return(*(++(*argvp)));                  /* operand operand */
 }
 
 
 }
 
 
@@ -432,19 +474,22 @@ register char *p;
 }
 
 
 }
 
 
-error(string)
+/*VARARGS1*/
+error(string, a1, a2, a3, a4)
 char *string;
 { 
 char *string;
 { 
-    printf("\nmakefont: %s\n",string);
+    fprintf(stderr, "makefont: ");
+    fprintf(stderr, string, a1, a2, a3, a4);
+    fprintf(stderr, "\n");
     exit(8);
 }
 
 rd1()
 {
     exit(8);
 }
 
 rd1()
 {
-    unsigned char i;
+    int i;
 
 
-    if(read (FID, &i, 1) != 1) error("File read error");
-    return (int) i;
+    if((i = getc(FID)) == EOF) error("file read error");
+    return i;
 }
 
 rd2()
 }
 
 rd2()