summaryrefslogtreecommitdiff
path: root/Build/source/texk/seetexk/dvibook.c
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-09-08 21:36:37 +0000
committerKarl Berry <karl@freefriends.org>2020-09-08 21:36:37 +0000
commit16c1f549288b0562c1c6c0d6d46da40169ee28ca (patch)
tree6554fcfbd4961bae970c0cdbf6387936bc209b8a /Build/source/texk/seetexk/dvibook.c
parentbefeb63edd03594ceb469a986a1c8c651f1cd84c (diff)
dvibook, dvitodvi: remove fixed limit of 1000 pages
git-svn-id: svn://tug.org/texlive/trunk@56299 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/seetexk/dvibook.c')
-rw-r--r--Build/source/texk/seetexk/dvibook.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/Build/source/texk/seetexk/dvibook.c b/Build/source/texk/seetexk/dvibook.c
index 39bf291b78c..47e51efcaea 100644
--- a/Build/source/texk/seetexk/dvibook.c
+++ b/Build/source/texk/seetexk/dvibook.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1987, 1989, 2012 University of Maryland Department of
+/* Copyright (c) 1987, 1989, 2012, 2020 University of Maryland Department of
Computer Science.
Permission is hereby granted, free of charge, to any person obtaining
@@ -60,8 +60,6 @@ extern int optind;
#define white(x) ((x) == ' ' || (x) == '\t' || (x) == ',')
-#define MAXDVIPAGES 1000 /* max (absolute) pages in DVI file */
-
char *ProgName;
/* Globals */
@@ -100,8 +98,8 @@ const char *DVIFileName; /* name of input DVI file */
FILE *inf; /* the input file itself */
FILE *outf; /* the output DVI file */
-long StartOfPage[MAXDVIPAGES]; /* The file positions of the
- input pages */
+long *StartOfPage; /* The file positions of the input pages */
+long StartOfPageSpace; /* Number of entries of StartOfPage array */
long StartOfLastPage; /* The file position just before we
started the last page */
@@ -126,7 +124,8 @@ i32 Count[10]; /* the 10 \count variables */
char writeerr[] = "error writing DVI file";
#ifndef KPATHSEA
-char *malloc(), *realloc();
+void *malloc(), *realloc();
+void free();
#endif
/*
* You may get lint warnings about sprintf's return value.
@@ -519,6 +518,12 @@ Usage: %s [-s signature] [-q] [-i infile] [-o outfile] [infile [outfile]]\n",
#endif
InputPageNumber = 0;
StartOfLastPage = -1;
+ StartOfPageSpace = 32;
+ StartOfPage = malloc(sizeof(long) * StartOfPageSpace);
+ if (!StartOfPage) {
+ error(1, -1, "cannot allocate list of pages; out of memory");
+ }
+
HandlePreAmble();
ScanDVIFile();
#ifdef ASCIIPTEX
@@ -527,6 +532,7 @@ Usage: %s [-s signature] [-q] [-i infile] [-o outfile] [infile [outfile]]\n",
else
#endif
HandleDVIFile();
+ free(StartOfPage);
HandlePostAmble();
if (!SFlag)
(void) fprintf(stderr, "\nWrote %d page%s, %ld bytes\n",
@@ -730,11 +736,23 @@ char oplen[128] = {
static void
ScanDVIFile(void)
{
+ long *tmp;
+
UseThisPage = 0;
StartOfPage[InputPageNumber] = ftell(inf);
while (HandlePage()) { /* scan DVI file */
- StartOfPage[++InputPageNumber] = ftell(inf);
+ ++InputPageNumber;
+ if (InputPageNumber >= StartOfPageSpace) {
+ StartOfPageSpace *= 2;
+ tmp = realloc(StartOfPage, sizeof(long) * StartOfPageSpace);
+ if (!tmp) {
+ error(1, -1, "cannot grow list of pages; out of memory");
+ }
+ StartOfPage = tmp;
+ }
+
+ StartOfPage[InputPageNumber] = ftell(inf);
}
}