[comp.text.tex] "dvidvi" executable on PC?

luo@dutepp1.et.tudelft.nl (Jian Luo) (06/05/91)

Hi, somebody here has got "dvidvi" run on an IBM-PC?  I would be very grateful
to you if you could send me a copy.  Or somebody informs me where I could
get one?

Thanks in advance.

Regards,
Jian <jian@hdetud11.bitnet>

--
===========================================================================
|| J. Luo                             |*| jian@hdetud11.bitnet           ||
|| Faculty of Electrical Engineering  |*| jluo@dutepp1.tudelft.nl        ||
|| Delft University of Technology     |*| Tel: +31-15-786227             ||

rjl@monu1.cc.monash.edu.au ( r lang) (06/09/91)

In article <.676108875@dutepp1>, luo@dutepp1.et.tudelft.nl (Jian Luo) writes:
> Hi, somebody here has got "dvidvi" run on an IBM-PC?  

Here are is a patch to make it work.
To compile use:
  tcc -DMSDOS dvidvi.c

*** dvidvi.c	Tue Jan  3 07:23:05 1989
--- dvidvipc.c	Sun Jun  9 17:10:21 1991
***************
*** 11,16
   */
  #include "stdio.h"
  #define MAXPPERP (32)
  /*
   *   Some globals to keep everyone happy.
   */

--- 11,25 -----
   */
  #include "stdio.h"
  #define MAXPPERP (32)
+ 
+ #ifdef MSDOS
+ #define READBIN "rb"
+ #define WRITEBIN "wb"
+ #include <string.h>
+ #else
+ #define READBIN "r"
+ #define WRITEBIN "w"
+ #endif
  /*
   *   Some globals to keep everyone happy.
   */
***************
*** 25,31
  } pages[MAXPPERP] ;  /* the organization of the pages on output */
  int pagesperpage ;   /* how many pages crammed onto each page? */
  FILE *infile ;       /* input dvi file (cannot be a stream) */
! char *temp[255] ;    /* a temporary place to put things */
  unsigned char *dvibuf ; /* our entire dvi file */
  long inlength ;      /* the length of the input dvi file */
  long postloc ;       /* location of the postamble */

--- 34,40 -----
  } pages[MAXPPERP] ;  /* the organization of the pages on output */
  int pagesperpage ;   /* how many pages crammed onto each page? */
  FILE *infile ;       /* input dvi file (cannot be a stream) */
! char temp[255] ;    /* a temporary place to put things */
  unsigned char *dvibuf ; /* our entire dvi file */
  long inlength ;      /* the length of the input dvi file */
  long postloc ;       /* location of the postamble */
***************
*** 311,317
   */
     argc-- ;
     argv++ ;
!    if ((infile=fopen(argv[0],"r"))==NULL) {
        strcpy(temp, argv[0]) ;
        strcat(temp, ".dvi") ;
        if ((infile=fopen(temp,"r"))==NULL)

--- 320,326 -----
   */
     argc-- ;
     argv++ ;
!    if ((infile=fopen(argv[0],READBIN))==NULL) {
        strcpy(temp, argv[0]) ;
        strcat(temp, ".dvi") ;
        if ((infile=fopen(temp,READBIN))==NULL)
***************
*** 314,320
     if ((infile=fopen(argv[0],"r"))==NULL) {
        strcpy(temp, argv[0]) ;
        strcat(temp, ".dvi") ;
!       if ((infile=fopen(temp,"r"))==NULL)
           error("! can't open input file") ;
     }
     argc-- ;

--- 323,329 -----
     if ((infile=fopen(argv[0],READBIN))==NULL) {
        strcpy(temp, argv[0]) ;
        strcat(temp, ".dvi") ;
!       if ((infile=fopen(temp,READBIN))==NULL)
           error("! can't open input file") ;
     }
     argc-- ;
***************
*** 328,334
     if (q==NULL)
        strcat(temp, ".dvi") ;
     if (argc > 0) {
!       if (freopen(temp, "w", stdout)==NULL)
           error("! can't open output file") ;
     }
  }

--- 337,343 -----
     if (q==NULL)
        strcat(temp, ".dvi") ;
     if (argc > 0) {
!       if (freopen(temp, WRITEBIN, stdout)==NULL)
           error("! can't open output file") ;
     }
  }
***************
*** 338,344
  long u2(where)
  long where ;
  {
!    return((dvibuf[where] << 8) + dvibuf[where + 1]) ;
  }
  /*
   *   Grabs a longword from the file.

--- 347,353 -----
  long u2(where)
  long where ;
  {
!    return(((long)dvibuf[where] << 8) + (long)dvibuf[where + 1]) ;
  }
  /*
   *   Grabs a longword from the file.
***************
*** 524,530
     p = dviloc ;
     dvibyte(248) ;
     dviquad(prevpp) ;
!    putbuf(postloc+5, 20) ;
     dvi2(u2(postloc+25)+1L) ; /* increase stack depth by 1 */
     dvi2(outputpages) ;
     for (i=0; i<256; i++)

--- 533,539 -----
     p = dviloc ;
     dvibyte(248) ;
     dviquad(prevpp) ;
!    putbuf(postloc+5, 20L) ;
     dvi2(u2(postloc+25)+1L) ; /* increase stack depth by 1 */
     dvi2(outputpages) ;
     for (i=0; i<256; i++)
***************
*** 566,572
  
     p = pageloc(num) + 45 ;
     while (dvibuf[p] != 140) {
!       if (len=comlen[dvibuf[p]]) {    /* most commands are simple */
           putbuf(p, (long)len) ;
           p += len ;
        } else {   /* but there are a few we need to treat specially */

--- 575,581 -----
  
     p = pageloc(num) + 45 ;
     while (dvibuf[p] != 140) {
!       if ((len=comlen[dvibuf[p]]) != 0) {    /* most commands are simple */
           putbuf(p, (long)len) ;
           p += len ;
        } else {   /* but there are a few we need to treat specially */
-- 
Russell Lang   Email: rjl@monu1.cc.monash.edu.au   Phone: (03) 565 3460
Department of Electrical and Computer Systems Engineering
Monash University, Australia