OSDN Git Service

updated codes.
authormaqiyuan <maqiyuan@users.sourceforge.jp>
Tue, 3 Jun 2014 13:49:52 +0000 (21:49 +0800)
committermaqiyuan <maqiyuan@users.sourceforge.jp>
Tue, 3 Jun 2014 13:49:52 +0000 (21:49 +0800)
src/dvisourc/dvianal.c
src/dvisourc/dviextra.c
src/dvisourc/dvipslog.c
src/dvisourc/dvipsone.c
src/dvisourc/dvipsone.h
src/dvisourc/dvispeci.c
src/dvisourc/dvitiff.c

index d6b6331..3ec7478 100644 (file)
@@ -51,10 +51,6 @@ char *escapecode = "btnvfr";  /* special codes for 8, 9, 10, 12, and 13 */
 
 /* we don't have to worry about sign extension here - no need for short int */
 
-/* static unsigned int ureadone (FILE *input) {
-  return getc(input);
-} */
-
 static unsigned int ureadtwo (FILE *input)
 {
   return (getc(input) << 8) | getc(input);
@@ -92,17 +88,6 @@ static int sreadone (FILE *input)
     return c;
 }
 
-#ifdef IGNORED
-static int sreadtwo (FILE *input)
-{
-  short int result;
-/*  return (getc(input) << 8) | getc(input); */ /* 1995/Nov/15 */
-/*  result = (getc(input) << 8) | getc(input); */
-  result = ((short int) getc(input) << 8) | (short int) getc(input);
-  return result;
-}
-#endif
-
 /* possible compiler optimization bug worked around 98/Feb/8 */
 
 static int sreadtwo (FILE *input)
