[tex-k] premature end of file (dvips 5.86f)

Toshikazu Onishi ohnishi@a.phys.nagoya-u.ac.jp
Tue, 5 Feb 2002 20:52:05 -0300


Hi,

Although I'm new to dvips codes, I am reporting a possible bug.

I've just installed teTeX-src-beta-20020129, and found that some EPS files 
cannot be embedded via dvips.  When the next lines of %%EndBinary are \n\n (
example 1) or one normal character plus \n (example 2), the premature end 
of file error occurs (i.e., the second character is '\n').  This may be 
because the possibleDSCLine is "BeginBinary:" and because c=='\n' when it 
returns to the beginning of while roop even after processing the Binary 
section.  If the next second character of "%%EndBinary" is '\n', the 
possibleDSCLine of "BeginBinary:" is used again, resulting in a premature 
error.

**Example 1***
%%EndBinary


Q
false eomode
**************

**Example 2***
%%EndBinary
Q
false eomode
**************

This is my guess, but the following fix works for me.
There may be another solution.

It would be nice if you check the code.

Toshikazu Onishi

*** output.c.orig       Tue Feb  5 18:17:01 2002
--- output.c    Tue Feb  5 18:19:23 2002
***************
*** 446,452 ****
                          if (c != '%')
                             error("! expected to see %%EndBinary at end of data") ;
                          while (1) {
-                            (void)putc(c, bitfile) ;
                             if (c == '\r' || c == '\n') {
                              if (c == '\r') { /* DOS-style text file? */
                                 c = getc(f);
--- 446,451 ----
***************
*** 457,469 ****
                              }
                                break ;
                           }
                             c = getc(f) ;
                             dosepsend-- ;
                             if (c == EOF)
                                error(
                                   "! premature end of file in binary section") ;
                          }
!                         c = getc(f) ;
                          dosepsend-- ;
                       }
                    } else if (scanForEnd && strncmp(possibleDSCLine, scanForEnd,
--- 456,469 ----
                              }
                                break ;
                           }
+                            (void)putc(c, bitfile) ;
                             c = getc(f) ;
                             dosepsend-- ;
                             if (c == EOF)
                                error(
                                   "! premature end of file in binary section") ;
                          }
!                         possibleDSCLine[0] = 0;
                          dosepsend-- ;
                       }
                    } else if (scanForEnd && strncmp(possibleDSCLine, scanForEnd,