texlive/source-dviutils.dif

578 lines
15 KiB
Plaintext
Raw Normal View History

--- m4/kpse-kpathsea-flags.m4
+++ m4/kpse-kpathsea-flags.m4 2010-11-12 11:51:59.947926203 +0000
@@ -19,7 +19,7 @@
AC_DEFUN([KPSE_KPATHSEA_FLAGS],
[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/search.c
+++ texk/seetexk/search.c 2009-08-28 14:13:32.877901585 +0000
@@ -19,6 +19,7 @@
* it runs in increasing-key-value sequence).
*/
+#include <stdlib.h>
#include "types.h"
#include "search.h"
@@ -30,10 +31,6 @@
static int DOffset; /* part of alignment code */
-#ifndef KPATHSEA
-char *malloc(), *realloc();
-#endif
-
struct search *
SCreate(unsigned int dsize)
{
--- texk/seetexk/a4toa5
+++ texk/seetexk/a4toa5 2010-11-12 11:50:39.552426619 +0000
@@ -0,0 +1,26 @@
+#!/bin/csh -f
+# 1993 (c) Werner Fink <Werner.Fink@itap.physik.uni-stuttgart.de>
+#
+
+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 2012-06-12 16:08:20.232473178 +0200
@@ -14258,7 +14258,7 @@ if test "x$with_kpathsea_libdir" != x &&
KPATHSEA_LIBS="-L$with_kpathsea_libdir $KPATHSEA_LIBS"
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 2009-08-28 14:13:32.721901870 +0000
@@ -27,6 +27,7 @@ extern char *optarg;
extern int optind;
#endif
+#include <stdlib.h>
#include "types.h"
#include "dviclass.h"
#include "dvicodes.h"
@@ -35,6 +36,8 @@ extern int optind;
#include "gripes.h"
#include "search.h"
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <ctype.h>
#include "seek.h"
@@ -101,9 +104,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
-char *malloc(), *realloc();
-#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 2009-08-28 14:31:09.497902049 +0000
@@ -25,6 +25,8 @@ extern char *optarg;
extern int optind;
#endif
+#include <stdlib.h>
+#include <string.h>
#include "types.h"
#include "dviclass.h"
#include "dvicodes.h"
@@ -87,15 +89,9 @@ i16 DVIStackSize; /* max of all stack s
char writeerr[] = "error writing DVI file";
static void HandleDVIFile(void);
-#ifdef _AMIGA
#define bcmp(s1, s2, len) memcmp(s1, s2, len)
#define bzero(s, len) memset(s, '\0', len)
#define index(s, c) strchr(s, c)
-#endif /* _AMIGA */
-
-#ifndef KPATHSEA
-char *malloc(), *realloc();
-#endif
/* extern int getopt(int, char **, char*); */
--- texk/seetexk/dviselect.c
+++ texk/seetexk/dviselect.c 2009-08-28 14:32:32.286401443 +0000
@@ -38,7 +38,10 @@ extern int optind;
#include "gripes.h"
#include "search.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
#define white(x) ((x) == ' ' || (x) == '\t' || (x) == ',')
@@ -148,15 +151,9 @@ static int ParsePages(char *);
static void HandleDVIFile(void);
static void PutFontSelector(i32);
-#ifdef _AMIGA
#define bcmp(s1, s2, len) memcmp(s1, s2, len)
#define bzero(s, len) memset(s, '\0', len)
#define index(s, c) strchr(s, c)
-#endif /* _AMIGA */
-
-#ifndef KPATHSEA
-char *malloc(), *realloc();
-#endif /* not KPATHSEA */
/*
* You may get lint warnings about sprintf's return value.
@@ -550,7 +547,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 2012-04-13 14:45:18.261443109 +0000
@@ -42,6 +42,7 @@ extern char *optarg;
extern int optind;
#endif
+#include <stdlib.h>
#include "types.h"
#include "dviclass.h"
#include "dvicodes.h"
@@ -50,6 +51,8 @@ extern int optind;
#include "gripes.h"
#include "search.h"
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <ctype.h>
#define white(x) ((x) == ' ' || (x) == '\t' || (x) == ',')
@@ -86,6 +89,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 */
@@ -122,9 +126,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
-char *malloc(), *realloc();
-#endif
static void WriteFont(struct fontinfo *fi);
static void PutFontSelector(i32 index);
@@ -185,6 +186,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;
@@ -292,6 +302,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);
@@ -492,9 +504,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);
@@ -587,7 +605,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);
@@ -614,6 +633,7 @@ main(int argc, char **argv)
Width = 0;
Height = 0;
Magnification = 1000;
+ MyMag = 0;
Modulo = 1;
ProgName = *argv;
@@ -710,12 +730,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();
if (WritingPage)
--- texk/seetexk/error.c
+++ texk/seetexk/error.c 2010-11-12 11:52:47.916425348 +0000
@@ -10,7 +10,12 @@
* optionally quit.
*
*/
+#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <c-auto.h>
+#include <errno.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -22,20 +27,11 @@
extern char *ProgName; /* program name from argv[0] */
-#include <errno.h>
-#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 2010-11-12 11:55:39.148426060 +0000
@@ -13,16 +13,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 2009-08-28 14:38:06.501901818 +0000
@@ -10,14 +10,12 @@
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
#include "types.h"
#include "error.h"
#include "gripes.h"
-#ifndef WIN32
-extern int errno;
-#endif
-
/*
* Cannot allocate memory.
*/
@@ -26,7 +24,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 */
}
/*
@@ -71,7 +69,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);
}
/*
@@ -84,5 +82,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 2009-08-28 14:13:32.869901244 +0000
@@ -10,6 +10,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include "types.h"
#include "error.h"
#include "font.h"
@@ -25,7 +26,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
@@ -42,7 +43,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 */
}
/*
@@ -54,7 +55,7 @@ GripeFontAlreadyDefined(i32 n)
error(0, 0, "%s redefines font %ld", dfl, n);
error(1, 0, areyousure, dfn(), dfl);
- /* NOTREACHED */
+ exit (0); /* NOTREACHED */
}
/*
@@ -77,7 +78,7 @@ GripeUnexpectedOp(const char *s)
error(0, 0, "unexpected %s in %s", s, dfl);
error(1, 0, areyousure, dfn(), dfl);
- /* NOTREACHED */
+ exit (0); /* NOTREACHED */
}
/*
@@ -89,7 +90,7 @@ GripeMissingOp(const char *s)
error(0, 0, "missing %s in %s", s, dfl);
error(1, 0, areyousure, dfn(), dfl);
- /* NOTREACHED */
+ exit (0); /* NOTREACHED */
}
/*
@@ -101,7 +102,7 @@ GripeCannotFindPostamble(void)
error(0, 0, "cannot find postamble");
error(1, 0, areyousure, dfn(), dfl);
- /* NOTREACHED */
+ exit (0); /* NOTREACHED */
}
/*
@@ -113,7 +114,7 @@ GripeMismatchedValue(const char *s)
error(0, 0, "mismatched %s in %s", s, dfl);
error(1, 0, areyousure, dfn(), dfl);
- /* NOTREACHED */
+ exit (0); /* NOTREACHED */
}
/*
@@ -125,7 +126,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 2010-11-12 11:50:39.783926350 +0000
@@ -0,0 +1,12 @@
+#!/bin/csh -f
+# 1993 (c) Werner Fink <Werner.Fink@itap.physik.uni-stuttgart.de>
+#
+dvitype ${1} <<DONE |& tr " " "\012" | fgrep totalpages
+0
+
+
+
+0
+DONE
+
+exit(0)
--- texk/seetexk/odd2even
+++ texk/seetexk/odd2even 2010-11-12 11:50:39.783926350 +0000
@@ -0,0 +1,22 @@
+#!/bin/csh -f
+# 1993 (c) Werner Fink <Werner.Fink@itap.physik.uni-stuttgart.de>
+#
+
+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/seek.c
+++ texk/seetexk/seek.c 2009-08-28 14:13:32.877901585 +0000
@@ -32,6 +32,10 @@
#endif
#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
#include "types.h" /* for BSD_FILE_SYSTEM */
#include "seek.h"
#include "tempfile.h"
@@ -44,12 +48,7 @@
#endif
#include <sys/stat.h>
-#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 2009-08-28 14:13:32.905901116 +0000
@@ -10,6 +10,7 @@
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
@@ -24,9 +25,7 @@
#include "types.h"
#else
#include <sys/file.h>
-
-char *getenv();
-
+#include <unistd.h>
#endif
#include "tempfile.h"
--- texk/seetexk/types.h
+++ texk/seetexk/types.h 2009-08-28 14:13:32.921901032 +0000
@@ -43,8 +43,9 @@
*
* (The bcopy provided in lib/bcopy.c does handle overlap.)
*/
-/* #define BLOCK_COPY(from, to, len) memmove(to, from, len) */
-#define BLOCK_COPY(from, to, len) bcopy(from, to, len)
+#include <string.h>
+#define BLOCK_COPY(from, to, len) memmove(to, from, len)
+/* #define BLOCK_COPY(from, to, len) bcopy(from, to, len) */
/*
* Define void as int if your compiler does not support void,