--- m4/kpse-kpathsea-flags.m4 | 2 +- texk/seetexk/a4toa5 | 26 ++++++++++++++++++++++++++ texk/seetexk/configure | 2 +- texk/seetexk/dvibook.c | 7 +++---- texk/seetexk/dviconcat.c | 6 ++---- texk/seetexk/dviselect.c | 8 +++----- texk/seetexk/dvitodvi.c | 41 ++++++++++++++++++++++++++++++++--------- texk/seetexk/error.c | 14 +++++--------- texk/seetexk/gripes.h | 21 +++++++++++---------- texk/seetexk/gripes0.c | 12 +++++------- texk/seetexk/gripes1.c | 17 +++++++++-------- texk/seetexk/mydvichk | 12 ++++++++++++ texk/seetexk/odd2even | 22 ++++++++++++++++++++++ texk/seetexk/search.c | 5 +---- texk/seetexk/seek.c | 11 +++++------ texk/seetexk/tempfile.c | 5 ++--- texk/seetexk/types.h | 2 +- 17 files changed, 141 insertions(+), 72 deletions(-) --- m4/kpse-kpathsea-flags.m4 +++ m4/kpse-kpathsea-flags.m4 2021-04-07 09:56:20.318745619 +0000 @@ -16,7 +16,7 @@ AC_DEFUN([KPSE_KPATHSEA_FLAGS], [dnl AC_REQUIRE([KPSE_SAVE_FLAGS])[]dnl _KPSE_TEXLIB_FLAGS([kpathsea], [kpathsea], [lt], - [-IBLD/texk -ISRC/texk], [BLD/texk/kpathsea/libkpathsea.la], [], + [-IBLD/texk/kpathsea -ISRC/texk/kpathsea -IBLD/texk -ISRC/texk], [BLD/texk/kpathsea/libkpathsea.la], [], [${top_srcdir}/../kpathsea/*.[ch]], [${top_builddir}/../kpathsea/paths.h]) m4_if(m4_index([ $1 ], [ no-debug ]), [-1], --- texk/seetexk/a4toa5 +++ texk/seetexk/a4toa5 2021-04-07 09:56:20.322745677 +0000 @@ -0,0 +1,26 @@ +#!/bin/csh -f +# 1993 (c) Werner Fink +# + +if (${#argv} <= 1) then + echo " ${0}: Usage: infile outfile" + exit +endif + +set NumP=`mydvichk $1 | sed -e 's/totalpages=//g'` + +if (${NumP} % 2) then + echo " Odd number of pages --- this doesn't work" + echo " Please use odd2even: This gives an additional first pages" + echo " Or" + echo " use dvibook: It sort the pages in book form" + exit +endif + +echo "${0}: For Printing: dvips -t landscape outfile" +echo "${0}: For Viewing: xdvi -paper a4r outfile" + +# +#exec dvitodvi -q '2:707@0(-5.5mm,-10mm)+1(204mm,-10mm)' $1 $2 +# +exec dvitodvi -q '2:707@0(-5.5mm,-10mm)+1(190mm,-10mm)' $1 $2 --- texk/seetexk/configure +++ texk/seetexk/configure 2021-04-07 09:56:20.322745677 +0000 @@ -16075,7 +16075,7 @@ elif test "x$need_kpathsea:$with_system_ as_fn_error $? "did not find kpathsea" "$LINENO" 5 fi else - KPATHSEA_INCLUDES="-I$kpse_BLD/texk -I$kpse_SRC/texk" + KPATHSEA_INCLUDES="-I$kpse_BLD/texk/kpathsea -I$kpse_SRC/texk/kpathsea -I$kpse_BLD/texk -I$kpse_SRC/texk" KPATHSEA_LIBS="$kpse_BLD/texk/kpathsea/libkpathsea.la" KPATHSEA_DEPEND='${top_builddir}/../kpathsea/libkpathsea.la' KPATHSEA_RULE='# Rebuild libkpathsea --- texk/seetexk/dvibook.c +++ texk/seetexk/dvibook.c 2021-04-07 09:59:15.141300494 +0000 @@ -49,6 +49,7 @@ extern int optind; #include #endif +#include #include "types.h" #include "dviclass.h" #include "dvicodes.h" @@ -57,6 +58,8 @@ extern int optind; #include "gripes.h" #include "search.h" #include +#include +#include #include #include "seek.h" #include "common.h" @@ -126,10 +129,6 @@ i32 Count[10]; /* the 10 \count variabl /* save some string space: we use this a lot */ char writeerr[] = "error writing DVI file"; -#ifndef KPATHSEA -void *malloc(), *realloc(); -void free(); -#endif /* * You may get lint warnings about sprintf's return value. * Older versions of 4BSD have `char *sprintf()'. ANSI and --- texk/seetexk/dviconcat.c +++ texk/seetexk/dviconcat.c 2021-04-07 09:56:20.322745677 +0000 @@ -46,6 +46,8 @@ extern int optind; #include #endif +#include +#include #include "types.h" #include "dviclass.h" #include "dvicodes.h" @@ -113,10 +115,6 @@ char writeerr[] = "error writing DVI fil static void HandleDVIFile(void); -#ifndef KPATHSEA -char *malloc(), *realloc(); -#endif - /* extern int getopt(int, char **, char*); */ /* --- texk/seetexk/dviselect.c +++ texk/seetexk/dviselect.c 2021-04-07 09:59:54.141870365 +0000 @@ -57,6 +57,8 @@ extern int optind; #include "gripes.h" #include "search.h" #include +#include +#include #include #include "common.h" @@ -173,10 +175,6 @@ static void HandleDVIFile(void); static void PutFontSelector(i32); static void WritePreAmble(void); -#ifndef KPATHSEA -char *malloc(), *realloc(); -#endif /* not KPATHSEA */ - /* * You may get lint warnings about sprintf's return value. * Older versions of 4BSD have `char *sprintf()'. ANSI and @@ -635,7 +633,7 @@ Usage: %s [-s] [-i infile] [-o outfile] static struct pagelist * InstallPL(struct pagesel *ps, int n, int absolute) { - register struct pagelist *pl; + struct pagelist *pl; pl = (struct pagelist *)malloc(sizeof *pl); if (pl == NULL) --- texk/seetexk/dvitodvi.c +++ texk/seetexk/dvitodvi.c 2021-04-07 10:02:34.816217795 +0000 @@ -46,6 +46,7 @@ extern char *optarg; extern int optind; #endif +#include #include "types.h" #include "dviclass.h" #include "dvicodes.h" @@ -54,6 +55,8 @@ extern int optind; #include "gripes.h" #include "search.h" #include +#include +#include #include #include "seek.h" #include "common.h" @@ -89,6 +92,7 @@ struct fontinfo { i32 Width; /* width of page */ i32 Height; /* height of page */ i32 Magnification; /* Magnification of pages */ +i32 MyMag; int Modulo; /* page spec modulo */ struct pagespec *PageSpecs; /* page specification list */ @@ -128,10 +132,6 @@ i32 Count[10]; /* the 10 \count variabl /* save some string space: we use this a lot */ char writeerr[] = "error writing DVI file"; -#ifndef KPATHSEA -void *malloc(), *realloc(); -void free(); -#endif static void WriteFont(struct fontinfo *fi); static void PutFontSelector(i32 index); @@ -192,6 +192,15 @@ scale(i32 whole, int num, int den, i32 s return (v) ; } +i32 myscale(i32 whole, i32 verus, i32 sf) +{ + i32 v; + + v = (i32) (( (double)whole * ( (double)sf / (double)verus ) ) + 0.5 ); + return(v); +} + + struct pagespec { int reversed, pageno, add; i32 xoff, yoff; @@ -299,6 +308,8 @@ parsedimen(char **sp) fac = Height; s++; } + if (MyMag) + fac = myscale(fac,MyMag,1000); whole = scale(whole, num, den, fac) ; *sp = s; return (neg ? -whole : whole); @@ -501,9 +512,15 @@ HandlePostAmble(void) PutLong(outf, Denominator); PutLong(outf, DVIMag); c = GetLong(inf); - PutLong(outf, c); /* tallest page height */ + if ( c >= Height ) + PutLong(outf, c); /* tallest page height */ + else + PutLong(outf, Height); c = GetLong(inf); - PutLong(outf, c); /* widest page width */ + if ( c >= Width ) + PutLong(outf, c); /* widest page width */ + else + PutLong(outf, Width); c = GetWord(inf)+1; PutWord(outf, c); /* DVI stack size */ PutWord(outf, NumberOfOutputPages); @@ -601,7 +618,8 @@ HandlePreAmble(void) DVIFileName, DVI_VERSION); Numerator = GetLong(inf); Denominator = GetLong(inf); - DVIMag = GetLong(inf) * Magnification / 1000; + MyMag = GetLong(inf); + DVIMag = MyMag * Magnification / 1000; putbyte(outf, DVI_PRE); putbyte(outf, DVI_VERSION); PutLong(outf, Numerator); @@ -641,6 +659,7 @@ main(int argc, char **argv) Width = 0; Height = 0; Magnification = 1000; + MyMag = 0; Modulo = 1; ProgName = *argv; @@ -752,12 +771,16 @@ Usage: %s [-q] [-i infile] [-o outfile] if (fseek(inf, 16L, 1) == -1) error(1, -1, "can't seek postamble"); if (Height == 0) /* get height from postamble */ - Height = GetLong(inf); + Height = myscale(GetLong(inf),1000,MyMag); else (void) GetLong(inf); /* ignore height */ if (Width == 0) /* get width from postamble */ - Width = GetLong(inf); + Width = myscale(GetLong(inf),1000,MyMag); + else + (void) GetLong(inf); PageSpecs = ParseSpecs(specstring, 1); + Height = myscale(Height,MyMag,1000); + Width = myscale(Width,MyMag,1000); HandleDVIFile(); free(StartOfPage); --- texk/seetexk/error.c +++ texk/seetexk/error.c 2021-04-07 09:56:20.326745736 +0000 @@ -29,7 +29,12 @@ #include #endif +#include #include +#include +#include +#include +#include #include "types.h" #include "error.h" @@ -37,20 +42,11 @@ extern char *ProgName; /* program name from argv[0] */ -#include -#ifndef errno -extern int errno; -#endif - static FILE *trap_file; /* error diversion file, if any */ static void (*trap_fn)(int, const char *); /* trap function */ static char *trap_buf; /* buffer for trapped error strings */ static int trap_size; /* size of trap_buf */ -#ifndef KPATHSEA -extern char *malloc(), *realloc(); -#endif - #if !defined (HAVE_STRERROR) && !defined (strerror) static char * strerror (int errnum) --- texk/seetexk/gripes.h +++ texk/seetexk/gripes.h 2021-04-07 09:56:20.326745736 +0000 @@ -28,16 +28,17 @@ extern const char *DVIFileName; * Declarations for the various gripes. */ -void GripeOutOfMemory(int n, const char *why); +#define __NR__ __attribute__ ((noreturn)) +void GripeOutOfMemory(int n, const char *why) __NR__; void GripeCannotGetFont(const char *name, i32 mag, i32 dsz, const char *dev, const char *fullname); void GripeDifferentChecksums(const char *font, i32 tfmsum, i32 fontsum); -void GripeMissingFontsPreventOutput(int n); -void GripeNoSuchFont(i32 n); -void GripeFontAlreadyDefined(i32 n); -void GripeUnexpectedDVIEOF(void); -void GripeUnexpectedOp(const char *s); -void GripeMissingOp(const char *s); -void GripeCannotFindPostamble(void); -void GripeMismatchedValue(const char *s); -void GripeUndefinedOp(int n); +void GripeMissingFontsPreventOutput(int n) __NR__; +void GripeNoSuchFont(i32 n) __NR__; +void GripeFontAlreadyDefined(i32 n) __NR__; +void GripeUnexpectedDVIEOF(void) __NR__; +void GripeUnexpectedOp(const char *s) __NR__; +void GripeMissingOp(const char *s) __NR__; +void GripeCannotFindPostamble(void) __NR__; +void GripeMismatchedValue(const char *s) __NR__; +void GripeUndefinedOp(int n) __NR__; void GripeBadGlyph(i32 c, struct font *f); --- texk/seetexk/gripes0.c +++ texk/seetexk/gripes0.c 2021-04-07 09:56:20.326745736 +0000 @@ -28,10 +28,8 @@ #include "error.h" #include "gripes.h" #include - -#ifndef WIN32 -extern int errno; -#endif +#include +#include /* * Cannot allocate memory. @@ -41,7 +39,7 @@ GripeOutOfMemory(int n, const char *why) { error(1, -1, "ran out of memory allocating %d bytes for %s", n, why); - /* NOTREACHED */ + exit(-1); /* NOTREACHED */ } /* @@ -86,7 +84,7 @@ WARNING: TeX and I have different checks \t\"%s\"\n\ \tPlease notify your TeX maintainer\n\ \t(TFM checksum = 0%lo, my checksum = 0%lo)", - font, (long)tfmsum, (long)fontsum); + font ? font : "", (long)tfmsum, (long)fontsum); } /* @@ -99,5 +97,5 @@ GripeMissingFontsPreventOutput(int n) error(1, 0, "%d missing font%s prevent%s output (sorry)", n, n > 1 ? s : &s[1], n == 1 ? s : &s[1]); - /* NOTREACHED */ + exit(0); /* NOTREACHED */ } --- texk/seetexk/gripes1.c +++ texk/seetexk/gripes1.c 2021-04-07 09:56:20.326745736 +0000 @@ -29,6 +29,7 @@ #include "font.h" #include "gripes.h" #include +#include static const char * dfn(void) @@ -40,7 +41,7 @@ dfn(void) /* * Save string space by declaring these here. */ -#if __STDC__ >= 1 +#if 0 static const char dfl[] = "DVI file"; static const char areyousure[] = "(are you sure %s is a %s?)"; #else @@ -57,7 +58,7 @@ GripeNoSuchFont(i32 n) error(0, 0, "%s wants font %ld, which it never defined", dfl, (long)n); error(1, 0, areyousure, dfn(), dfl); - /* NOTREACHED */ + exit (0); /* NOTREACHED */ } /* @@ -69,7 +70,7 @@ GripeFontAlreadyDefined(i32 n) error(0, 0, "%s redefines font %ld", dfl, n); error(1, 0, areyousure, dfn(), dfl); - /* NOTREACHED */ + exit (0); /* NOTREACHED */ } /* @@ -92,7 +93,7 @@ GripeUnexpectedOp(const char *s) error(0, 0, "unexpected %s in %s", s, dfl); error(1, 0, areyousure, dfn(), dfl); - /* NOTREACHED */ + exit (0); /* NOTREACHED */ } /* @@ -104,7 +105,7 @@ GripeMissingOp(const char *s) error(0, 0, "missing %s in %s", s, dfl); error(1, 0, areyousure, dfn(), dfl); - /* NOTREACHED */ + exit (0); /* NOTREACHED */ } /* @@ -116,7 +117,7 @@ GripeCannotFindPostamble(void) error(0, 0, "cannot find postamble"); error(1, 0, areyousure, dfn(), dfl); - /* NOTREACHED */ + exit (0); /* NOTREACHED */ } /* @@ -128,7 +129,7 @@ GripeMismatchedValue(const char *s) error(0, 0, "mismatched %s in %s", s, dfl); error(1, 0, areyousure, dfn(), dfl); - /* NOTREACHED */ + exit (0); /* NOTREACHED */ } /* @@ -140,7 +141,7 @@ GripeUndefinedOp(int n) error(0, 0, "undefined DVI opcode %d", n); error(1, 0, areyousure, dfn(), dfl); - /* NOTREACHED */ + exit (0); /* NOTREACHED */ } /* --- texk/seetexk/mydvichk +++ texk/seetexk/mydvichk 2021-04-07 09:56:20.326745736 +0000 @@ -0,0 +1,12 @@ +#!/bin/csh -f +# 1993 (c) Werner Fink +# +dvitype ${1} < +# + +if (${#argv} <= 1) then + echo " ${0}: Usage: infile outfile" + exit +endif + +set NumP=`mydvichk $1 | sed -e 's/totalpages=//g'` + +if (${NumP} % 2) then + dviselect -s '=1' $1 | \ + dvibook -q | \ + dviselect -s '=1' | \ + dviconcat -o $2 - $1 >& /dev/null + echo " ${0}: ready" +else + echo " ${0}: even number of pages --- nothing to do" +endif + +exit 0 --- texk/seetexk/search.c +++ texk/seetexk/search.c 2021-04-07 09:56:20.330745794 +0000 @@ -34,6 +34,7 @@ * it runs in increasing-key-value sequence). */ +#include #include "types.h" #include "search.h" @@ -45,10 +46,6 @@ static int DOffset; /* part of alignment code */ -#ifndef KPATHSEA -char *malloc(), *realloc(); -#endif - struct search * SCreate(unsigned int dsize) { --- texk/seetexk/seek.c +++ texk/seetexk/seek.c 2021-04-07 09:56:20.330745794 +0000 @@ -43,6 +43,10 @@ #endif #include +#include +#include +#include +#include #include "types.h" /* for BSD_FILE_SYSTEM */ #include "seek.h" #include "tempfile.h" @@ -55,12 +59,7 @@ #endif #include -#ifndef KPATHSEA -long lseek(); -char *malloc(); - -extern int errno; -#endif +extern int MakeRWTempFile(); /* * Make and return a version of `f' on which fseek works (unconditionally). --- texk/seetexk/tempfile.c +++ texk/seetexk/tempfile.c 2021-04-07 09:56:20.330745794 +0000 @@ -25,6 +25,7 @@ #endif #include +#include #include #ifdef HAVE_UNISTD_H @@ -39,9 +40,7 @@ #include "types.h" #else #include - -char *getenv(); - +#include #endif #include "tempfile.h" --- texk/seetexk/types.h +++ texk/seetexk/types.h 2021-04-07 09:56:20.330745794 +0000 @@ -58,7 +58,7 @@ * * (The bcopy provided in lib/bcopy.c does handle overlap.) */ -/* #define BLOCK_COPY(from, to, len) memmove(to, from, len) */ +#include #define BLOCK_COPY(from, to, len) memmove(to, from, len) /*