@@ -210,9 +195,7 @@ void do_pop(FILE *output, FILE *input)
   }
 }
 
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-
-void complaincharcode(unsigned long c)    /* 1993/Dec/11 */
+void complaincharcode(unsigned long c)
 {
   sprintf(logline, " Character code %lu > 255\n", c);
   showline(logline, 1);
@@ -221,7 +204,7 @@ void complaincharcode(unsigned long c)    /* 1993/Dec/11 */
 /* come here either with character code 0 - 127 --- or from set1 */
 /* in the case of set1 we need to read the next byte, which likely is > 127 */
 
-void normalchar (FILE *output, FILE *input, int c)
+void normal_char (FILE *output, FILE *input, int c)
 {
   int d;
 
@@ -262,25 +245,29 @@ void normalchar (FILE *output, FILE *input, int c)
         else if (c == 9) c = 170;   /* 1996/June/4 */
         else if (c == 0) c = 161;
       }
-/*      if (c < 32 || c >= 127) { */    /* control characters */
-/* added test for percent 1992/Dec/21 to avoid % in string ... */
-      if (c < 32 || c >= 127 || c == 37)  { /* control chars and % */
-/*        if (bForwardFlag != 0 && c <= 13 && c >= 8 && c != 11)  */
-        if (c <= 13 && c >= 8 && c != 11 && bForwardFlag != 0) {
+
+      if (c < 32 || c >= 127 || c == 37)
+      {
+        if (c <= 13 && c >= 8 && c != 11 && bForwardFlag != 0)
+        {
 /* use special escape \b \t \n ... \f \r for 8 ... 13 1993/Sep/29 */
           PSputc('\\', output);
-          PSputc(escapecode[c-8], output);
+          PSputc(escapecode[c - 8], output);
         }
-/*        if (backwardflag == 1)  */ /* backward compatible with old ALW */
-        else if (bBackWardFlag == 1) { /* compatibility with old ALW */
+        else if (bBackWardFlag == 1) /* compatibility with old ALW */
+        {
           d = getc(input); (void) ungetc(d, input); /* peek  */
-          if ((d >= 32 && d <= 127) || d == (int) set1) {
+
+          if ((d >= 32 && d <= 127) || d == (int) set1)
+          {
 //            fprintf(output, "\\%03o", c);  /* just to be safe */
             sprintf(logline, "\\%03o", c);  /* just to be safe */
           }
-          else {
+          else
+          {
             sprintf(logline, "\\%o", c);
           }
+          
           PSputs(logline, output);
         }
         else {    /* following not always safe for old ALW ... */
@@ -295,38 +282,42 @@ void normalchar (FILE *output, FILE *input, int c)
           PSputs(logline, output);
         }
       }
-      else {              /* not control characters */
+      else /* not control characters */
+      {
         if (c == '\\' || c == '(' || c == ')')
         {
-//          putc('\\', output);
           PSputc('\\', output);
         }
-/*        if (c == '%') fprintf(output, "\045"); */
-/*        else putc(c, output); */
-//        putc(c, output);
+
         PSputc(c, output);
       }
     }
+
     c = getc(input);    /* get the next byte in DVI file */
-    if (c < 0) break;   /* trap EOF - avoid loop */
+
+    if (c < 0)
+      break;   /* trap EOF - avoid loop */
   } /* end of while (c < 128 ... ) loop */
 
 /* analyze next DVI command to see whether can combine with above */
-  if (skipflag != 0) (void) ungetc(c, input);
-  else {
-    if (c == (int) w0) {
-//      fputs(")S", output);
+  if (skipflag != 0)
+    (void) ungetc(c, input);
+  else
+  {
+    if (c == (int) w0)
+    {
       PSputs(")S", output);
     }
-    else if (c == (int) x0) {
-//      fputs(")T", output);
+    else if (c == (int) x0)
+    {
       PSputs(")T", output);
     }
-    else {
-//      fputs(")s", output);
+    else
+    {
       PSputs(")s", output);
       (void) ungetc(c, input);  /* can't use it, put it back */
     }
+
     showcount++;
   }
 /*  also need to increase h by total width */
@@ -338,7 +329,7 @@ void normalchar (FILE *output, FILE *input, int c)
 /* Following need *not* be efficient since it is rarely used */
 /* Put single character - called by put1/put2/put3/put4 */
 /* Set single character - also called by set2/set3/set4 */
-/* duplicates a lot of code form normalchar() above */
+/* duplicates a lot of code form normal_char() above */
 
 /* separated out 1995/June/30 */  /* third arg is `s' or `p' */
 
@@ -346,16 +337,18 @@ void do_charsub (FILE *output, unsigned long c, char code)
 {
   if (skipflag == 0)
   {
-/*    if (bRemapControl && c < MAXREMAP) c = remaptable[c]; */
     if (bRemapControl || bRemapFont)
     {
-      if (c < MAXREMAP) c = remaptable[c];
+      if (c < MAXREMAP)
+        c = remaptable[c];
+
 #if MAXREMAP < 128
       else if (c == 32) c = 195;
       else if (c == 127) c = 196;
 #endif
     }
-    else if (bRemapSpace && c <= 32) {        /* 1995/Oct/17 */
+    else if (bRemapSpace && c <= 32)
+    {
       if (c == 32) c = 195;   /* not 160 */
       else if (c == 13) c = 176;  /* 1996/June/4 */
       else if (c == 10) c = 173;  /* 1996/June/4 */
@@ -366,16 +359,9 @@ void do_charsub (FILE *output, unsigned long c, char code)
       complaincharcode(c);
       return;       /* ignore it - should never happen */
     }
-/*    if (f < 0) {
-      showline("Setting char %d without font", c);
-      tellwhere(1);   errcount(0);
-    } */
-//    putc('(', output); 
+
     PSputc('(', output); 
-/*    the following code copied from normachar() --- 1995/June/30 */
-/*    if (bRemapControl && c < MAXREMAP)
-      c = remaptable[c];  */        /* 1994/Jun/20 */
-/*    if (c < 32 || c >= 127) */
+
     if (c < 32 || c >= 127 || c == 37) {  /* 1995/June/30 fix */
 /*      fprintf(output, "(\\%o)p", c); */   /* put1 */
       if (c <= 13 && c >= 8 && c != 11 && bForwardFlag != 0) {
@@ -396,8 +382,8 @@ void do_charsub (FILE *output, unsigned long c, char code)
     }
 /*    else fprintf(output, "(%c)p", c); */  /* 1995/June/30 fixed */
     else {
-        if (c == '\\' || c == '(' || c == ')') {
-//          putc('\\', output);
+        if (c == '\\' || c == '(' || c == ')')
+        {
           PSputc('\\', output);
         }
 /*        if (c == '%') fprintf(output, "\045"); */
@@ -405,9 +391,8 @@ void do_charsub (FILE *output, unsigned long c, char code)
 //        putc((unsigned int) c, output);
         PSputc((unsigned int) c, output);
     }
-//    putc(')', output); 
+
     PSputc(')', output); 
-//    putc(code, output);     /* 'p' or 's' */
     PSputc(code, output);     /* 'p' or 's' */
     showcount++;
   }
@@ -416,13 +401,13 @@ void do_charsub (FILE *output, unsigned long c, char code)
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 
 /* could be more efficient here if we ever see several in a row OK */
-/* model on "normalchar" if needed OK */
+/* model on "normal_char" if needed OK */
     
 void do_set1(FILE *output, FILE *input)
 {
   if (skipflag == 0)
   {
-    normalchar(output, input, (int) set1);
+    normal_char(output, input, (int) set1);
   }
   else
     (void) getc(input);
@@ -2035,7 +2020,7 @@ int scandvifile (FILE *output, FILE *input, int lastflag)
 
     if (c < 128)
     {
-      normalchar(output, input, c);
+      normal_char(output, input, c);
     }
     else if (c >= 171 && c <= 234)
     {
@@ -2385,7 +2370,7 @@ int scandvifile (FILE *output, FILE *input, int lastflag)
 
 /* access w, x, y, z off stack (i.e. keep in stack not register) ? */
 
-/* consider sequences of set1 commands - treat like normalchar ? */
+/* consider sequences of set1 commands - treat like normal_char ? */
 
 /* check on fonthit even when font switch on page that is not printed ? */
 
index 7e7b7e8..090fab2 100644 (file)
@@ -3314,12 +3314,7 @@ int extracttype1 (FILE *output, FILE *input, int fn, char *fontnamek)
 //    fputs(line, output);    /* 1992/Aug/22 */
     PSputs(line, output);     /* 1992/Aug/22 */
   }
-#ifdef IGNORED
-  else if ((property & C_MULTIPLE) != 0) {  /* don't mess with MM base */
-//    fputs(line, output);    /* 1997/June/1 */
-    PSputs(line, output);     /* 1997/June/1 */
-  }
-#endif    /* test 97/Nov/30 */
+
 /*  else if (bMMNewFlag == 0 && mmflag != 0) fputs(line, output); */
   else if ((property & C_REMAPIT) == 0) {   /* if font is not remapped */
     if (strstr(line, "StandardEncoding") != NULL) { /* easy case! */
@@ -3720,20 +3715,13 @@ charagain:              /* 1993 Aug 5 - hybrid font loop */
     putenline(output, line);
     n = getenline(input, line);
   }
+
   putenline(output, line);
   flushencrypt(output);           // ???
 
 /*  A problem here if the font has junk at the end of binary section ... */
 /*  Will this `fix' screw up treatment of Mac fonts ? */
 
-#ifdef IGNORED
-  if (stripbadend) {
-    c = getc(input);        /* eat spurious zeros if needed */
-    while (c == 0) c = getc(input); /* 95/Mar/1 */
-    (void) ungetc(c, input);    /* turn these into ASCII zeros ? */
-  }
-#endif
-
 /*  96/Feb/22 deal with junk at end of encrypted section */
 /*  Looking for M-@C-A (ASCII section heading) for PFB */
 /*  Looking for EOL for PFA */
@@ -5176,19 +5164,6 @@ int AddMMBase (int m)
 /* Do we get into any problems because of not checking for substitution ? */
 /* Not used anymore ? */
 
-#ifdef IGNORED
-void AddInBaseFonts(void)
-{
-  int k;
-/*  for (k = 0; k < mmbase; k++) { */
-  for (k = 0; k < fnext; k++)
-  {
-/*    if (fontproper[k] & C_MULTIPLE) continue; */
-    if (fontproper[k] & C_INSTANCE) AddMMBase(k);
-  }
-}
-#endif
-
 /* Old style PSS stubs look like this: */
 
 /* 128, 1, x, x, x, x (length)
@@ -6063,10 +6038,7 @@ void dofont (FILE *fp_out, int f, int fn)
       if (property & C_INSTANCE) {
 /*        strcpy(fname, subfontname + f * MAXFONTNAME); */
         *fname = '\0';
-#ifdef IGNORED
-        if ((property & C_REMAPIT) || bWindowsFlag) /* 97/June/1 */
-          strcpy(fname, COORDINATE);  /* make up `coordinated' name */
-#endif      /* test 97/Nov/30 */
+
 //        strcat(fname, subfontname + f * MAXFONTNAME);
         if (subfontname[f] != NULL) strcat(fname, subfontname[f]);
 #ifdef DEBUG
@@ -6763,10 +6735,7 @@ void fontsetup (FILE *fp_out)
 /*        strcpy(fname, fontname + k * MAXTEXNAME); */  /* 1994/Feb/2 */
         if (property & C_MULTIPLE) {      /* 97/June/1 */
           *fname = '\0';
-#ifdef IGNORED
-          if ((property & C_REMAPIT) || bWindowsFlag) /* 97/June/1 */
-            strcpy(fname, COORDINATE);  /* coordinated name */
-#endif    /* test 97/Nov/30 */
+
 //          strcat(fname, subfontname + k * MAXFONTNAME);
           if (subfontname[k] != NULL) strcat(fname, subfontname[k]);
         }
index 625bd80..c1507ff 100644 (file)
@@ -108,18 +108,6 @@ static unsigned long ureadfour (FILE *infile)
   else return c;
 } */
 
-#ifdef IGNORED
-/* static short int sreadtwo (FILE *infile) { */  /* ??? */
-static int sreadtwo (FILE *infile)
-{
-  short int result;
-/*  return (getc(infile) << 8) | getc(infile); */ /* 1995/Nov/15 */
-/*  result = (getc(infile) << 8) | getc(infile); */
-  result = ((short int) getc(infile) << 8) | (short int) getc(infile);
-  return result;
-} /* needed now for code imported from dviextra.c readtfm etc */
-#endif
-
 /* avoid possible compiler optimization error */
 
 static int sreadtwo (FILE *input)    /* experiment 98/Feb/7 */
@@ -343,36 +331,6 @@ void logdo_set2(FILE *infile)
   logdo_setsub(ureadtwo(infile));
 }
 
-#ifdef IGNORED
-void logdo_set2(FILE *infile)
-{
-  unsigned int c;
-  c = ureadtwo(infile);
-  if (skipflag == 0) {
-/*    if (ff < 0) invalidset((int) c); */
-    if (ff == BLANKFONT) invalidset((int) c);
-    else if (c < 256) {
-/*      if (bRemapControl && c < MAXREMAP) c = remaptable[c]; */
-      if (bRemapControl || bRemapFont) {
-        if (c < MAXREMAP) c = remaptable[c];
-#if MAXREMAP < 128
-        else if (c == 32) c = 195;
-        else if (c == 127) c = 196;
-#endif
-      }
-      else if (bRemapSpace && c <= 32) {      /* 1995/Oct/17 */
-        if (c == 32) c = 195;   /* not 160 */
-        else if (c == 13) c = 176;  /* 1996/June/4 */
-        else if (c == 10) c = 173;  /* 1996/June/4 */
-        else if (c == 9) c = 170;   /* 1996/June/4 */
-        else if (c == 0) c = 161;
-      }
-      currentfont[c] = 1;
-    }
-  }
-}
-#endif
-
 void logdo_set3(FILE *infile)
 {
   logdo_setsub(ureadthree(infile));
@@ -1095,15 +1053,15 @@ void get_page_mode (FILE *infile)
   pagemode = get_common_string(infile);
 }
 
-/* example \special{papersize=5.04in,3.751in} */
+/* example \special{paper_size=5.04in,3.751in} */
 
 void get_paper_size (FILE *infile)
 {
-//  if (strcmp(papersize,"") != 0) return;  /* ignore all but first */
-  if (papersize != NULL) return;
-//  papersize = malloc ((size_t) (nspecial+1));
-//  get_common_string(infile, papersize);
-  papersize = get_common_string(infile);
+//  if (strcmp(paper_size,"") != 0) return;  /* ignore all but first */
+  if (paper_size != NULL) return;
+//  paper_size = malloc ((size_t) (nspecial+1));
+//  get_common_string(infile, paper_size);
+  paper_size = get_common_string(infile);
 }
 
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
@@ -1318,7 +1276,7 @@ void logdo_com (FILE *infile)
 /*    following added in 1995 July */
     else if (strcmp(line, "DSCheader") == 0) get_custom_name(infile);
     else if (strcmp(line, "DSCtext") == 0) get_custom_text(infile);
-    else if (strcmp(line, "papersize") == 0) get_paper_size(infile);
+    else if (strcmp(line, "paper_size") == 0) get_paper_size(infile);
     else if (strcmp(line, "DVIPSONE") == 0) get_command_spec(infile);
     else if (strcmp(line, "DVIWindo") == 0) flush_special(infile);
 /*    else complain ??? */
@@ -3464,135 +3422,6 @@ int SetupDirs (FILE *input, unsigned long startdirlist, unsigned long enddirlist
   return 0;
 }
 
-/* Look for given PS FontName in atmreg.atm and return file name of PFB */
-/* returns 0 if found, -1 if not found */
-
-#ifdef IGNORED
-int SearchATMReg (FILE *input, unsigned long endfontlist,
-          char *szPSFontName, char *szPFBFileName)
-{
-  int c, k;
-  unsigned int stroffset, nlen;
-  unsigned long next;
-  int boldflag, italicflag;   /* style bits */
-  int ttfflag;
-/*  following just used for statistics - could remove to save time */
-  int psflag, mmmflag, mmiflag, genflag;    /* font type bits */
-  int nMMM, nPFB, nPFM;       /* index into dir path table */
-  unsigned int flag[16];        /* 16 bytes of flags */
-  char FaceName[LF_FACENAME+1];   /* Windows Face Name - not used */
-  char StyleName[LF_FACENAME+1];    /* Style Name for TT font - not used */
-  char FullName[LF_FULLFACENAME+1]; /* Full Name - not used */
-  char FontName[LF_FULLFACENAME+1]; /* Font Name - used in comparison (T1 only) */
-  char MMMName[LF_FACENAME+1];    /* PFM file or TTF file or MMM file */
-  char PFBName[LF_FACENAME+1];    /* PFB file or PSS file - not used */
-  char PFMName[LF_FACENAME+1];    /* PFM file of MMM font - not used */
-//  char *s;
-
-  *szPFBFileName = '\0';
-  
-  fseek(input, startfontlist, SEEK_SET);
-
-/*   positioned at start of font list at this point */
-
-  for (;;) {
-    c = getc(input);        /* check for end of file 99/Mar/1 */
-    if (c == EOF) {
-      break;
-    }
-    ungetc(c, input);
-    stroffset = xreadtwo(input);  /* offset to first string == 44 */
-    nlen = xreadtwo(input);     /* length of this record in bytes */
-    next = xreadfour(input);    /* pointer to next record */
-    for (k = 0; k < (28 - 8); k++) (void) getc(input);
-    for (k = 0; k < 16; k++) flag[k] = getc(input);
-    boldflag = flag[1];
-    if (boldflag == 0 || boldflag > 2) {
-      if (boldflag > 2) boldflag = 1; /* pretend it is OK */
-/*      break; */  /* impossible */ /* `fixed' 97/Sep/14 */
-    }
-    else boldflag = boldflag - 1;
-    italicflag = flag[2];
-    if (italicflag > 1) {
-/*      break; */ /* impossible */  /* `fixed' 97/Sep/14 */
-    }
-    ttfflag = psflag = mmmflag = mmiflag = genflag = 0;
-/*    ttfflag = flag[5]; */
-    if (flag[4] == 0) ttfflag = 1;
-    else if (flag[4] == 1) psflag = 1;
-    else if (flag[4] == 2) mmmflag = 1;
-    else if (flag[4] == 4) mmiflag = 1;
-    if (flag[6] == 10) {
-      genflag = 1;
-      mmmflag = 0;
-    }
-    nMMM = flag[8] | (flag[9] << 8);  /* index into path name table */
-    nPFB = flag[10] | (flag[11] << 8);  /* index into path name table */
-    nPFM = flag[12] | (flag[13] << 8);  /* index into path name table */
-/*    mmflag = flag[12]; */
-
-//    if (ttfflag) ttfcount++;
-//    else if (genflag) gencount++;
-//    else if (mmiflag) mmicount++;
-//    else if (mmmflag) mmmcount++;
-//    else pscount++;
-
-/*    These used to all continue when they hit trouble */
-/*    Windows Face Name */
-      if (ReadString(input, FaceName, sizeof(FaceName)) < 0) goto donext;
-/*    Style Name (will be empty string for PS SM or MM font) */
-      if (ReadString(input, StyleName, sizeof(StyleName)) < 0) goto donext;
-/*    Full Name  (will be empty string for PS SM or MM font) */
-      if (ReadString(input, FullName, sizeof(FullName)) < 0) goto donext;
-/*    Font Name  (may be empty if font file not yet read by ATM) */
-      if (ReadString(input, FontName, sizeof(FontName)) < 0) goto donext;
-/*    Name of MMM file or PFM file or TTF file */ 
-      if (ReadString(input, MMMName, sizeof(MMMName)) < 0) goto donext;
-/*    Name of PFB file or PSS file */ 
-      if (ReadString(input, PFBName, sizeof(PFBName)) < 0) goto donext;
-/*    Name of PFM file in case of MMM font */ 
-      if (ReadString(input, PFMName, sizeof(PFMName)) < 0) goto donext;
-/*    Flush extension from file name --- MMMName is file name */
-//    if ((s = strchr(MMMName, '.')) != NULL) *s = '\0';
-/*    Remove underscores from file name */
-/*    removeunderscores(MMMName); */
-/*    if (testflag == 0) removeunderscores (MMMName); */  /* ??? */
-/*    Make all uppercase ? It's a file name so its safe at least */
-/*    makeuppercase (MMMName); */ /* ??? */
-#ifdef DEBUGATM
-    if (traceflag) {
-//      sprintf(logline, "%s %s %s%s %s (%d)\n", MMMName, FaceName,
-//          boldflag ? "BOLD" : "",
-//          italicflag ? "ITALIC" : "",
-//          ttfflag ? "(TT)" : "", pscount);
-//      showline(logline, 0);
-      sprintf(logline, "Face: `%s' Style: `%s' Full: `%s' Font: `%s' MMM: `%s' PFB: `%s' PFM: `%s'",
-          FaceName, StyleName, FullName, FontName, MMMName, PFBName, PFMName);
-      showline(logline, 0);
-    }
-#endif
-/*    if (strcmp(FontName, szPSFontName) == 0) */ /* ignore TrueType fonts */
-    if (ttfflag == 0 && strcmp(FontName, szPSFontName) == 0 &&
-        *PFBName != '\0') { // 2000 July 3
-      if (DirPaths[nPFB] != NULL) strcpy(szPFBFileName, DirPaths[nPFB]);
-      else *szPFBFileName = '\0';     // should not happen
-      strcat(szPFBFileName, PFBName);
-      if (traceflag) {
-        sprintf(logline, " FOUND: %s for %s\n", szPFBFileName, szPSFontName);
-        showline(logline, 0);
-      }
-      return 0;         /* success */
-    }
-donext:     /* 1999/Mar/1 */
-/*    if (findfontstart(input) < 0) break; */
-    if (next >= endfontlist) break;
-    if (fseek(input, next, SEEK_SET) < 0) break;
-  }
-  *szPFBFileName = '\0';    /* wipe clean again */
-  return -1;          /* failed to find */
-}
-#endif
-
 /* New version uses ATMFonts structure */ /* First argument is PS FontName */
 /* WRITES BACK INTO SECOND ARGUMENT */
 /* returns 0 if found, -1 if not found */
@@ -3828,41 +3657,6 @@ int LoadATMREG (void)
   return count;
 }
 
-
-/*  Look up specific font in ATMREG.ATM */
-/*  scan atmreg.atm in the windows directory for font info */
-/*  called with a single specific PS FontName */
-/*  returns -1 if it fails for one reason or another */
-/*  WRITES BACK INTO SECOND ARGUMENT */
-
-#ifdef IGNORED
-int LookupATMReg (char *szPSFontName, char *szPSFileName)
-{
-  FILE *input;
-  int n=0;
-
-  if (! useatmreg) return -1;     // tried before and failed
-  if (szATMRegAtm == NULL) {
-    if (SetupATMReg()) return -1; // failed to setup now
-  }
-  input = fopen(szATMRegAtm, "rb"); // open in binary mode for reading 
-  if (input == NULL) return -1;   // probably because not found
-  if (traceflag) {
-    sprintf(logline, "Scanning %s ", szATMRegAtm);
-    showline(logline, 0);
-  }
-  (void) ReadPointers(input);
-  if (AllocDirs(nDirs)) return -1;
-  SetupDirs(input, startdirlist, enddirlist);
-  (void) fseek (input, startfontlist, SEEK_SET);
-  n = SearchATMReg(input, endfontlist, szPSFontName, szPSFileName);
-//  showline(" LookupATMReg ATTEMPT TO FREE DIRPATHS\n", 0);  // debugging only
-//  FreeDirs();
-  fclose(input);
-  return n;
-}
-#endif
-
 /* First arg is PS FontName */ /* WRITES BACK INTO SECOND ARG */
 
 int LookupATMReg (char *szPSFontName, char *szPSFileName)
index 75a1404..2d8506e 100644 (file)
@@ -192,37 +192,38 @@ int remaptable[MAXREMAP];         /* 1994/June/20 */
 
 /* added A2 and B3 1994/Dec/10 */
 
-char *papertypes[] = 
-{
-  "letter", "note", "legal", "folio", "ledger", "tabloid", "executive",
-  "a2", "a3", "a4", "a5", "b3", "b4", "b5", "quarto", ""
-};
-
-/* in inches */
-double pagewidths[] = 
-{
-  8.5, 8.5, 8.5, 8.5, 11, 11, 7.25,
-  420/25.4, 297/25.4, 210/25.4, 148/25.4,
-  354/25.4, 250/25.4, 176/25.4, 215/25.4, 1
-};
+typedef struct {
+  char * type;
+  double width;
+  double height;
+} paper_size_t;
 
-/* in inches */
-double pageheights[] =
+static paper_size_t paper_struct [] =
 {
-  11, 11, 14, 13, 17, 17, 10.5,
-  594/25.4, 420/25.4, 297/25.4, 210/25.4,
-  500/25.4, 354/25.4, 250/25.4, 275/25.4, 1
+  {"letter",    8.5,      11},
+  {"note",      8.5,      11},
+  {"legal",     8.5,      14},
+  {"folio",     8.5,      13},
+  {"ledger",    11,       17},
+  {"tabloid",   11,       17},
+  {"executive", 7.25,     10.5},
+  {"a2",        420/25.4, 594/25.4},
+  {"a3",        297/25.4, 420/25.4},
+  {"a4",        210/25.4, 297/25.4},
+  {"a5",        148/25.4, 210/25.4},
+  {"b3",        354/25.4, 500/25.4},
+  {"b4",        250/25.4, 354/25.4},
+  {"b5",        176/25.4, 250/25.4},
+  {"quarto",    215/25.4, 275/25.4},
+  {"",          1,        1}
 };
 
 /* `statement' 5 1/2 x 8 1/2 */
 
-char *papertype=NULL;   /* "letter" or "" ? from command line */
-
-char *boundingtype=NULL;  /* "letter" or "" ? 94/May/6 */
-
-char *papersize=NULL;   /* Custom paper size specified via special */
-
-char *dscextra=NULL;    /* extra DSC comment to add in 94/May/6 */
+char *paper_type    = NULL; /* "letter" or "" ? from command line */
+char *bounding_type = NULL; /* "letter" or "" ? 94/May/6 */
+char *paper_size    = NULL; /* Custom paper size specified via special */
+char *dsc_extra     = NULL; /* extra DSC comment to add in 94/May/6 */
 
 /* compute later using command line page size argument */
 
@@ -231,7 +232,7 @@ double pagewidth;     /* page width in bp */
 
 int currentdirect=1;  /* non-zero => place output current directory */
 
-int magniflag=0;    /* next arg => user specified magnification */
+int magniflag =0;    /* next arg => user specified magnification */
 int rotateflag=0;   /* next arg => user specified rotation */
 int xoffsetflag=0;    /* next arg => user specified xoffset */
 int yoffsetflag=0;    /* next arg => user specified yoffset */
@@ -263,13 +264,6 @@ int halftoneflag = 0; /* next arg => halftone screen info */
 int wantcontrold=0;   /* non-zero => want control D added at end */
 int tryunderscore=1;  /* non-zero => try underscore form of font file name */
 
-/* int showlogflag=0; */  /* non-zero => show log of fonts and characters */
-/* int wantpreamble=1;  *//* non-zero => want preamble */
-/* int wanthistogram=0; */  /* non-zero => make histogram of commands */
-/* int deepstack=0; */    /* non-zero => want deeper stack */
-/* int wantpacking=1; */  /* try and pack PS code */
-/* int wantcpyrght=1; */  /* want copyright message in output file */
-
 int bAllowStandard=1; /* allow use of StandardEncoding - if it works */
 int bAllowTexText=1;  /* allow use of TeXtext encoding - if it works */
 int bAllowANSI=1;   /* allow use of ANSI encoding - if it works */
@@ -330,7 +324,7 @@ int pagetpic=0;     /* non-zero if TPIC special used on this page */
 
 char *fontprefix=NULL;  /* prefix to use on FontName */
 
-char szRandomPrefix[8]="ABCDEF+";  /* Random prefix for Acrobat */
+char szRandomPrefix[8]="ABCDEF+";  /* Random prefix for Adobe Reader */
             /* avoid partial font subfont cache problem */
             /* 6 characters followed by + and terminating null */
 
@@ -350,10 +344,8 @@ int beginorend=0;     /* +1 => last was begin -1 => last was end */
 
 int rangeindex=0;     /* index into following table */
 
-// long beginpages[MAXRANGES];  /* table of pagebegins - 48 bytes*/
-long *beginpages=NULL;    /* table of pagebegins */
-// long endpages[MAXRANGES];  /* table of pagebegins - 48 bytes*/
-long *endpages=NULL;    /* table of pageends - */
+long *beginpages = NULL;    /* table of pagebegins */
+long *endpages   = NULL;    /* table of pageends - */
 
 // int pagerangeseq[MAXRANGES];   /* which instance of page range desired ? */
 int *pagerangeseq=NULL;   /* which instance of page range desired ? */
@@ -378,24 +370,23 @@ double yoffset=0.0;     /* y offset read off command line */
 
 #define UNKNOWNOFFSET -32767.0
 
-double xoffsete=UNKNOWNOFFSET;      /* x offset even pages */
-double yoffsete=UNKNOWNOFFSET;      /* y offset even pages*/
-
-double xoffseto=UNKNOWNOFFSET;      /* x offset odd pages */
-double yoffseto=UNKNOWNOFFSET;      /* y offset odd pages */
+double xoffsete = UNKNOWNOFFSET; /* x offset even pages */
+double yoffsete = UNKNOWNOFFSET; /* y offset even pages*/
+double xoffseto = UNKNOWNOFFSET; /* x offset odd pages */
+double yoffseto = UNKNOWNOFFSET; /* y offset odd pages */
 
 int evenoddoff = 0;     /* non-zero if offset differs even/odd pages */
 
 int nRepeatIndex=0;
 int nRepeatCount=1;     /* new way to make multiple copies 95/Aug/27 */
 
-long nMinRule=0;      /* min rule thickness (Acrobat fix) 95/Oct/10 */
+long nMinRule=0;      /* min rule thickness (Adobe Reader fix) 95/Oct/10 */
 
 int version=2;
 int revision=2;       /* now obtained from progversion string */
 int subrevision=4;
 
-char *progversion="2.2.4";      /* 2000/May/24 */
+char *progversion = "2.2.4";      /* 2000/May/24 */
 
 /* WARNING: remember to *also* change version number in DVIPREAM.PS !!! */
 /* look for line: /checkversion{1 2 3 hashversion 4 1 roll hashversion ne */
@@ -414,10 +405,6 @@ char *copyright = "\nCopyright (C) 1990--2000, Y&Y, Inc.\n"
                   //"(at your option) any later version.\n\n";
 
 
-/* char *company="Y&&Y, Inc. USA"; */ /* double percent for Acrobat Info */
-
-/* char *company="Y&Y, Inc. USA"; */  /* 97/Jan/30 */
-
 char *company = "Y&Y, Inc.";  /* 97/Apr/29 */
 char *URL     = ""; /* string in binary ... */
 
@@ -496,26 +483,14 @@ int commandspeclen=0;   /* how much has been accumulated in the following */
 char *commandspec=NULL;   /* command line stuff from DVI file */
 
 int keywordslen=0;      /* how much has been accumulated in following */
-char *keywords=NULL;    /* accumulated keywords from PDF: Keywords ... */
-              /* need to free at end of file */
-
-char *creatorstring=NULL; /* Creator for DocInfo in Acrobat */
-              /* need to free at end of file */
-
-char *titlestring=NULL;   /* Title for DocInfo in Acrobat */
-              /* need to free at end of file */
-
-char *subjectstring=NULL; /* Subject for DocInfo in Acrobat */
-              /* need to free at end of file */
-
-char *authorstring=NULL;  /* Author for DocInfo in Acrobat */
-                /* need to free at end of file */
+char *keywords      = NULL; /* accumulated keywords from PDF: Keywords ... */
+char *creatorstring = NULL; /* Creator for DocInfo in Adobe Reader */
+char *titlestring   = NULL; /* Title for DocInfo in Adobe Reader */
+char *subjectstring = NULL; /* Subject for DocInfo in Adobe Reader */
+char *authorstring  = NULL; /* Author for DocInfo in Adobe Reader */
+char *basestring    = NULL; /* Base for DocView in Adobe Reader */
+char *pagemode      = NULL; /* Base for DocView in Adobe Reader */
 
-char *basestring=NULL;  /* Base for DocView in Acrobat */
-                /* need to free at end of file */
-
-char *pagemode=NULL;    /* Base for DocView in Acrobat */
-                /* need to free at end of file */
 
 char line[MAXLINE];       /* general purpose input `buffer' 512 bytes */
 
@@ -532,25 +507,6 @@ char *comment=NULL;     /* space for comment - 1995/July/15 - 256 => 27 */
 
 /* Code to show VM usage and page rendering time: */ /* flushed 1996/May/6 */
 
-#ifdef IGNORED
-static char showpagecode[] = "\
-dvidict begin\n\
-/showpageinfo{save % ctm setmatrix\n\
-/Helvetica findfont 10 scalefont setfont\n\
-72 PageHeight 36 sub moveto\n\
-(Total VM in use:  ) show exch =string cvs show ( bytes) show\n\
-currentpoint exch pop PageWidth 3 div 36 add exch moveto\n\
-(Page VM usage:  ) show exch =string cvs show ( bytes) show\n\
-currentpoint exch pop PageWidth 3 div 2 mul exch moveto\n\
-(Rendering time:  ) show exch 10 div cvi 100 div =string cvs show\n\
-( seconds) show restore}bd\n\
-/bphook{vmstatus pop exch pop usertime}bd\n\
-/ephook{usertime exch sub exch dup vmstatus pop exch pop exch sub exch\n\
-showpageinfo}bd\n\
-end\n\
-";
-#endif
-
 /* % add processing to beginning and end of page:\n\ */
 
 /* char *duplexcode = "\
@@ -585,30 +541,13 @@ int fnext=0;      /* next slot to use normal fonts */
 
 // int finx[MAXFONTNUMBERS];    /* index into next now default */
 short finx[MAXFONTNUMBERS];     /* index into next */
-
-/* char fontname[MAXFONTS][MAXTEXNAME]; */    /* names of fonts called for */
-// char *fontname;          /* 1994/Feb/2 */
 char *fontname[MAXFONTS];     /* 1999/Nov.6 */
-
-/* char subfontname[MAXFONTS][MAXFONTNAME]; */  /* substituted font name */
-// char *subfontname;       /* 1994/Feb/2 */
 char *subfontname[MAXFONTS];    /* 1999/Nov/6 */
-
-// char fontvector[MAXFONTS][MAXVECNAME]; /* font remapping vector if any */
-// char *fontvector;        /* font remapping vector if any */
 char *fontvector[MAXFONTS];     /* font remapping vector if any */
-
-// char *fontchar;          /* which characters seen */
 char *fontchar[MAXFONTS];     /* which characters seen */
-
 int fontsubflag[MAXFONTS];  /* non-negative if substitute font to be used */
-              /* number indicates base font - 256 bytes */
-
 int fontproper[MAXFONTS]; /* code if font is resident/forced/remapped */
-
 unsigned long fc[MAXFONTS]; /* checksum of TFM file (use for encoding info) */
-              /* reenabled 95/Jan/10 - 512 bytes */
-
 unsigned long fs[MAXFONTS];   /* at size - 512 bytes */ 
 
 /* unsigned long fd[MAXFONTS]; */ /* design size */ /* NOT ACCESSED ? */
@@ -651,9 +590,9 @@ char *dviwindo = NULL;    /* full file name for dviwindo.ini, with path */
 char *logfilename = "dvipsone.log";
 #endif
 
-FILE *logfile = NULL;  /* 1999/Apr/20 */
-FILE *input   = NULL;  /* used by following */
-FILE *output  = NULL;  /* used by `interrupt handler' */
+FILE * logfile = NULL;  /* 1999/Apr/20 */
+FILE * input   = NULL;  /* used by following */
+FILE * output  = NULL;  /* used by `interrupt handler' */
 
 char fn_in[FNAMELEN], fn_out[FNAMELEN];   /* 1994/Mar/1 */
 
@@ -723,6 +662,7 @@ void checkenter (int argc, char *argv[]) /* 95/Oct/28 */
 void checkexit (int n) /* 95/Oct/28 */
 {
   checkpause(1);
+
 #ifdef USELOGFILE
   if (logfile != NULL)
   {
@@ -730,13 +670,7 @@ void checkexit (int n) /* 95/Oct/28 */
     logfile = NULL;
   }
 #endif
-#ifdef _WINDOWS
-//  sprintf(logline, "CHECKEXIT %d\n", n);
-//  showline(logline, 1);   // debugging only
-//  abortflag++;
-#else
-//  exit(n);
-#endif
+
   uexit(n);
 }
 
@@ -753,10 +687,7 @@ char *zstrdup (char *s)    /* new central location 1996/Aug/28 */
 
   sprintf(logline, " ERROR: Unable to allocate memory for %s\n", s);
   showline(logline, 1);
-#ifdef _WINDOWS
-//  abortflag++;
-//  return NULL;
-#endif
+
 #ifndef _WINDOWS
   showline("Press any key to continue . . .\n", 0);
   pause();
@@ -924,23 +855,6 @@ int setupatmini (void)
 
 /* WARNING: this will return NULL if not found anywhere - just like getenv */
 
-#ifdef _WINDOWS
-char *grabenvvar (char *varname, char *inifile, char *section, int useini)
-{
-  (void) GetPrivateProfileString(section, varname, "", line, sizeof(line), inifile);
-
-  if (traceflag)
-  {
-    sprintf(logline, "%s=%s\n", varname, line);
-    showline(logline, 0);
-  }
-
-  if (*line != '\0')
-    return zstrdup(line);
-  else
-    return getenv(varname);
-}
-#else
 char *grabenvvar (char *varname, char *inifile, char *section, int useini)
 {
   FILE *input;
@@ -1010,29 +924,9 @@ char *grabenvvar (char *varname, char *inifile, char *section, int useini)
   return getenv(varname); /* failed, so try and get from environment */
               /* no tusing strdup when non-NULL ? */
 }             /* this will return NULL if not found anywhere */
-#endif
-
-/* WARNING: this will return NULL if not found anywhere - just like getenv */
-
-#ifdef _WINDOWS
-/* get from [Environment] in dviwindo.ini */
-char *grabenv (char *varname)
-{
-  (void) GetPrivateProfileString("Environment", varname, "", line, sizeof(line), "dviwindo.ini");
 
-  if (traceflag)
-  {
-    sprintf(logline, "%s=%s\n", varname, line);
-    showline(logline, 0);
-  }
 
-  if (*line != '\0')
-    return zstrdup(line);
-  else
-    return getenv(varname);
-}
-#else
-/* get from [Environment] in dviwindo.ini */
+/* WARNING: this will return NULL if not found anywhere - just like getenv */
 char *grabenv (char *varname)
 {
   if (usedviwindo && ! dviwindoinisetup)
@@ -1040,7 +934,6 @@ char *grabenv (char *varname)
 
   return grabenvvar (varname, dviwindo, "[Environment]", usedviwindo);
 }
-#endif
 
 /***************************************************************************/
 
@@ -1263,7 +1156,7 @@ void showusage (char *program)
   s += strlen(s);
   showline(s, 0);
   sprintf(s, "    l:    paper size type (default `%s')\n",
-      (papertype != NULL) ? papertype : "");
+      (paper_type != NULL) ? paper_type : "");
   s += strlen(s);
   sprintf(s, "    d:    destination ");
   s += strlen(s);
@@ -1682,7 +1575,6 @@ void waitasec (int delay)
 
 void cleanup (void)
 {
-/*  nothing much to do unless output file open */
   if (output != NULL)
   {
     if (directprint)
@@ -1691,40 +1583,32 @@ void cleanup (void)
       fflush(stdout);           /* ??? 98/Jun/30 */
 #endif
 
-/*      if (wantcontrold != 0) { */ /* changed 1993/Mar/5 */
       if (wantcontrold != 0 || stripcomment != 0)
       {
-/*        putc(3, output);    */  /* send control-C */
-//        putc(4, output);      /* send control-D */
         PSputc(4, output);      /* send control-D */
       }
-#ifdef _WINDOWS
-      PSputs("", output);     // flush PS buffer in DLL version
-#else
-      fflush(output);           /* ??? 98/Jun/30 */
-#endif
-      fclose(output);       /* close output */
-      waitasec(1000);       /* give it time to clear out ? */
+
+      fflush(output); /* ??? 98/Jun/30 */
+      fclose(output); /* close output */
+      waitasec(1000); /* give it time to clear out ? */
     }
     else
     {
-      if (wantcontrold) {   /* added 1993/Mar/5 */
-/*        putc(3, output);    */  /* send control-C */
-//        putc(4, output);      /* send control-D */
+      if (wantcontrold)
+      {
         PSputc(4, output);      /* send control-D */
       }
+
       fclose(output);       /* close output */
       (void) remove(fn_out);    /* and remove bad file */
     }
   }
-/*  fcloseall();  */
 }
 
 void abortjob (void)
 {
   cleanup();
   checkexit(3);
-//  return -1;
 }
 
 /* called each time `survivable' error encountered */
@@ -1744,7 +1628,6 @@ void errcount (int flag)
 }
 
 /***********************************************************************/
-
 /* flag = 0 => DocumentFonts */ /* => no longer used */
 /* flag = 1 => DocumentSuppliedFonts */  /* => DocumentSuppliedResources */
 /* this should also write out fonts that have not been found when flag = 0 */
@@ -1755,7 +1638,7 @@ void errcount (int flag)
 int writefontlist (FILE *outfile, int flag, int column)
 {
   int k, want;
-  int wanted=0, missing=0, resident=0, dependent=0, unused=0, instance=0;
+  int wanted = 0, missing = 0, resident = 0, dependent = 0, unused = 0, instance = 0;
 
 //  char ftemp[MAXTEXNAME];
   char ftemp[FNAMELEN];
@@ -1938,17 +1821,17 @@ void writemissing (FILE *outfile, int column)
 
 /* a4tray, b5tray, legaltray, lettertray  - or setpageparams ? */
 
-/* \special{papersize=5.04in,3.75in} */
+/* \special{paper_size=5.04in,3.75in} */
 
-int decodepapersize (char *papersize, double *pagewidth, double *pageheight)
+int decode_paper_size (char *paper_size, double *pagewidth, double *pageheight)
 {
   double multiple;
   double width, height;
   char units[3];
-  char *s=papersize;
+  char *s=paper_size;
   int n;
 
-  if (papersize == NULL || *papersize == '\0')
+  if (paper_size == NULL || *paper_size == '\0')
     return -1;
 
   if(sscanf(s, "%lg%n", &width, &n) > 0)
@@ -1962,7 +1845,7 @@ int decodepapersize (char *papersize, double *pagewidth, double *pageheight)
   }
   else
   {
-    sprintf(logline, "Don't understand papersize %s\n", papersize);
+    sprintf(logline, "Don't understand paper_size %s\n", paper_size);
     showline(logline, 1);
     return -1;
   }
@@ -1984,7 +1867,7 @@ int decodepapersize (char *papersize, double *pagewidth, double *pageheight)
   }
   else
   {
-    sprintf(logline, "Don't understand papersize %s\n", papersize);
+    sprintf(logline, "Don't understand paper_size %s\n", paper_size);
     showline(logline, 1);
     return -1;
   }
@@ -2005,53 +1888,50 @@ int decodepapersize (char *papersize, double *pagewidth, double *pageheight)
 /* PS letter, note, legal, ledger ? */
 /* use table for neatness */
 
-int analpapertype (char *papertype, double *pagewidth, double *pageheight)
+int analpapertype (char *paper_type, double *pagewidth, double *pageheight)
 {
   int k;
 
-  if (papertype == NULL)
+  if (paper_type == NULL)
     return 0;
 
-  for (k= 0; k < 32; k++)        /* 94/May/6 */
+  for (k= 0; k < 32; k++)
   {
-    if (strcmp(papertypes[k], "") == 0)
+    if (strcmp(paper_struct[k].type, "") == 0)
       break;
 
-    if (strcmp(papertypes[k], papertype) == 0)
+    if (strcmp(paper_struct[k].type, paper_type) == 0)
     {
-      *pagewidth = pagewidths[k] * 72;
-      *pageheight = pageheights[k] * 72;
+      *pagewidth = paper_struct[k].width * 72;
+      *pageheight = paper_struct[k].height * 72;
       return 0;
     }
   }
-/*  stupid compiler doesn't like it if we do following in same loop! */
-/* dvipsone.c(1132) : warning C4713: analpapertype: INTERNAL COMPILER ERROR; restarting
-    (compiler file '@(#)reg86.c:1.26', line 3667)
-    Contact Microsoft Product Support Services */
-  for (k= 0; k < 32; k++) /* 94/May/6 */
+
+  for (k= 0; k < 32; k++)
   {
-    if (strcmp(papertypes[k], "") == 0)
+    if (strcmp(paper_struct[k].type, "") == 0)
       break;
 /*  Try landscape versions ... (In which first letter upper case) 94/July/1 */
-    if (_strcmpi(papertypes[k], papertype) == 0)
+    if (_strcmpi(paper_struct[k].type, paper_type) == 0)
     {
-      *pageheight = pagewidths[k] * 72;
-      *pagewidth = pageheights[k] * 72;
+      *pageheight = paper_struct[k].width * 72;
+      *pagewidth = paper_struct[k].height * 72;
       return 0;
     }
   }
 /*  new option to deal with large and peculiar sizes 1994/Dec/16 */
 /*  -l=<width>*<height> where width and height are in PostScript points */
-/*  if (sscanf(papertype, "%lg*%lg", &pagewidth, &pageheight) == 2) { *//*NO*/
-  if (sscanf(papertype, "%lg*%lg", pagewidth, pageheight) == 2)
+/*  if (sscanf(paper_type, "%lg*%lg", &pagewidth, &pageheight) == 2) { *//*NO*/
+  if (sscanf(paper_type, "%lg*%lg", pagewidth, pageheight) == 2)
   {
     return 0;
   }
 
 //  insert code to interpret 4in*5in e.g. ???
-  if (decodepapersize(papertype, pagewidth, pageheight) == 0)
+  if (decode_paper_size(paper_type, pagewidth, pageheight) == 0)
     return 0;
-  sprintf(logline, "Don't understand papertype: %s\n", papertype);
+  sprintf(logline, "Don't understand paper_type: %s\n", paper_type);
   showline(logline, 1);
   errcount(0);
 
@@ -2083,7 +1963,6 @@ void scivilize (char *date)
 }
 
 /* Thu Sep 27 06:26:35 1990 => 1990 Sep 27 06:26:35 */
-
 void lcivilize (char *date)
 {
   int k;
@@ -2119,12 +1998,8 @@ char *stampit (char *line, int dateflag)
   strcpy(date, compiledate);
   scivilize(date);
 
-//  following revised for Acrobat 4.0 so Creator shows URL
-#ifdef _WINDOWS
+//  following revised for Adobe Reader 4.0 so Creator shows URL
   strcpy(s, "DVIPSONE ");
-#else
-  strcpy(s, "DVIPSONE ");
-#endif
 
   s += strlen(s);
 
@@ -2197,8 +2072,6 @@ void copyDSCfile (FILE *output, char *name)
   fclose(input);
 }
 
-void showowner(char *, char *, int);
-
 void showownerout(char *);
 
 void addescapes (char *sline, char *filename, int nlen) // puts result in line
@@ -2220,7 +2093,6 @@ void addescapes (char *sline, char *filename, int nlen) // puts result in line
 }
 
 /* Write DSC header */
-
 void writestruct (FILE *outfile)
 {
   time_t ltime; /* for time and date */
@@ -2232,23 +2104,24 @@ void writestruct (FILE *outfile)
   int xll, yll, xur, yur;         /* 1995/Sep/16 */
   char *u;              /* 1995/July/15 */
 
-  PSputs("%!PS-Adobe-3.0\n", outfile);    /* 1992/July/18 */
+  PSputs("%!PS-Adobe-3.0\n", outfile);
 
   if (stripcomment != 0)
-    return;      /* 1993/March/5 */
+    return;
+
+  (void) time(&ltime);
 
-/*  get current date and time */
-  (void) time(&ltime);      /* get seconds since 1970 */
-  if (ltime < 0) /* "impossible" error */
+  if (ltime < 0)
   {
     sprintf(logline, "ERROR: Time not available (%0ld)!\n", ltime);
     showline(logline, 1);
   }
 
   s = ctime(&ltime);
-  if (s == NULL) /* "impossible" error */
+
+  if (s == NULL)
   {
-    sprintf(logline, "ERROR: Cannot convert time (%0ld)!\n", ltime);  /* 96/Jan/4 */
+    sprintf(logline, "ERROR: Cannot convert time (%0ld)!\n", ltime);
     showline(logline, 1);
     s = "Thu Jan 18 22:14:00 2038";
   }
@@ -2259,18 +2132,19 @@ void writestruct (FILE *outfile)
 
   if (filenamex != NULL)
   {
-    addescapes(line, filenamex, sizeof(line));  /* MAXLINE */
+    addescapes(line, filenamex, sizeof(line));
     PSputs(line, outfile);
   }
+
   PSputc('\n', outfile);
 
-  PSputs("%%Creator: ", outfile);       /* 1992/July/18 */
+  PSputs("%%Creator: ", outfile);
   stampit(line, 0);
   PSputs(line, outfile);
   PSputc('\n', outfile);
 
   PSputs("%%For: ", outfile);
-  showownerout(line);    /* MAXLINE */
+  showownerout(line);
   strcat(line, "\n");
   PSputs(line, output);
 
@@ -2282,7 +2156,8 @@ void writestruct (FILE *outfile)
   }
 
   PSputs("%%BoundingBox: ", outfile);
-  if (BBxll != 0 || BByll != 0 || BBxur != 0 || BByur != 0) /* 96/May/4 */
+
+  if (BBxll != 0 || BByll != 0 || BBxur != 0 || BByur != 0)
   {
     /* should really convert from TeX coordinates to PS coordinates */
     xll = BBxll; yll = BByll;
@@ -2290,7 +2165,7 @@ void writestruct (FILE *outfile)
   }
   else
   {
-    if (boundingtype == NULL)      /* 94/May/6 */
+    if (bounding_type == NULL)
     {
       xll = 72;
       yll = (int) ((double) pageheight - 72 - (unsigned long) (dvi_l / 65781));
@@ -2299,10 +2174,10 @@ void writestruct (FILE *outfile)
     }
     else
     {
-      boundheight = 11*72;  boundwidth = 8.5*72;    /* default */
+      boundheight = 11 * 72;  boundwidth = 8.5 * 72;    /* default */
 
-      if (boundingtype != NULL)
-        analpapertype(boundingtype, &boundwidth, &boundheight);
+      if (bounding_type != NULL)
+        analpapertype(bounding_type, &boundwidth, &boundheight);
 
       xll = 0;
       yll = 0;
@@ -2310,26 +2185,27 @@ void writestruct (FILE *outfile)
       yur = (int) boundheight;
     }
   }
-  sprintf(logline, "%d %d %d %d\n", xll, yll, xur, yur);  /* 95/Sep/16 */
+
+  sprintf(logline, "%d %d %d %d\n", xll, yll, xur, yur);
   PSputs(logline, output);
 
   pages = numpages;
+
   if (collated)
-    pages = pages * copies;       /* 94/Oct/12 */
+    pages = pages * copies;
 
   if (nRepeatCount > 1)
-    pages = pages * nRepeatCount; /* 95/Aug/27 */
+    pages = pages * nRepeatCount;
 
   PSputs("%%Pages: ", outfile);
   sprintf(logline, "%ld\n", pages); 
   PSputs(logline, output);
 
-/*  %%PageOrder is highly optional ... */
+  /*  %%PageOrder is highly optional ... */
   if (bOptionalDSC)
   {
     PSputs("%%PageOrder: ", outfile);
-    sprintf(logline, "%s\n",
-        reverseflag ? "Descend" : "Ascend");
+    sprintf(logline, "%s\n", reverseflag ? "Descend" : "Ascend");
     PSputs(logline, output);
   }
 
@@ -2337,15 +2213,13 @@ void writestruct (FILE *outfile)
   missing = writefontlist(outfile, 1, 29);
 
   PSputs("%%+ procset ", outfile);
-  sprintf(logline, "%s %d %d\n", 
-    procsetrest, version, revision);  /* no subrevision number */
+  sprintf(logline, "%s %d %d\n", procsetrest, version, revision);
   PSputs(logline, output);
 
   if (needtpic != 0)
   {
     PSputs("%%+ procset ", outfile);
-    sprintf(logline, "%s %d %d\n", 
-        tpicrest, version, revision); /* no subrevision number */
+    sprintf(logline, "%s %d %d\n", tpicrest, version, revision);
     PSputs(logline, output);
   }
 
@@ -2354,7 +2228,7 @@ void writestruct (FILE *outfile)
     prolog_comments (prologfile[k], outfile);
   }
 
-/*  should have version and revision? */
+  /*  should have version and revision? */
   if (headerfile != NULL)
     prolog_comments(headerfile, outfile);  /* 1993/Nov/15 */
 
@@ -2363,41 +2237,42 @@ void writestruct (FILE *outfile)
     PSputs("%%DocumentNeededResources: ", outfile);
     writemissing(outfile, 27);
   }
-/*  Extra DSC code supplied on command line using -*D=... */
-/*  If first character is not %, then convert all matching chars to space */
-/*  If --- after that --- first char is not %, insert %% before it */
-//  if (strcmp(dscextra, "") != 0) {    /* 1994/May/6 */
-  if (dscextra != NULL)
+
+  /*  Extra DSC code supplied on command line using -*D=... */
+  /*  If first character is not %, then convert all matching chars to space */
+  /*  If --- after that --- first char is not %, insert %% before it */
+  if (dsc_extra != NULL)
   {
-    c = *dscextra; /* look at first character */
+    c = *dsc_extra; /* look at first character */
 
     if (c != '%')
     {
-      s = dscextra;
+      s = dsc_extra;
 
       while (*(s+1) != '\0') {
         if (*(s+1) == c)
           *s = ' ';  /* replace magic with space */
         else
-          *s = *(s+1);     /* shift left one character */
+          *s = *(s+1); /* shift left one character */
 
         s++;
       }
 
       *s = '\0';            /* terminate */
-      c = *dscextra;
+      c = *dsc_extra;
     }
 
     if (c != '%')
     {
       PSputs("%%", output);
     }
-    PSputs(dscextra, output);
+
+    PSputs(dsc_extra, output);
     PSputc('\n', output);
   }
 
-/*  Extra DSC code supplied in \special{DSCtext=...} */
-/*  We are not checking whether lines start with %% and so on */
+  /*  Extra DSC code supplied in \special{DSCtext=...} */
+  /*  We are not checking whether lines start with %% and so on */
   if (dsccustom != NULL) /* 1995/July/15 */
   {
     u = dsccustom;
@@ -2417,22 +2292,18 @@ void writestruct (FILE *outfile)
 
   PSputs("%%Copyright: (C) 1990--2000, Y&Y, Inc.\n", output);
   PSputs("%%Copyright: (C) 2007, TeX Users Group.\n", output);
-  PSputs("%%Copyright: (C) 2014, Clerk Ma.", output);
-  PSputc('\n', output);
-
-
+  PSputs("%%Copyright: (C) 2014, Clerk Ma.\n", output);
   PSputs("%%EndComments", outfile);    /* may omit if next line ... */
   PSputc('\n', outfile);
 }
 
 /* Made common routines to save strig space */
-
-void dvidictbegin(FILE *outfile)   /* 1993/Dec/29 */
+void dvidictbegin(FILE *outfile)
 {
   PSputs("dvidict begin\n", outfile);
 }
 
-void dvidictend(FILE *outfile)    /* 1993/Dec/29 */
+void dvidictend(FILE *outfile)
 {
   PSputs("end", outfile);
 
@@ -2467,6 +2338,7 @@ void writeparams(FILE *outfile)
   {
     sprintf(logline, "/den %lu def ", den);
   }
+
   PSputs(logline, output);
 #else
   {
@@ -2484,18 +2356,18 @@ void writeparams(FILE *outfile)
       showline(logline, 0);
     }
   }
+
   sprintf(logline, "/mag %lu def\n", mag); /* TeX magnification * 1000 */
   PSputs(logline, output);
 
-/*  now for user specified transformations: */
+  /*  now for user specified transformations: */
   if (evenoddoff == 0)  /* only if the same on even and odd pages */
     sprintf(logline, "/xoffset %lg def /yoffset %lg def\n", xoffset, yoffset);
-  PSputs(logline, output);
 
+  PSputs(logline, output);
   sprintf(logline, "/xmagnif %lg def /ymagnif %lg def /rotation %lg def\n",
     xmagnification, ymagnification, rotation);
   PSputs(logline, output);
-
   sprintf(logline, "/PageHeight %lg def /PageWidth %lg def\n",
     pageheight, pagewidth);
   PSputs(logline, output);
@@ -2532,7 +2404,7 @@ void writeparams(FILE *outfile)
     PSputs(logline, output);
   }
 
-/*  Does user want to explicitly set screen frequency ? 94/March/18 */
+  /*  Does user want to explicitly set screen frequency ? 94/March/18 */
   if (frequency >= 0)
   {
     if (frequency > 0)  /* did user specified frequency & angle ? */
@@ -2555,6 +2427,7 @@ void writeparams(FILE *outfile)
     }
     PSputs(" dviscreen\n", output);
   }
+
   dvidictend (outfile);
 }
 
@@ -2562,7 +2435,7 @@ void writeparams(FILE *outfile)
 
 // returns -1 if it fails
 
-int copypreamble (FILE *output, FILE *input, char *procsetfile, int checkflag)
+int copy_preamble (FILE *output, FILE *input, char *procsetfile, int checkflag)
 {
   int c, d, column;
   int goodflag = 0;         /* 93/Mar/31 */
@@ -2724,10 +2597,12 @@ int copypreamble (FILE *output, FILE *input, char *procsetfile, int checkflag)
   return -1;
 }
 
-void expand_separators (char *line) // for filename in PS string
+void expand_separators (char *line)
 {
-  char *s=line;
-  while ((s = strchr(s, '\\')) != NULL) {
+  char *s = line;
+
+  while ((s = strchr(s, '\\')) != NULL)
+  {
     memmove(s+1, s, strlen(s)+1); // "\" => "\\"
     s += 2;
   }
@@ -2750,14 +2625,13 @@ int writepreamble (FILE *outfile, char *procsetfile, char *procsetrest, int chec
 
   if (stripcomment == 0)
   {
-    sprintf(logline, "procset %s %d %d\n", procsetrest, version, revision);  /* no subrevision number */
+    sprintf(logline, "procset %s %d %d\n", procsetrest, version, revision);
     PSputs(logline, output);
   }
 
-/*  if ((infile = fopen(procsetfile, "r")) == NULL) { */
   infile = fopen(procsetfile, "rb");
 
-  if (input == NULL)  /* 93/Oct/3 */
+  if (input == NULL)
   {
     sprintf(logline, "ERROR: Can't find preamble file `%s'\n", procsetfile);
     showline(logline, 1);
@@ -2775,20 +2649,20 @@ int writepreamble (FILE *outfile, char *procsetfile, char *procsetrest, int chec
       strcat(logline, " ]%%) = flush % for Distiller log\n");
       PSputs(logline, outfile);
     }
-    ret = copypreamble(outfile, infile, procsetfile, checkflag);
+    ret = copy_preamble(outfile, infile, procsetfile, checkflag);
     fclose(infile);
     if (abortflag) ret = -1;
   }
+
   if (stripcomment == 0)
     PSputs("%%EndResource\n", outfile);
 
   return ret;
 }
 
-/* void copyprologfile(char *filename, FILE *outfile) { */
 void copyprologfilesub (char *filename, FILE *outfile)
 {
-  FILE *infile;
+  FILE * infile;
 
   if (verboseflag)
   {
@@ -2806,6 +2680,7 @@ void copyprologfilesub (char *filename, FILE *outfile)
       sprintf(logline, "procset %s\n", filename);   /* should have version and revision? */
       PSputs(logline, output);
     }
+
     dvidictbegin(outfile);
     copyepssimple(outfile, infile);       /* 1993/Jan/24 */
     fclose(infile);
@@ -2873,6 +2748,7 @@ int tryencandps(char *restofname)
     fclose(infile);
     return 0;
   }
+
   return -1;      // failed
 }
 
@@ -2891,7 +2767,7 @@ int setupprocset (char *procsetrest)
   FILE *infile;
   char *s;
 
-//  if explicit path given use that
+  //  if explicit path given use that
   if (strpbrk(procsetrest, "\\/:") != NULL)
   {
     strcpy(procsetfile, procsetrest);
@@ -2938,11 +2814,6 @@ int setupprocset (char *procsetrest)
   return -1;  // failed
 }
 
-#ifdef _WINDOWS
-char *achDiag   = "Diagnostics";      /* Profile file section name */
-char *achFile = "dviwindo.ini";
-#endif
-
 /* the following needs more work ... structuring conventions and such */
 /* also no coalesced mostly into on preamble => make file ? */
 
@@ -2964,10 +2835,6 @@ int writeheader (FILE *outfile)
     return -1;
   }
 
-#ifdef _WINDOWS
-  (void) WritePrivateProfileString(achDiag, "ProcSetFile", procsetfile, achFile);
-#endif
-
   if (writepreamble(outfile, procsetfile, procsetrest, 1) != 0)
   {
     sprintf(logline, "ERROR: Problem with %s\n", procsetfile);
@@ -3572,17 +3439,17 @@ int decodearg (char *command, char *next, int firstarg)
       }
       else if (paperflag != 0)
       {
-        papertype = s;
+        paper_type = s;
         paperflag = 0;
       }
       else if (boundingflag != 0)
       {
-        boundingtype = s;
+        bounding_type = s;
         boundingflag = 0;
       }
       else if (dscextraflag != 0)
       {
-        dscextra = s;
+        dsc_extra = s;
         dscextraflag = 0;
       }
       else if (afmflag != 0)
@@ -4044,7 +3911,7 @@ void packdatetime (char *date)  /* rewrite date and time in PDF format */
   strcpy(date + 6, date  + 7);
 }
 
-void writedocinfo (FILE *output)    /* write DOCINFO & PAGES pdfmarks */
+void writedocinfo (FILE *output)
 {
   time_t ltime;   /* for time and date */
   char *s = "";
@@ -4071,12 +3938,12 @@ void writedocinfo (FILE *output)    /* write DOCINFO & PAGES pdfmarks */
   }
   sprintf(logline, "[ /Title (%s)\n", line);      /* optional */
   PSputs(logline, output);
-/*  for PDFmark need date/time format (D:YYYYMMDDHHmmSS) */
-  (void) time(&ltime);      /* get seconds since 1970 */
-/*  added some sanity checks 98/July/29 */
+  (void) time(&ltime);
+
   if (ltime > 0)
   {
     s = ctime(&ltime);
+
     if (s != NULL)
     {
       lcivilize(s);
@@ -4096,18 +3963,7 @@ void writedocinfo (FILE *output)    /* write DOCINFO & PAGES pdfmarks */
     free(creatorstring);
     creatorstring = NULL;
   }
-//  fputs("  /Creator (", output);      /* optional */
-//  PSputs("  /Creator (", output);     /* optional */
-/*  stampit(output, 1, 0); */
-//  stampit(output, 0, 0);          /* 98/Apr/20 */
-//  stampit(line, 0, 0);          /* 98/Apr/20 */
-//  PSputs(line, output);
-/*  putc(' ', output); */
-/*  fputs(company, output); */
-/*  putc(' ', output); */
-/*  fputs(URL, output); */
-//  fputs(")\n", output);
-//  PSputs(")\n", output);
+
   if (*line != '\0')
   {
     sprintf(logline, "  /Creator (%s)\n", line);
@@ -4132,7 +3988,7 @@ void writedocinfo (FILE *output)    /* write DOCINFO & PAGES pdfmarks */
     PSputs(logline, output);
   }
 
-/*  Allow insertion of keywords using \special{keywords=...} 96/May/10 */
+  /*  Allow insertion of keywords using \special{keywords=...} 96/May/10 */
   if (keywords != NULL)
   {
     *line = '\0';
@@ -4195,6 +4051,7 @@ void writedocview (FILE *output)    /* write DOCVIEW pdfmark */
 
   /* only if PageMode or Base URL specified */
   PSputs("[", output);
+
   if (pagemode != NULL)
   {
     strcpy(line, pagemode);
@@ -4212,6 +4069,7 @@ void writedocview (FILE *output)    /* write DOCVIEW pdfmark */
     sprintf(logline, " /URI << /Base (%s) >>\n", line);
     PSputs(logline, output);
   }
+
   PSputs("/DOCVIEW pdfmark\n", output);
 /*  Could also have PageMode (UseNone, UseOutlines, UseThumbs, FullScreen) */
 /*  (Default is UseNone) --- see Table 10 in TN 5150 */
@@ -4223,7 +4081,7 @@ void writedocview (FILE *output)    /* write DOCVIEW pdfmark */
 void writesetup (FILE *output, char *filename)
 {
   time_t ltime;   /* for time and date */
-  int c;        /* for first letter of papertype */
+  int c;        /* for first letter of paper_type */
   char *s;
 
 /*  Don't bother with following if writing direct to printer ? */
@@ -4268,7 +4126,7 @@ void writesetup (FILE *output, char *filename)
     PSputs(s, output);
     PSputs(")\nput\n", output);
 
-    if (papertype != NULL || papersize != NULL)
+    if (paper_type != NULL || paper_size != NULL)
     {
       PSputs("[{\n", output);
       if (stripcomment == 0)
@@ -4276,25 +4134,25 @@ void writesetup (FILE *output, char *filename)
         PSputs("%%BeginFeature: ", output);
         PSputs("*PageSize", output);
 
-        if (papertype != NULL && strchr(papertype, '*') == NULL)
+        if (paper_type != NULL && strchr(paper_type, '*') == NULL)
         {
           PSputc(' ', output);
-          c = *papertype;
+          c = *paper_type;
 
           if (c >= 'a' && c <= 'z')
             c = c + 'A' - 'a';
           PSputc(c, output);
-          PSputs(papertype + 1, output);
+          PSputs(paper_type + 1, output);
         }
         PSputc('\n', output);
       }
 
 /*  don't output page command if `custom size' -l=<width>*<height> 94/Dec/16 */
-/*      if (strcmp(papertype, "custom") != 0) */
+/*      if (strcmp(paper_type, "custom") != 0) */
 /*      statusdict /lettertray get exec ??? */
-      if (papertype != NULL && strchr(papertype, '*') == NULL)
+      if (paper_type != NULL && strchr(paper_type, '*') == NULL)
       {
-        PSputs(papertype, output);  /* since already stopped context */
+        PSputs(paper_type, output);  /* since already stopped context */
       }
       else
       {
@@ -4600,15 +4458,10 @@ void initialtables (void)
     fontname[k] = subfontname[k] = fontvector[k] = fontchar[k] = NULL;
 }
 
-/* exehdr says: DVIPSONE.EXE needs 190k to load */
-/* In DOS: */
-/* Above says allocated 78848, 22454 avail, 22434 memmax, 2628 stack avail */
-/* In Epsilon 7.0 process buffer in Windows NT: */
-/* Above says allocated 39434, 21910 avail, 21890 memmax, 2628 stack avail */
-
 void freememory (void)  /*   check that heap was not corrupted */
 {
   int k;
+
   for (k = 0; k < MAXSUBSTITUTE; k++)
   {
     if (fontsubfrom[k] != NULL)
@@ -4675,7 +4528,7 @@ int dvibody (int argc, char *argv[])
   char *s, *t, *filename;
   clock_t sclock, lclock, fclock, eclock;
   char *mode;
-  unsigned long starttime;  /* seconds since 1970 Jan 1 */
+  unsigned long starttime;
   int count = 0;
 
 #ifdef USELOGFILE
@@ -4714,26 +4567,9 @@ int dvibody (int argc, char *argv[])
   
 //  following assumes dvipsone and dviwindo are subdirectories of same thing
 
-#ifdef _WINDOWS
-  if ((s = grabenv("YANDYPATH")) != NULL)
-  {
-    strcpy(line, s);
-    strcat(line, "\\dvipsone");
-    programpath = zstrdup(s);
-  }
-  else
-  {
-    programpath = zstrdup(GetCommandLine());  // 99/Jun/25
-    stripname(programpath);       // flush executable name
-
-//    this gets the path to DVIWindo ... not to DVIPSONE, so:
-    if ((s = strstr(programpath, "dviwindo")) != NULL) 
-      strcpy(s, "dvipsone");  // replace "dviwindo\\dviwindo.exe" with "dvipsone"
-  }
-#else
   programpath = zstrdup(argv[0]);
   stripname(programpath);   // flush executable name
-#endif
+
   strcpy(programpath, getenv("DVIPSONE")); // CM 20140401
 
 /*  if programpath doesn't exist - try and guess - not really likely ! */
@@ -4873,7 +4709,7 @@ int dvibody (int argc, char *argv[])
   if (verboseflag)
     showline("\n", 0);
 
-/*  Code to make up random prefix to avoid Acrobat partial font problem */
+/*  Code to make up random prefix to avoid Adobe Reader partial font problem */
   if (bRandomPrefix)
   {
     starttime = (unsigned long) time(NULL);
@@ -4900,9 +4736,6 @@ int dvibody (int argc, char *argv[])
     evenpageflag = 0; oddpageflag = 0;
   }
 
-#ifdef _WINDOWS
-  showcommand(NULL, argc, argv, 0);   /* show command line */
-#else
   if (showcommandflag)
   {
     showcommand(stdout, argc, argv, 0); /* show command line 94/Mar/8 */
@@ -4910,13 +4743,9 @@ int dvibody (int argc, char *argv[])
     if (logfileflag != 0)
       showcommand(logfile, argc, argv, 0); /* show command line 94/Mar/8 */
   }
-#endif
 
-//  doallocation();
   initialtables();
-
   initializeencoding(bANSITeX); /* textext and ansi encoding from SE */
-                                /* now used only in 16 bit version */
 
   if (traceflag)
   {
@@ -4943,11 +4772,7 @@ int dvibody (int argc, char *argv[])
 /*  also, don't force extension if an extension was specified */
 /*  also, try and figure out if going direct to a printer */
 
-#ifdef _WINDOWS
-  if (outputfile != NULL && usecallbackflag == 0)
-#else
   if (outputfile != NULL)
-#endif
   {
     strcpy(fn_out, outputfile);
 
@@ -5024,15 +4849,6 @@ int dvibody (int argc, char *argv[])
     }
   }
 
-#ifdef _WINDOWS
-  if (usecallbackflag)      // if we are going to use callback function
-  {
-    directprint = 0;
-    stripcomment = 0;
-    output = NULL;
-  }
-#endif
-
   if (bAbort)
     abortjob();
 
@@ -5074,11 +4890,7 @@ int dvibody (int argc, char *argv[])
     filename = removepath(fn_in);   /* strip off path of file */
 //    if (strcmp(outputfile, "") == 0)  /* output file specified ? */
 
-#ifdef _WINDOWS
-    if (outputfile == NULL && usecallbackflag == 0)
-#else
     if (outputfile == NULL)
-#endif
     {
       if (currentdirect != 0)     /* write in current directory ? */
         strcpy(fn_out, filename);
@@ -5157,13 +4969,8 @@ int dvibody (int argc, char *argv[])
 //    directprint = 1;    // debugging only
 //    stripcomment = 1;   // debugging only
 
-#ifdef _WINDOWS
-    sprintf(logline, "(%sto %s)\n", directprint ? "direct " : "",
-        usecallbackflag ? "DVIWindo" : fn_out);
-#else
     sprintf(logline, "(%sto %s)\n", directprint ? "direct " : "",
         fn_out);
-#endif
     showline(logline, 0);
     
 /*    input = fp_in;          */
@@ -5189,17 +4996,6 @@ int dvibody (int argc, char *argv[])
 
     rewind(input);          /* get set for next pass */
 
-/*    printf("NUMPAGES %ld\n", numpages); */  /* debugging 94/Oct/13 */
-
-    if (useatmreg)
-    {
-      if (LoadATMREG() < 0) // try and get info from ATMREG.ATM
-      {
-        if (verboseflag) showline("Warning: no ATMREG.ATM ", 0);
-//        return -1;
-      }
-    }
-
     task = "checking for duplicate & substitutions";
 
     if (substituteflag)       // this is done once per file now
@@ -5208,15 +5004,15 @@ int dvibody (int argc, char *argv[])
     preextract();
 
 /*    do the following only once ? not needed for every file ? */ 
-/*    analpapertype(papertype); */  
+/*    analpapertype(paper_type); */  
 /*    get PageHeight and PageWidth */   /* 94/May/6 */
     pageheight = 11*72; pagewidth = 8.5*72;   /* default */
 
-    if (papersize != NULL)
-      decodepapersize(papersize, &pagewidth, &pageheight);
+    if (paper_size != NULL)
+      decode_paper_size(paper_size, &pagewidth, &pageheight);
 
-    if (papertype != NULL)
-      analpapertype(papertype, &pagewidth, &pageheight);
+    if (paper_type != NULL)
+      analpapertype(paper_type, &pagewidth, &pageheight);
 
     lclock = clock();       /* end of prescan - start of fonts */
 
@@ -5462,17 +5258,14 @@ int dvibody (int argc, char *argv[])
     if (bCarryColor && bColorUsed)
       freecolorsave(); // 2000 May 27
 
-    if (papersize != NULL)
+    if (paper_size != NULL)
     {
-      free(papersize);
-      papersize = NULL;
+      free(paper_size);
+      paper_size = NULL;
     }
+
     count++;        /* 99/Mar/17 */
-#ifdef _WINDOWS
-    PSputs("", output);     // flush PS buffer in DLL version
-#else
     fflush(stdout);       /* ??? 98/Jun/30 */
-#endif
 
     freememory();       // moved here to happen every file
 
@@ -5620,12 +5413,8 @@ int main (int argc, char *argv[]) /* main program entry point */
 
   if (flag == 0)
     return 0;
-
-#ifdef _WINDOWS
-  return flag;
-#else
-  else exit (flag);
-#endif
+  else
+    exit (flag);
 }
 
 //////////////////////////////////////////////////////////////////////////////
index 07d84c3..58d3c41 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301 USA.  */
 
-/////////////////////////////////////////////////////////
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <conio.h>
 
 
-#ifdef _WINDOWS
-  #pragma warning(disable:4100) // unreferenced formal variable
-#endif
-
 #pragma warning(disable:4996)
 #pragma warning(disable:4127) // conditional expression is constant
 
 #ifdef _WINDOWS
-
-// MYLIBAPI is defined as __declspec(dllexport) in the
-// implementation file (dvipsone.c).  Thus when this
-// header file is included by dvipsone.c, functions will
-// be exported instead of imported.
-
-#ifndef MYLIBAPI
-#define MYLIBAPI __declspec(dllimport)
-#endif
-
-//////////////////////////////////////////////////////////
-
-// MYLIBAPI int dvipsone(HWND, char *);
-
-// MYLIBAPI int dvipsone(HWND, char *, int (*) (const char *));
-MYLIBAPI int dvipsone(HWND, char *, int (*) (const char *, int));
-
-// last argument is a call-backup that can send PS strings back
-
-#define ICN_LISTBOX  525
-#define ICN_COPY     526
-#define ICN_RESET    527
-#define ICN_ADDTEXT  528
-#define ICN_SETTITLE 529
-#define ICN_DONE     530
-#define ICN_CLEAR    531
-
-// MYLIBAPI int reencodeflag;
-
-#endif
-
-#ifdef _WINDOWS
-#define PSBUFLEN 256
-extern unsigned int psbufpos;
-extern char psbuffer[PSBUFLEN];
-extern void sendpsbuffer(FILE *);
-extern void psputs(char *, FILE *);
-#endif
-
-#ifdef _WINDOWS
 #define PSputs(str,output) psputs(str,output)
 #else
 #define PSputs(str,output) fputs(str,output)
 #endif
 
 // PSputc done as macro for speed
-
 #ifdef _WINDOWS
 // #define PSputc(chr,output) psputc(str, output);
 #define PSputc(chr,output)              \
@@ -114,18 +67,14 @@ extern void psputs(char *, FILE *);
   } while(0)
 #endif
 
-#ifdef _WINDOWS
-// extern int (* PScallback) (const char *);  // callback for PS strings
-extern int (* PScallback) (const char *, int);  // callback for PS strings
-#endif
-
 //////////////////////////////////////////////////////////
 
 #define ID_BYTE 2     /* for version of DVI files that we understand */
 
 /* Introduce new convenient structure for color info 98/Jul/18 */
 
-typedef struct tagCOLORSPEC {
+typedef struct
+{
   float A;
   float B;
   float C;
@@ -133,18 +82,6 @@ typedef struct tagCOLORSPEC {
 }
 COLORSPEC;
 
-/* the following kills __far */
-#define __far
-/*  and redefine far malloc, far realloc and far free in Win 32 */
-#define _ffree free
-#define _fmalloc malloc
-#define _frealloc realloc
-/* following are not standard C anyway */
-/* #define _strdup strdup */
-/* #define _searchenv searchenv */
-/* #define _access access */
-/* #define _alloca alloca */
-
 /* #define FILENAME_MAX 128 */ /* 16 bit compiler stdio.h */
 /* #define FILENAME_MAX 260 */ /* 32 bit compiler stdio.h */
 
@@ -273,24 +210,24 @@ COLORSPEC;
 
 /* DVI one byte commands: */
 
-enum dvicom {
-/* set_char_0 = 0, set_char_1, set_char_2, */
-set1 = 128, set2, set3, set4,
-set_rule = 132, 
-put1 = 133, put2, put3, put4,
-put_rule = 137,
-nop = 138, bop, eop, push, pop,
-right1 = 143, right2, right3, right4,
-w0 = 147, w1, w2, w3, w4,
-x0 = 152, x1, x2, x3, x4,
-down1 = 157, down2, down3, down4,
-y0 = 161, y1, y2, y3, y4,
-z0 = 166, z1, z2, z3, z4,
-/* fnt_num_0 = 171, font_num_1, font_num_2, font_num_3, */
-fnt1 = 235, fnt2, fnt3, fnt4,
-xxx1 = 239, xxx2, xxx3, xxx4,
-fnt_def1 = 243, fnt_def2, fnt_def3, fnt_def4,
-pre = 247, post, post_post
+enum dvicom 
+{
+  set1 = 128, set2, set3, set4,
+  set_rule = 132, 
+  put1 = 133, put2, put3, put4,
+  put_rule = 137,
+  nop = 138, bop, eop, push, pop,
+  right1 = 143, right2, right3, right4,
+  w0 = 147, w1, w2, w3, w4,
+  x0 = 152, x1, x2, x3, x4,
+  down1 = 157, down2, down3, down4,
+  y0 = 161, y1, y2, y3, y4,
+  z0 = 166, z1, z2, z3, z4,
+  /* fnt_num_0 = 171, font_num_1, font_num_2, font_num_3, */
+  fnt1 = 235, fnt2, fnt3, fnt4,
+  xxx1 = 239, xxx2, xxx3, xxx4,
+  fnt_def1 = 243, fnt_def2, fnt_def3, fnt_def4,
+  pre = 247, post, post_post
 };
 
 /* srefl = 250, erefl = 251 used for `right-to-left' languages in TeX-XeT */
@@ -512,7 +449,7 @@ extern long pageno;     /* for convenience in error messages dvipslog.c */
 extern long pagenumber;   /* count of pages actually seen */
 extern long numpages;   /* number of pages actually processed */
 extern long dvistart;   /* where DVI part of Textures file starts */
-extern long nMinRule;   /* min rule thickness (Acrobat fix) 95/Oct/10 */
+extern long nMinRule;   /* min rule thickness (Adobe Reader fix) 95/Oct/10 */
 extern long previous;   /* pointer to previous bop in this file */
 extern int finish;      /* when seen last eop */
 
@@ -743,7 +680,7 @@ extern long specstart;    /* saved start of \special for error message */
 
 extern char *comment;     /* pointer to place for TeX comment */
 
-extern char *papersize;     /* Custom paper size specified via special */
+extern char *paper_size;     /* Custom paper size specified via special */
 
 extern int nheaderlength;   // 99/July/14
 extern char *headerfile;    /* name of user supplied header file(s) */
@@ -762,12 +699,12 @@ extern char *keywords;      /* accumulated keywords from keywords= */
 
 extern char *dscfile;     /* name of (single) DSC header file */
 
-extern char *creatorstring;   /* creator for DocInfo in Acrobat */
-extern char *titlestring;   /* title for DocInfo in Acrobat */
-extern char *subjectstring;   /* Subject for DocInfo in Acrobat */
-extern char *authorstring;    /* Author for DocInfo in Acrobat */
-extern char *basestring;    /* Base for DocView in Acrobat */
-extern char *pagemode;      /* Base for DocView in Acrobat */
+extern char *creatorstring;   /* creator for DocInfo in Adobe Reader */
+extern char *titlestring;   /* title for DocInfo in Adobe Reader */
+extern char *subjectstring;   /* Subject for DocInfo in Adobe Reader */
+extern char *authorstring;    /* Author for DocInfo in Adobe Reader */
+extern char *basestring;    /* Base for DocView in Adobe Reader */
+extern char *pagemode;      /* Base for DocView in Adobe Reader */
 
 extern int stinx;       /* stack index */ /* just for verification */
 extern int maxstinx;      /* max stack index seen */
index 9520d7c..42c52bf 100644 (file)
@@ -3781,84 +3781,6 @@ int readdvitops (FILE *output, FILE *input, int pctexflag)
 
 void reademtex(FILE *, FILE *);
 
-#ifdef IGNORED
-
-/* em:message xxx --- output message xxx right away on console */
-/* em:linewidth w ---- set linewidth for subsequent lines 0.4pt default */
-/* em:moveto --- remember current point as start for next line */
-/* em:lineto --- draw line from previous moveto or lineto */
-
-/* em:graph xxx ---- MSP or PCX image top-left corner at current point */
-/* em:point n --- remember current coordinates for point n */
-/* em:line a[h|v|p],b[h|v|p][,w] draw line thickness w from point a to b */
-
-void reademtex (FILE *output, FILE *input)
-{
-  double linewidth, multiple;
-  long emline = 26214;          /* default 0.4pt * 65536 */
-  char *s;
-  char units[3];
-  int n;
-
-/*  if (get_alpha_token(input, line, MAXLINE) == 0) { */
-  if (get_alpha_token(input, line, sizeof(line)) == 0)
-  {
-    complainspecial(input);
-    return;
-  }
-  if (strcmp(line, "message") == 0)
-  {
-//    putc(' ', stdout);  
-    showline(" ", 0); 
-    (void) scan_special(input, line, MAXLINE);
-//    fputs(line, stdout);
-//    PSputs(line, stdout);
-    showline(line, 0);
-  }
-  else if (strcmp(line, "linewidth") == 0) {
-    (void) scan_special(input, line, MAXLINE);
-    s = line;
-    if (sscanf(s, "%lg%n", &linewidth, &n) == 0) {
-      showline("linewidth not specified", 1); /* used default */
-    }
-    else {
-      s +=  n;
-      units[0] = *s++; units[1] = *s++; units[2] = '\0';
-      multiple = decodeunits (units);   /* conversion to PS pt's */
-      linewidth = linewidth * multiple * (72.27 / 72.0) * 65536.0;
-      emline = (long) (linewidth + 0.5);  /* convert to scaled pt's */
-    }
-    PSputc('\n', output);       // always on new line ?
-#ifdef ALLOWSCALE
-    if (outscaleflag) {
-      sprintf(logline, "%.9lg emw", (double) emline / outscale);
-      PSputs(logline, output);
-    }
-    else
-#endif
-    {
-      sprintf(logline, "%ld emw", emline);
-      PSputs(logline, output);
-    }
-    showcount = 0;    
-  }
-  else if (strcmp(line, "moveto") == 0) {
-    PSputs(" emm", output);
-    showcount++;
-  }
-  else if (strcmp(line, "lineto") == 0) {
-    PSputs(" eml", output);
-    showcount++;
-  }
-  else complainspecial(input);
-  if (showcount >=MAXSHOWONLINE) {
-    PSputc('\n', output);
-    freshflag = 1;    // ?
-    showcount = 0;
-  }
-}
-#endif
-
 /*    DVITPS specials for figure insertion --- 1993/March/24  */
 /*    Not done as carefully as it should be, see DVI2PS and DVIPS code */
 
index 163227b..04f679e 100644 (file)
@@ -1340,15 +1340,6 @@ int readBMPPalette (FILE *input, long ColorMapPtr, int BitsPerSample)
   }\r
   \r
 /*  fseek (input, present, SEEK_SET); */\r
-#ifdef IGNORED\r
-  if (traceflag) {    /* show palette */\r
-    for (k = 0; k < n; k++) {\r
-      sprintf(logline, "INX %d\tR %u\tG %u\tB %u\n",\r
-        k, PaletteRed[k], PaletteGreen[k], PaletteBlue[k]);\r
-      showline(logline, 1);\r
-    }\r
-  }\r
-#endif\r
   return 0; \r
 }\r
 \r
@@ -2526,41 +2517,6 @@ int SetupNodes (FILE *output)
   return 0;\r
 }\r
 \r
-#ifdef IGNORED\r
-// We are at node n and adding a new branch for byte chr -- NOT USED\r
-void AddaNode (FILE *output, int n, int chr, int previous)\r
-{\r
-  int k, klast;\r
-//  if (nextnode < 0 || nextnode >= MAXCODES) showline("TABLE OVERFLOW", 1);\r
-//  Is there already a node at the next level ?\r
-  k = node[n].nextlevel;\r
-  if (k < 0) {    // no, start next level list\r
-    node[n].nextlevel = nextnode; // link to new node\r
-  }\r
-  else {                // yes, link to end of that list\r
-//    k = node[n].nextlevel;\r
-//    find end of linked list\r
-    while (k >= 0) {\r
-      klast = k;\r
-      k = node[klast].nextinlist;\r
-    }\r
-    node[klast].nextinlist = nextnode;  // link new node to end of list\r
-  }\r
-//  set up new node being added\r
-//  node[nextnode].code = nextnode;\r
-  node[nextnode].chr = chr;\r
-  node[nextnode].nextinlist = -1;\r
-  node[nextnode].nextlevel = -1;\r
-  nextnode++;\r
-  if (nextnode == 512 || nextnode == 1024 || nextnode == 2048) {\r
-//    sprintf(logline, "CODELENGTH %d ", codelength);\r
-//    showline(logline, 0);\r
-    codelength++;\r
-  }\r
-  else if (nextnode == 4096) CleanOut(output, chr);\r
-}\r
-#endif\r
-\r
 // We are adding a new node for byte chr\r
 \r
 void NewNode (FILE *output, int chr, int previous) {\r
@@ -2625,18 +2581,6 @@ void DoNextByte (FILE *output, int chr) { // called from  writearowLZW
   currentnode = k;  // it IS in table, no output\r
 }\r
 \r
-#ifdef IGNORED\r
-void DoCleanup (FILE *output)  // not used - see LZWflushfilter\r
-{\r
-  if (currentnode >= 0) LZWput(currentnode, output);\r
-//  LZWput(CLEAR, output);\r
-//  nextnode = FIRSTCODE;\r
-//  currentnode = -1;\r
-//  codelength = 9;\r
-  CleanOut(output, -1);\r
-}\r
-#endif\r
-\r
 /***************************************************************************/\r
 \r
 int perrow = 100;\r
@@ -4988,15 +4932,7 @@ int DecodeLZW (FILE *output, FILE *input, unsigned char *lpBuffer)
   long nlen;\r
 \r
   nlen = (long) BufferLength * RowsPerStrip;\r
-#ifdef IGNORED\r
-/*  is this 65535U limit still valid in NT ? malloc limitation ? */\r
-  if (nlen > 65535U) {\r
-    sprintf(logline, " Cannot handle Strip Buffer of %lu bytes\n", nlen);\r
-    showline(logline, 1);\r
-/*    nlen = 30000U;  */        /* TESTING HACK! */\r
-    checkexit(1); \r
-  }\r
-#endif\r
+\r
   StripDataLen = (unsigned int) nlen;\r
 #ifdef DEBUGTIFF\r
   if (traceflag) {            /* debugging */\r