summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/image/writejbig2.w
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/image/writejbig2.w')
-rw-r--r--Build/source/texk/web2c/luatexdir/image/writejbig2.w55
1 files changed, 28 insertions, 27 deletions
diff --git a/Build/source/texk/web2c/luatexdir/image/writejbig2.w b/Build/source/texk/web2c/luatexdir/image/writejbig2.w
index 6828ba418aa..8b186b6b740 100644
--- a/Build/source/texk/web2c/luatexdir/image/writejbig2.w
+++ b/Build/source/texk/web2c/luatexdir/image/writejbig2.w
@@ -143,10 +143,10 @@ typedef struct _SEGINFO {
unsigned int segnumwidth; /* set by readseghdr() */
long segpage; /* set by readseghdr() */
unsigned long segdatalen; /* set by readseghdr() */
- unsigned long hdrstart; /* set by readseghdr() */
- unsigned long hdrend; /* set by readseghdr() */
- unsigned long datastart;
- unsigned long dataend;
+ off_t hdrstart; /* set by readseghdr() */
+ off_t hdrend; /* set by readseghdr() */
+ off_t datastart;
+ off_t dataend;
boolean endofstripeflag; /* set by checkseghdrflags() */
boolean endofpageflag; /* set by checkseghdrflags() */
boolean pageinfoflag; /* set by checkseghdrflags() */
@@ -168,13 +168,13 @@ typedef struct _PAGEINFO {
typedef struct _FILEINFO {
FILE *file;
char *filepath;
- long filesize;
+ off_t filesize;
LIST pages; /* not including page0 */
LIST page0;
unsigned int filehdrflags; /* set by readfilehdr() */
boolean sequentialaccess; /* set by readfilehdr() */
unsigned long numofpages; /* set by readfilehdr() */
- unsigned long streamstart; /* set by |get_jbig2_info()| */
+ off_t streamstart; /* set by |get_jbig2_info()| */
unsigned long pdfpage0objnum;
PHASE phase;
} FILEINFO;
@@ -369,7 +369,8 @@ static unsigned long getstreamlen(LITEM * slip, boolean refer)
for (; slip != NULL; slip = slip->next) {
sip = slip->d;
if (refer || sip->isrefered)
- len += sip->hdrend - sip->hdrstart + sip->dataend - sip->datastart;
+ len += (unsigned long) (sip->hdrend - sip->hdrstart)
+ + (unsigned long) (sip->dataend - sip->datastart);
}
return len;
}
@@ -381,7 +382,7 @@ static void readfilehdr(FILEINFO * fip)
/* Annex D.4 File header syntax */
/* Annex D.4.1 ID string */
unsigned char jbig2_id[] = { 0x97, 'J', 'B', '2', 0x0d, 0x0a, 0x1a, 0x0a };
- xfseek(fip->file, 0, SEEK_SET, fip->filepath);
+ xfseeko(fip->file, 0, SEEK_SET, fip->filepath);
for (i = 0; i < 8; i++)
if (ygetc(fip->file) != jbig2_id[i])
pdftex_fail
@@ -390,9 +391,9 @@ static void readfilehdr(FILEINFO * fip)
fip->filehdrflags = (unsigned int) ygetc(fip->file);
fip->sequentialaccess = (fip->filehdrflags & 0x01) ? true : false;
if (fip->sequentialaccess) { /* Annex D.1 vs. Annex D.2 */
- xfseek(fip->file, 0, SEEK_END, fip->filepath);
- fip->filesize = (long) xftello(fip->file, fip->filepath);
- xfseek(fip->file, 9, SEEK_SET, fip->filepath);
+ xfseeko(fip->file, 0, SEEK_END, fip->filepath);
+ fip->filesize = xftello(fip->file, fip->filepath);
+ xfseeko(fip->file, 9, SEEK_SET, fip->filepath);
}
/* Annex D.4.3 Number of pages */
if (!(fip->filehdrflags >> 1) & 0x01) /* known number of pages */
@@ -453,7 +454,7 @@ static void checkseghdrflags(SEGINFO * sip)
static boolean readseghdr(FILEINFO * fip, SEGINFO * sip)
{
unsigned int i;
- sip->hdrstart = xftell(fip->file, fip->filepath);
+ sip->hdrstart = xftello(fip->file, fip->filepath);
if (fip->sequentialaccess && sip->hdrstart == (unsigned) fip->filesize)
return false; /* no endoffileflag is ok for sequentialaccess */
#ifdef DEBUG
@@ -480,7 +481,7 @@ static boolean readseghdr(FILEINFO * fip, SEGINFO * sip)
sip->fieldlen = 1;
else {
sip->fieldlen = 5 + sip->countofrefered / 8;
- xfseek(fip->file, sip->fieldlen - 1, SEEK_CUR, fip->filepath);
+ xfseeko(fip->file, (off_t) sip->fieldlen - 1, SEEK_CUR, fip->filepath);
}
/* 7.2.5 Referred-to segment numbers */
if (sip->segnum <= 256)
@@ -509,7 +510,7 @@ static boolean readseghdr(FILEINFO * fip, SEGINFO * sip)
sip->segpage = ygetc(fip->file);
/* 7.2.7 Segment data length */
sip->segdatalen = read4bytes(fip->file);
- sip->hdrend = (unsigned long) xftello(fip->file, fip->filepath);
+ sip->hdrend = xftello(fip->file, fip->filepath);
/* ---- at end of segment header ---- */
return true;
}
@@ -590,7 +591,7 @@ static void checkseghdr(FILEINFO * fip, SEGINFO * sip)
/* 7.2.2 Segment number */
/* 7.2.3 Segment header flags */
/* 7.2.4 Referred-to segment count and retention flags */
- xfseek(fip->file, 5 + sip->fieldlen, SEEK_CUR, fip->filepath);
+ xfseeko(fip->file, (off_t) sip->fieldlen + 5, SEEK_CUR, fip->filepath);
/* 7.2.5 Referred-to segment numbers */
for (i = 0; i < sip->countofrefered; i++) {
switch (sip->segnumwidth) {
@@ -612,14 +613,14 @@ static void checkseghdr(FILEINFO * fip, SEGINFO * sip)
/* 7.2.6 Segment page association */
/* 7.2.7 Segment data length */
if (sip->pageassocsizeflag)
- xfseek(fip->file, 8, SEEK_CUR, fip->filepath);
+ xfseeko(fip->file, 8, SEEK_CUR, fip->filepath);
else
- xfseek(fip->file, 5, SEEK_CUR, fip->filepath);
+ xfseeko(fip->file, 5, SEEK_CUR, fip->filepath);
/* ---- at end of segment header ---- */
}
@ @c
-static unsigned long findstreamstart(FILEINFO * fip)
+static off_t findstreamstart(FILEINFO * fip)
{
SEGINFO tmp;
assert(!fip->sequentialaccess); /* D.2 Random-access organisation */
@@ -634,8 +635,8 @@ static unsigned long findstreamstart(FILEINFO * fip)
@ @c
static void rd_jbig2_info(FILEINFO * fip)
{
- unsigned long seekdist = 0; /* for sequential-access only */
- unsigned long streampos = 0; /* for random-access only */
+ off_t seekdist = 0; /* for sequential-access only */
+ off_t streampos = 0; /* for random-access only */
unsigned long currentpage = 0;
boolean sipavail = false;
PAGEINFO *pip;
@@ -679,8 +680,8 @@ static void rd_jbig2_info(FILEINFO * fip)
sip->dataend = sip->datastart + sip->segdatalen;
if (!fip->sequentialaccess
&& (sip->pageinfoflag || sip->endofstripeflag))
- xfseeko(fip->file, (off_t) sip->datastart, SEEK_SET, fip->filepath);
- seekdist = sip->segdatalen;
+ xfseeko(fip->file, sip->datastart, SEEK_SET, fip->filepath);
+ seekdist = (off_t) sip->segdatalen;
/* 7.4.8 Page information segment syntax */
if (sip->pageinfoflag) {
pip->pagenum = (unsigned long) sip->segpage;
@@ -699,11 +700,11 @@ static void rd_jbig2_info(FILEINFO * fip)
}
if (!fip->sequentialaccess
&& (sip->pageinfoflag || sip->endofstripeflag))
- xfseeko(fip->file, (off_t) sip->hdrend, SEEK_SET, fip->filepath);
+ xfseeko(fip->file, sip->hdrend, SEEK_SET, fip->filepath);
if (!fip->sequentialaccess)
streampos += sip->segdatalen;
if (fip->sequentialaccess)
- xfseeko(fip->file, (off_t) seekdist, SEEK_CUR, fip->filepath);
+ xfseeko(fip->file, seekdist, SEEK_CUR, fip->filepath);
if (sip->endofpageflag && currentpage && (pip->stripinginfo >> 15))
pip->height = pip->stripedheight;
}
@@ -719,7 +720,7 @@ static void wr_jbig2(PDF pdf, FILEINFO * fip, unsigned long page)
LITEM *slip;
PAGEINFO *pip;
SEGINFO *sip;
- unsigned long i;
+ off_t i;
if (page > 0) {
pip = find_pageinfo(&(fip->pages), page);
assert(pip != NULL);
@@ -752,10 +753,10 @@ static void wr_jbig2(PDF pdf, FILEINFO * fip, unsigned long page)
for (slip = pip->segments.first; slip != NULL; slip = slip->next) { /* loop over page segments */
sip = slip->d;
if (sip->isrefered || page > 0) {
- xfseeko(fip->file, (off_t) sip->hdrstart, SEEK_SET, fip->filepath);
+ xfseeko(fip->file, sip->hdrstart, SEEK_SET, fip->filepath);
/* mark refered-to page 0 segments, change segpages > 1 to 1 */
writeseghdr(pdf, fip, sip);
- xfseeko(fip->file, (off_t) sip->datastart, SEEK_SET, fip->filepath);
+ xfseeko(fip->file, sip->datastart, SEEK_SET, fip->filepath);
for (i = sip->datastart; i < sip->dataend; i++)
pdf_out(pdf, ygetc(fip->file));
}