From fc5971d795c43bd9c8f07559e6cbc8e0e8b62dbf Mon Sep 17 00:00:00 2001 From: Hironobu Yamashita Date: Sun, 25 Nov 2018 14:29:11 +0000 Subject: dviout-util: version 20181125 git-svn-id: svn://tug.org/texlive/trunk@49247 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dviout-util/ChangeLog | 25 +++ Build/source/texk/dviout-util/Makefile.am | 26 ++- Build/source/texk/dviout-util/Makefile.in | 22 +-- Build/source/texk/dviout-util/chkdvifont.c | 2 +- Build/source/texk/dviout-util/configure | 22 +-- Build/source/texk/dviout-util/configure.ac | 2 +- Build/source/texk/dviout-util/dvispc-en.txt | 4 +- Build/source/texk/dviout-util/dvispc-ja.txt | 4 +- Build/source/texk/dviout-util/dvispc.c | 194 +++++++++++------------ Build/source/texk/dviout-util/dvispc.man | 4 +- Build/source/texk/dviout-util/dvispc.test | 32 +++- Build/source/texk/dviout-util/tests/first.dry | 9 ++ Build/source/texk/dviout-util/tests/firstpn.dry | 2 + Build/source/texk/dviout-util/tests/oldindep.dry | 8 + Build/source/texk/dviout-util/tests/reverse.dry | 23 +++ Build/source/texk/dviout-util/tests/tpicpn.dry | 10 ++ Build/source/texk/dviout-util/tests/tpicsh.dry | 2 + Build/source/texk/dviout-util/tests/under.dvi | Bin 0 -> 1728 bytes Build/source/texk/dviout-util/tests/under.tex | 44 +++++ Build/source/texk/dviout-util/tests/underout.dvi | Bin 0 -> 1832 bytes 20 files changed, 297 insertions(+), 138 deletions(-) create mode 100644 Build/source/texk/dviout-util/tests/first.dry create mode 100644 Build/source/texk/dviout-util/tests/firstpn.dry create mode 100644 Build/source/texk/dviout-util/tests/oldindep.dry create mode 100644 Build/source/texk/dviout-util/tests/reverse.dry create mode 100644 Build/source/texk/dviout-util/tests/tpicpn.dry create mode 100644 Build/source/texk/dviout-util/tests/tpicsh.dry create mode 100644 Build/source/texk/dviout-util/tests/under.dvi create mode 100644 Build/source/texk/dviout-util/tests/under.tex create mode 100644 Build/source/texk/dviout-util/tests/underout.dvi diff --git a/Build/source/texk/dviout-util/ChangeLog b/Build/source/texk/dviout-util/ChangeLog index c3e836f9182..7dc6c14888d 100644 --- a/Build/source/texk/dviout-util/ChangeLog +++ b/Build/source/texk/dviout-util/ChangeLog @@ -1,3 +1,28 @@ +2018-11-25 Hironobu Yamashita + + * configure.ac: Version 20181125. + +2018-11-10 Hironobu Yamashita + + * dvispc.c, dvispc.man, dvispc-{ja,en}.txt: Better help message. + +2018-10-16 Hironobu Yamashita + + * dvispc.test: Add tests for underflow. + * tests/under.{tex,dvi}, tests/underout.dvi: New tests. + * Makefile.am: Adjusted. + +2018-10-15 Hironobu Yamashita + + * dvispc.c: Use common routine for EXE2MODIFY and EXE2CHECK + for simplicity. + * dvispc.test: Add tests for consistency between EXE2MODIFY + and EXE2CHECK. + * tests/oldindep.dry, tests/tpicpn.dry, tests/tpicsh.dry, + tests/reverse.dry, tests/first.dry, tests/firstpn.dry: + New tests. + * Makefile.am: Adjusted. + 2018-10-14 Hironobu Yamashita * dvispc.c: Fix a bug that modification of non-stack diff --git a/Build/source/texk/dviout-util/Makefile.am b/Build/source/texk/dviout-util/Makefile.am index 8f7ea28287e..8aab6bd3cc0 100644 --- a/Build/source/texk/dviout-util/Makefile.am +++ b/Build/source/texk/dviout-util/Makefile.am @@ -31,18 +31,32 @@ EXTRA_DIST = $(TESTS) ## dvispc.test EXTRA_DIST += tests/oldindep.spc \ - tests/oldindep.tex tests/oldindep.dvi tests/oldindepout.dvi \ - tests/tpicpn.tex tests/tpicpn.dvi tests/tpicpnout.dvi \ + tests/oldindep.tex tests/oldindep.dvi \ + tests/oldindep.dry tests/oldindepout.dvi \ + tests/under.tex tests/under.dvi \ + tests/underout.dvi \ + tests/tpicpn.tex tests/tpicpn.dvi \ + tests/tpicpn.dry tests/tpicpnout.dvi \ tests/tpicsh.tex tests/tpicsh.dvi \ - tests/reverse.tex tests/reverse.dvi tests/reverseout.dvi \ - tests/first.tex tests/first.dvi tests/firstout.dvi \ + tests/tpicsh.dry \ + tests/reverse.tex tests/reverse.dvi \ + tests/reverse.dry tests/reverseout.dvi \ + tests/first.tex tests/first.dvi \ + tests/first.dry tests/firstout.dvi \ tests/firstpn.tex tests/firstpn.dvi \ + tests/firstpn.dry \ tests/annot.tex tests/annot.dvi \ tests/longspec.tex tests/longspec.dvi \ tests/flatnest.tex tests/flatnest.dvi DISTCLEANFILES = x*oldindep.spc \ - x*oldindepa.txt x*oldindepax.dvi x*oldindepout.dvi \ - x*tpicpnout.dvi x*reverseout.dvi x*firstout.dvi \ + x*oldindepa.txt x*oldindepax.dvi \ + x*oldindep.dry x*oldindepout.dvi \ + x*underout.dvi \ + x*tpicpn.dry x*tpicpnout.dvi \ + x*tpicsh.dry \ + x*reverse.dry x*reverseout.dvi \ + x*first.dry x*firstout.dvi \ + x*firstpn.dry \ x*write.dvi x*writeout.dvi ## chkdvifont.test diff --git a/Build/source/texk/dviout-util/Makefile.in b/Build/source/texk/dviout-util/Makefile.in index ee034add300..4b7bfc74a78 100644 --- a/Build/source/texk/dviout-util/Makefile.in +++ b/Build/source/texk/dviout-util/Makefile.in @@ -560,21 +560,25 @@ dvispc_LDADD = $(PTEXENC_LIBS) $(LDADD) dist_man1_MANS = dvispc.man chkdvifont.man TESTS = dvispc.test chkdvifont.test EXTRA_DIST = $(TESTS) tests/oldindep.spc tests/oldindep.tex \ - tests/oldindep.dvi tests/oldindepout.dvi tests/tpicpn.tex \ - tests/tpicpn.dvi tests/tpicpnout.dvi tests/tpicsh.tex \ - tests/tpicsh.dvi tests/reverse.tex tests/reverse.dvi \ - tests/reverseout.dvi tests/first.tex tests/first.dvi \ - tests/firstout.dvi tests/firstpn.tex tests/firstpn.dvi \ + tests/oldindep.dvi tests/oldindep.dry tests/oldindepout.dvi \ + tests/under.tex tests/under.dvi tests/underout.dvi \ + tests/tpicpn.tex tests/tpicpn.dvi tests/tpicpn.dry \ + tests/tpicpnout.dvi tests/tpicsh.tex tests/tpicsh.dvi \ + tests/tpicsh.dry tests/reverse.tex tests/reverse.dvi \ + tests/reverse.dry tests/reverseout.dvi tests/first.tex \ + tests/first.dvi tests/first.dry tests/firstout.dvi \ + tests/firstpn.tex tests/firstpn.dvi tests/firstpn.dry \ tests/annot.tex tests/annot.dvi tests/longspec.tex \ tests/longspec.dvi tests/flatnest.tex tests/flatnest.dvi \ tests/oldindep.cfn tests/jis.tfm tests/jis.cfn \ tests/eufm10.tfm tests/eufm10.cfn tests/cmr10.pk \ tests/cmr10.cfn tests/upjisr-h.vf tests/upsjir-h.cfn DISTCLEANFILES = x*oldindep.spc x*oldindepa.txt x*oldindepax.dvi \ - x*oldindepout.dvi x*tpicpnout.dvi x*reverseout.dvi \ - x*firstout.dvi x*write.dvi x*writeout.dvi oldindep.dvi \ - xoldindep.cfn xjis.cfn xeufm10.cfn xeufm10.ed.cfn xcmr10.cfn \ - xupjisr-h.cfn + x*oldindep.dry x*oldindepout.dvi x*underout.dvi x*tpicpn.dry \ + x*tpicpnout.dvi x*tpicsh.dry x*reverse.dry x*reverseout.dvi \ + x*first.dry x*firstout.dvi x*firstpn.dry x*write.dvi \ + x*writeout.dvi oldindep.dvi xoldindep.cfn xjis.cfn xeufm10.cfn \ + xeufm10.ed.cfn xcmr10.cfn xupjisr-h.cfn all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/Build/source/texk/dviout-util/chkdvifont.c b/Build/source/texk/dviout-util/chkdvifont.c index 4732f52e960..499bd0deb45 100644 --- a/Build/source/texk/dviout-util/chkdvifont.c +++ b/Build/source/texk/dviout-util/chkdvifont.c @@ -1266,7 +1266,7 @@ void usage() exit(1); show: - fprintf(stderr, + fprintf(stderr, "\n\n" #endif "Errorlevel is the sum of the following number\n" "\t 1: cmbsy5-9, cmcsc8-9, cmex7-9, cmmib5-9\n" diff --git a/Build/source/texk/dviout-util/configure b/Build/source/texk/dviout-util/configure index 365bb621ac5..4a9dca566f7 100755 --- a/Build/source/texk/dviout-util/configure +++ b/Build/source/texk/dviout-util/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for dviout-util (TeX Live) 20181014. +# Generated by GNU Autoconf 2.69 for dviout-util (TeX Live) 20181125. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dviout-util (TeX Live)' PACKAGE_TARNAME='dviout-util--tex-live-' -PACKAGE_VERSION='20181014' -PACKAGE_STRING='dviout-util (TeX Live) 20181014' +PACKAGE_VERSION='20181125' +PACKAGE_STRING='dviout-util (TeX Live) 20181125' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1332,7 +1332,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dviout-util (TeX Live) 20181014 to adapt to many kinds of systems. +\`configure' configures dviout-util (TeX Live) 20181125 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1403,7 +1403,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dviout-util (TeX Live) 20181014:";; + short | recursive ) echo "Configuration of dviout-util (TeX Live) 20181125:";; esac cat <<\_ACEOF @@ -1524,7 +1524,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dviout-util (TeX Live) configure 20181014 +dviout-util (TeX Live) configure 20181125 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2180,7 +2180,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dviout-util (TeX Live) $as_me 20181014, which was +It was created by dviout-util (TeX Live) $as_me 20181125, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -7865,7 +7865,7 @@ fi # Define the identity of the package. PACKAGE='dviout-util--tex-live-' - VERSION='20181014' + VERSION='20181125' cat >>confdefs.h <<_ACEOF @@ -13891,7 +13891,7 @@ Usage: $0 [OPTIONS] Report bugs to ." lt_cl_version="\ -dviout-util (TeX Live) config.lt 20181014 +dviout-util (TeX Live) config.lt 20181125 configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. @@ -15496,7 +15496,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dviout-util (TeX Live) $as_me 20181014, which was +This file was extended by dviout-util (TeX Live) $as_me 20181125, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15562,7 +15562,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dviout-util (TeX Live) config.status 20181014 +dviout-util (TeX Live) config.status 20181125 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/texk/dviout-util/configure.ac b/Build/source/texk/dviout-util/configure.ac index eca9fa8d0ad..16e5e46f363 100644 --- a/Build/source/texk/dviout-util/configure.ac +++ b/Build/source/texk/dviout-util/configure.ac @@ -6,7 +6,7 @@ dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl -AC_INIT([dviout-util (TeX Live)], [20181014], [tex-k@tug.org]) +AC_INIT([dviout-util (TeX Live)], [20181125], [tex-k@tug.org]) AC_PREREQ([2.65]) AC_CONFIG_SRCDIR([dvispc.c]) AC_CONFIG_AUX_DIR([../../build-aux]) diff --git a/Build/source/texk/dviout-util/dvispc-en.txt b/Build/source/texk/dviout-util/dvispc-en.txt index d1f2f32c637..82beba9e052 100644 --- a/Build/source/texk/dviout-util/dvispc-en.txt +++ b/Build/source/texk/dviout-util/dvispc-en.txt @@ -10,8 +10,8 @@ Usage: dvispc [-c] [-bvz] input_dvi_file [output_dvi_file] dvispc -x[..] [-ltv][-r..] [input_text_file] output_dvi_file Mode options: - -c: make page-indepent DVI in specials (default) - -d: check page-independence + -c: correct input DVI to be page-indepent in specials (default) + -d: dry run to check page-independence -s: show specials -a: translate DVI to Text -x: translate Text to DVI (-x0:str0 1:chkfnt 2:variety) diff --git a/Build/source/texk/dviout-util/dvispc-ja.txt b/Build/source/texk/dviout-util/dvispc-ja.txt index 9c1e093077b..7e1b0ade312 100644 --- a/Build/source/texk/dviout-util/dvispc-ja.txt +++ b/Build/source/texk/dviout-util/dvispc-ja.txt @@ -10,8 +10,8 @@ Usage: dvispc [-c] [-bvz] input_dvi_file [output_dvi_file] dvispc -x[..] [-ltv][-r..] [input_text_file] output_dvi_file Mode options: - -c: make page-indepent DVI in specials (default) - -d: check page-independence + -c: correct input DVI to be page-indepent in specials (default) + -d: dry run to check page-independence -s: show specials -a: translate DVI to Text -x: translate Text to DVI (-x0:str0 1:chkfnt 2:variety) diff --git a/Build/source/texk/dviout-util/dvispc.c b/Build/source/texk/dviout-util/dvispc.c index 914e7fca8d2..00472045ce1 100644 --- a/Build/source/texk/dviout-util/dvispc.c +++ b/Build/source/texk/dviout-util/dvispc.c @@ -248,6 +248,7 @@ int f_book = 0; /* multiple of four pages */ int f_ptex = 0; int f_prescan = 0; +int f_last = 0; int max_stack; char *out_pages ="T-L"; int total_book_page; @@ -441,8 +442,8 @@ void usage(int ex) #endif " dvispc -x[..] [-ltv][-r..] [input_text_file] output_dvi_file\n\n" "Mode options:\n" - " -c: make page-indepent DVI in specials (default)\n" - " -d: check page-independence\n" + " -c: correct input DVI to be page-indepent in specials (default)\n" + " -d: dry run to check page-independence\n" " -s: show specials\n" " -a: translate DVI to Text\n" " -x: translate Text to DVI (-x0:str0 1:chkfnt 2:variety)\n\n" @@ -802,6 +803,10 @@ void write_sp(FILE *fp, char *sp) int len; len = strlen(sp); + if(f_debug) + fprintf(fp_out, "%s", sp); + if(f_mode != EXE2MODIFY || f_last) + return; /* dry-run for EXE2CHECK */ if(len <= 0xff) fprintf(fp, "%c%c%s", XXX1, len, sp); else if(len <= 0xffffffff){ @@ -813,6 +818,15 @@ void write_sp(FILE *fp, char *sp) Exit(1); } } +void write_sp_nodebug(FILE *fp, char *sp) +{ /* omit debug message (for backward compatibility) */ + if(f_debug){ + f_debug = 0; /* disable debug printing temporarily */ + write_sp(fp, sp); + f_debug = 1; + }else + write_sp(fp, sp); +} void translate(DVIFILE_INFO *dvi, DIMENSION *dim) @@ -831,6 +845,7 @@ void translate(DVIFILE_INFO *dvi, DIMENSION *dim) fp = NULL; f_needs_corr = flag = 0; + f_last = 0; if(f_mode == EXE2TEXT || f_mode == EXE2SPECIAL){ while(out_pages && *out_pages){ @@ -916,148 +931,125 @@ lastpage: if(isdigit(*++out_pages)){ pos = position of EOP + 1 */ if(f_debug){ /* EXE2CHECK always falls into this */ fprintf(fp_out, "[%d]", page); - flag = color_depth; - flag += pdf_color_depth; - flag += pdf_annot_depth; - if(background[0] && !f_background){ - if(!background_prev[0]) /* assume white */ - fprintf(fp_out, "\nbackground gray 1"); - else - fprintf(fp_out, "\n%s", background_prev); - flag++; - } - if(pdf_bgcolor[0] && !f_pdf_bgcolor){ - if(!pdf_bgcolor_prev[0]) /* assume white */ - fprintf(fp_out, "\npdf:bgcolor [1]"); - else - fprintf(fp_out, "\n%s", pdf_bgcolor_prev); - flag++; - } - for(count = 0; count < color_depth; count++) - fprintf(fp_out, "\n%d:%s", count+1, color_pt[count]); - for(count = 0; count < pdf_color_depth; count++) - fprintf(fp_out, "\n%d:%s", count+1, pdf_color_pt[count]); - for(count = 0; count < pdf_annot_depth; count++) - fprintf(fp_out, "\n%d:%s", count+1, pdf_annot_pt[count]); - if(f_pn < 0){ - if(!tpic_pn_prev[0]) - fprintf(stderr, "Cannot find valid tpic pn.\n" - "Please check your LaTeX source.\n"); - else{ - fprintf(fp_out, "\n%s", tpic_pn_prev); - flag++; - } - } - if(flag){ - fprintf(fp_out, "\n"); /* at least one special printed */ - f_needs_corr += flag; - } - } - if(f_mode == EXE2CHECK){ - if(background[0] && f_background) /* save current status of background */ - strncpy(background_prev, background, MAX_LEN); - if(pdf_bgcolor[0] && f_pdf_bgcolor) /* save current status of pdf_bgcolor */ - strncpy(pdf_bgcolor_prev, pdf_bgcolor, MAX_LEN); - if(tpic_pn[0]) /* save current status of tpic_pn */ - strncpy(tpic_pn_prev, tpic_pn, MAX_LEN); - continue; /* skip loop if (f_mode == EXE2CHECK); - * remainings in this loop are for (f_mode == EXE2MODIFY) */ + flag = f_needs_corr; /* reserved for later check */ } - /* [Process 2] At the beginning of each page, - put non-stack specials if necessary. + /* [Process 2] Before writing the current page, handle non-stack specials. + * If not found but necessary, put one. + * If found, save current status before going back to the loop head + for the next page (= scanning the whole next page might overwrite it!). Also, if the page is suffering from stack underflow, - open lacking stacks beforehand */ + open lacking stacks beforehand. */ while(color_under > 0){ /* recover underflow of color stack */ - write_sp(fp, "color push Black"); + write_sp_nodebug(fp, "color push Black"); f_needs_corr++; color_under--; } while(pdf_color_under > 0){ /* recover underflow of pdf:bcolor ... pdf:ecolor stack */ - write_sp(fp, "pdf:bcolor [0]"); + write_sp_nodebug(fp, "pdf:bcolor [0]"); f_needs_corr++; pdf_color_under--; } - if(background[0] && !f_background){ /* background from the former page is effective */ - if(!background_prev[0]) /* assume white */ - write_sp(fp, "background gray 1"); - else - write_sp(fp, background_prev); - f_needs_corr++; + if(background[0]){ /* background used somewhere */ + if(!f_background){ /* no background in this page */ + if(f_debug) fprintf(fp_out, "\n"); + if(!background_prev[0]) /* assume white */ + write_sp(fp, "background gray 1"); + else + write_sp(fp, background_prev); + f_needs_corr++; + }else /* this page had one! */ + strncpy(background_prev, background, MAX_LEN); /* save current */ } - if(pdf_bgcolor[0] && !f_pdf_bgcolor){ /* pdf:bgcolor from the former page is effective */ - if(!pdf_bgcolor_prev[0]) /* assume white */ - write_sp(fp, "pdf:bgcolor [1]"); - else - write_sp(fp, pdf_bgcolor_prev); - f_needs_corr++; + if(pdf_bgcolor[0]){ /* pdf:bgcolor used somewhere */ + if(!f_pdf_bgcolor){ /* no pdf:bgcolor in this page */ + if(f_debug) fprintf(fp_out, "\n"); + if(!pdf_bgcolor_prev[0]) /* assume white */ + write_sp(fp, "pdf:bgcolor [1]"); + else + write_sp(fp, pdf_bgcolor_prev); + f_needs_corr++; + }else /* this page had one! */ + strncpy(pdf_bgcolor_prev, pdf_bgcolor, MAX_LEN); /* save current */ } // while(pdf_annot_under > 0){ /* recover underflow of pdf:bann ... pdf:eann stack */ // /* [TODO] what should we do here? */ // f_needs_corr++; // pdf_annot_under--; // } - if(f_pn < 0) { /* tpic_pn from the former page is effective */ - if(!tpic_pn_prev[0]) + if(f_pn < 0) { /* tpic_pn from the former page should be effective ... */ + if(!tpic_pn_prev[0]) /* ... but nothing found before */ fprintf(stderr, "\nCannot find valid tpic pn." "\nPlease check your LaTeX source."); - else{ + else{ /* ... OK */ + if(f_debug) fprintf(fp_out, "\n"); write_sp(fp, tpic_pn_prev); f_needs_corr++; } } + if(tpic_pn[0] && f_pn) /* tpic_pn used in this page */ + strncpy(tpic_pn_prev, tpic_pn, MAX_LEN); /* save current */ - /* [Process 3] write contents of the current page */ - fseek(dvi->file_ptr, dim->page_index[page]+45, SEEK_SET); - for(size = pos - dim->page_index[page] - 46; size > 0; size--) - write_byte(read_byte(dvi->file_ptr), fp); + /* [Process 3] Write contents of the current page. */ + if(f_mode == EXE2MODIFY){ + fseek(dvi->file_ptr, dim->page_index[page]+45, SEEK_SET); + for(size = pos - dim->page_index[page] - 46; size > 0; size--) + write_byte(read_byte(dvi->file_ptr), fp); + } - /* [Process 4] at the end of page, - close not-yet-closed stacks */ + /* [Process 4] After writing the current page, + close not-yet-closed stacks. */ for(count = 0; count < color_depth; count++){ - write_sp(fp, "color pop"); + write_sp_nodebug(fp, "color pop"); f_needs_corr++; } for(count = 0; count < pdf_color_depth; count++){ - write_sp(fp, "pdf:ecolor"); + write_sp_nodebug(fp, "pdf:ecolor"); f_needs_corr++; } // for(count = 0; count < pdf_annot_depth; count++){ -// write_sp(fp, "pdf:eann"); +// write_sp_nodebug(fp, "pdf:eann"); // f_needs_corr++; // } - write_byte((uchar)EOP, fp); /* write EOP */ - former = current; - current = ftell(fp); /* get position of BOP/POST */ + if(f_mode == EXE2MODIFY){ + write_byte((uchar)EOP, fp); /* write EOP */ + former = current; + current = ftell(fp); /* get position of BOP/POST */ + } + + if(page == dim->total_page) + f_last = 1; /* reached the last page, change behavior of write_sp(fp,sp) */ - /* [Process 5] except for the last page, - start the next page with passing not-yet-closed stacks */ - if(page < dim->total_page){ + /* [Process 5] Except for the last page, + start the next page with passing not-yet-closed stacks. */ + if(f_mode == EXE2MODIFY && !f_last){ fseek(dvi->file_ptr, dim->page_index[page+1], SEEK_SET); for(size = 41; size > 0; size--) /* write BOP and c[] */ write_byte(read_byte(dvi->file_ptr), fp); write_long(former, fp); /* position of BOP of the former page */ - for(count = 0; count < color_depth; count++) - write_sp(fp, color_pt[count]); - for(count = 0; count < pdf_color_depth; count++) - write_sp(fp, pdf_color_pt[count]); -// for(count = 0; count < pdf_annot_depth; count++) -// write_sp(fp, pdf_annot_pt[count]); - f_needs_corr += color_depth; - f_needs_corr += pdf_color_depth; -// f_needs_corr += pdf_annot_depth; - /* Save current status of now, before it is (probably) - overwritten after scanning the whole next page. */ - if(background[0] && f_background) /* save current status of background */ - strncpy(background_prev, background, MAX_LEN); - if(pdf_bgcolor[0] && f_pdf_bgcolor) /* save current status of pdf_bgcolor */ - strncpy(pdf_bgcolor_prev, pdf_bgcolor, MAX_LEN); - if(tpic_pn[0]) /* save current status of tpic_pn */ - strncpy(tpic_pn_prev, tpic_pn, MAX_LEN); } + for(count = 0; count < color_depth; count++){ + if(f_debug) fprintf(fp_out, "\n%d:", count+1); + write_sp(fp, color_pt[count]); + } + for(count = 0; count < pdf_color_depth; count++){ + if(f_debug) fprintf(fp_out, "\n%d:", count+1); + write_sp(fp, pdf_color_pt[count]); + } +// for(count = 0; count < pdf_annot_depth; count++){ +// if(f_debug) fprintf(fp_out, "\n%d:", count+1); +// write_sp(fp, pdf_annot_pt[count]); +// } + /* f_needs_corr already set properly in [Process 4] */ + + if(f_debug){ /* EXE2CHECK always falls into this */ + if(flag != f_needs_corr) /* at least one special printed for debug */ + fprintf(fp_out, "\n"); + } + f_last = 0; /* restore write_sp(fp,sp) */ } /* page loop end */ - if(f_debug) { + if(f_debug) { /* EXE2CHECK always falls into this */ if(color_depth_max) fprintf(fp_out, "\nMaximal depth of color stack:%d", color_depth_max); if(pdf_color_depth_max) diff --git a/Build/source/texk/dviout-util/dvispc.man b/Build/source/texk/dviout-util/dvispc.man index 0c73de6aa4f..99e3a896b81 100644 --- a/Build/source/texk/dviout-util/dvispc.man +++ b/Build/source/texk/dviout-util/dvispc.man @@ -26,10 +26,10 @@ dvispc \- Modify a DVI file to be page-independent in specials is a utility to modify/edit \*(TX DVI file with the following features: .PP Mode option \fB\-c\fR (default): - modify an input DVI to be page-independent in specials (default) + correct an input DVI to be page-independent in specials (default) .PP Mode option \fB\-d\fR: - check if an input DVI is page-independent in specials + dry run to check if an input DVI is page-independent in specials .PP Mode option \fB\-s\fR: show all specials in the input DVI diff --git a/Build/source/texk/dviout-util/dvispc.test b/Build/source/texk/dviout-util/dvispc.test index 41ed78c8138..c111dde13e5 100755 --- a/Build/source/texk/dviout-util/dvispc.test +++ b/Build/source/texk/dviout-util/dvispc.test @@ -49,7 +49,10 @@ diff --strip-trailing-cr $testdir/oldindep.spc $testdir/oldindep.spc \ cmp $testdir/oldindep.dvi x3oldindepax.dvi && echo || exit 7 -## EXE2INDEP +## EXE2MODIFY & EXE2CHECK (should be consistent) + +./dvispc -d $testdir/oldindep.dvi >x0oldindep.dry + diff $diffoptCRLF $testdir/oldindep.dry x0oldindep.dry && echo || exit 1 ./dvispc -c $testdir/oldindep.dvi x0oldindepout.dvi && \ cmp $testdir/oldindepout.dvi x0oldindepout.dvi && echo || exit 1 @@ -75,6 +78,13 @@ diff --strip-trailing-cr $testdir/oldindep.spc $testdir/oldindep.spc \ # ./dvispc x3write.dvi # cmp $testdir/oldindepout.dvi x3write.dvi && echo || exit 5 +## case of underflow +./dvispc $testdir/under.dvi x0underout.dvi && \ + cmp $testdir/underout.dvi x0underout.dvi && echo || exit 6 +rm -f x1underout.dvi +./dvispc x0underout.dvi x1underout.dvi && \ + if test -f x1underout.dvi; then exit 1; else echo; fi || exit 6 + ./dvispc && echo || exit 0 # the following tests will not pass for old version written by SHIMA. @@ -82,39 +92,55 @@ diff --strip-trailing-cr $testdir/oldindep.spc $testdir/oldindep.spc \ # exit code 1 for usage without argument. (the above line did it!) # correction for tpicpn.dvi is needed but should be minimal +./dvispc -d $testdir/tpicpn.dvi >x0tpicpn.dry + diff $diffoptCRLF $testdir/tpicpn.dry x0tpicpn.dry && echo || exit 1 ./dvispc $testdir/tpicpn.dvi x0tpicpnout.dvi && \ cmp $testdir/tpicpnout.dvi x0tpicpnout.dvi && echo || exit 1 # correction for tpicsh.dvi is never needed, check no output +./dvispc -d $testdir/tpicsh.dvi >x0tpicsh.dry + diff $diffoptCRLF $testdir/tpicsh.dry x0tpicsh.dry && echo || exit 1 rm -f x0tpicshout.dvi ./dvispc $testdir/tpicsh.dvi x0tpicshout.dvi && \ - if test -f x0tpicshout.dvi; then exit 1; else echo; fi + if test -f x0tpicshout.dvi; then exit 1; else echo; fi || exit 1 ## page independence in reverse order which requires prior scanning +./dvispc -d $testdir/reverse.dvi >xreverse.dry + diff $diffoptCRLF $testdir/reverse.dry xreverse.dry && echo || exit 1 ./dvispc $testdir/reverse.dvi xreverseout.dvi && \ cmp $testdir/reverseout.dvi xreverseout.dvi && echo || exit 1 # prior scanning should not mess up +./dvispc -d $testdir/first.dvi >xfirst.dry + diff $diffoptCRLF $testdir/first.dry xfirst.dry && echo || exit 1 ./dvispc $testdir/first.dvi xfirstout.dvi && \ cmp $testdir/firstout.dvi xfirstout.dvi && echo || exit 1 # prior scanning should not mess up (no correction) +./dvispc -d $testdir/firstpn.dvi >xfirstpn.dry + diff $diffoptCRLF $testdir/firstpn.dry xfirstpn.dry && echo || exit 1 rm -f xfirstpn.dvi ./dvispc $testdir/firstpn.dvi xfirstpn.dvi && \ - if test -f xfirstpn.dvi; then exit 1; else echo; fi + if test -f xfirstpn.dvi; then exit 1; else echo; fi || exit 1 # ==== future work start ==== ## page independence of annotation +#./dvispc -d $testdir/annot.dvi >xannot.dry +# diff $diffoptCRLF $testdir/annot.dry xannot.dry && echo || exit 2 #./dvispc $testdir/annot.dvi xannotout.dvi && \ # cmp $testdir/annotout.dvi xannotout.dvi && echo || exit 2 ## page independence of long (>255) specials (e.g. annotation) ## disabled because annotation is unsupported +#./dvispc -d $testdir/longspec.dvi >xlongspec.dry +# diff $diffoptCRLF $testdir/longspec.dry xlongspec.dry && echo || exit 3 #./dvispc $testdir/longspec.dvi xlongspecout.dvi && \ # cmp $testdir/longspecout.dvi xlongspecout.dvi && echo || exit 3 ## flatten nested anotation +#./dvispc -d $testdir/flatnest.dvi >xflatnest.dry +# diff $diffoptCRLF $testdir/flatnest.dry xflatnest.dry && echo || exit 3 #./dvispc $testdir/flatnest.dvi xflatnestout.dvi && \ # cmp $testdir/flatnestout.dvi xflatnestout.dvi && echo || exit 4 diff --git a/Build/source/texk/dviout-util/tests/first.dry b/Build/source/texk/dviout-util/tests/first.dry new file mode 100644 index 00000000000..dcec345d2d6 --- /dev/null +++ b/Build/source/texk/dviout-util/tests/first.dry @@ -0,0 +1,9 @@ +[1] +background gray 1 +[2] +background gray 1 +[3][4] +background rgb 1 0 0 + +Maximal depth of color stack:1 +Some corrections are necessary! diff --git a/Build/source/texk/dviout-util/tests/firstpn.dry b/Build/source/texk/dviout-util/tests/firstpn.dry new file mode 100644 index 00000000000..3ae55bc2193 --- /dev/null +++ b/Build/source/texk/dviout-util/tests/firstpn.dry @@ -0,0 +1,2 @@ +[1][2][3] +No modification is necessary diff --git a/Build/source/texk/dviout-util/tests/oldindep.dry b/Build/source/texk/dviout-util/tests/oldindep.dry new file mode 100644 index 00000000000..4c6efd4245f --- /dev/null +++ b/Build/source/texk/dviout-util/tests/oldindep.dry @@ -0,0 +1,8 @@ +[1][2] +background rgb 1 0 0 +1:color push rgb 0 0 1 +[3][4] +background gray 1 + +Maximal depth of color stack:2 +Some corrections are necessary! diff --git a/Build/source/texk/dviout-util/tests/reverse.dry b/Build/source/texk/dviout-util/tests/reverse.dry new file mode 100644 index 00000000000..441aa3ccb2b --- /dev/null +++ b/Build/source/texk/dviout-util/tests/reverse.dry @@ -0,0 +1,23 @@ +[1] +background gray 1 +[2] +background gray 1 +[3][4] +background rgb 1 0 0 +[5] +background rgb 1 0 0 +[6][7] +background gray 1 +[8] +background gray 1 +1:color push rgb 1 0 0 +[9] +background gray 1 +1:color push rgb 1 0 0 +[10] +background gray 1 +[11] +background gray 1 + +Maximal depth of color stack:2 +Some corrections are necessary! diff --git a/Build/source/texk/dviout-util/tests/tpicpn.dry b/Build/source/texk/dviout-util/tests/tpicpn.dry new file mode 100644 index 00000000000..46c0cd9d1cc --- /dev/null +++ b/Build/source/texk/dviout-util/tests/tpicpn.dry @@ -0,0 +1,10 @@ +[1][2] +pn 30 +[3][4][5] +pn 5 +[6][7][8] +pn 30 +[9] +pn 30 + +Some corrections are necessary! diff --git a/Build/source/texk/dviout-util/tests/tpicsh.dry b/Build/source/texk/dviout-util/tests/tpicsh.dry new file mode 100644 index 00000000000..2c3dc2fb4ad --- /dev/null +++ b/Build/source/texk/dviout-util/tests/tpicsh.dry @@ -0,0 +1,2 @@ +[1][2] +No modification is necessary diff --git a/Build/source/texk/dviout-util/tests/under.dvi b/Build/source/texk/dviout-util/tests/under.dvi new file mode 100644 index 00000000000..7bd73f99619 Binary files /dev/null and b/Build/source/texk/dviout-util/tests/under.dvi differ diff --git a/Build/source/texk/dviout-util/tests/under.tex b/Build/source/texk/dviout-util/tests/under.tex new file mode 100644 index 00000000000..79b640f9a94 --- /dev/null +++ b/Build/source/texk/dviout-util/tests/under.tex @@ -0,0 +1,44 @@ +% check underflow +\documentclass{article} +\usepackage[dvips]{color} +\usepackage{atbegshi} +\begin{document} +black +\newpage +\AtBeginShipoutNext{\AtBeginShipoutDiscard} +{\color{red} + start red (but discarded) +\newpage + \AtBeginShipoutNext{\AtBeginShipoutDiscard} + {\color{blue} + start blue (but discarded) +\newpage + \AtBeginShipoutNext{\AtBeginShipoutDiscard} + {\color{green} + start green (but discarded) +\newpage + end green} +\newpage + end blue} +\newpage + end red} +\newpage +black +\newpage +\AtBeginShipoutNext{\AtBeginShipoutDiscard} +{\color{red} + start red (but discarded) + {\color{blue} + start blue (but discarded) +\newpage + end blue} + end red} +\newpage +black +\newpage +{\color{yellow} + start yellow +\newpage + \AtBeginShipoutNext{\AtBeginShipoutDiscard} + end yellow (but discarded)} +\end{document} diff --git a/Build/source/texk/dviout-util/tests/underout.dvi b/Build/source/texk/dviout-util/tests/underout.dvi new file mode 100644 index 00000000000..ab81e58cdd2 Binary files /dev/null and b/Build/source/texk/dviout-util/tests/underout.dvi differ -- cgit v1.2.3