diff options
author | Hironobu Yamashita <h.y.acetaminophen@gmail.com> | 2018-10-13 15:50:11 +0000 |
---|---|---|
committer | Hironobu Yamashita <h.y.acetaminophen@gmail.com> | 2018-10-13 15:50:11 +0000 |
commit | e1bed2de3bcddcea384fcf9f9a14b4e26abbac26 (patch) | |
tree | f649e5bf05455aec4a43f5c5e261aa8b8e14b513 | |
parent | fd5413cde8ad0e1d1ce845be4d88f4c37a1d8b3a (diff) |
import aminophen/dviout-util@66be463
git-svn-id: svn://tug.org/texlive/trunk@48901 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/dviout-util/ChangeLog | 7 | ||||
-rw-r--r-- | Build/source/texk/dviout-util/Makefile.am | 4 | ||||
-rw-r--r-- | Build/source/texk/dviout-util/Makefile.in | 21 | ||||
-rw-r--r-- | Build/source/texk/dviout-util/dvispc.c | 76 | ||||
-rwxr-xr-x | Build/source/texk/dviout-util/dvispc.test | 9 | ||||
-rw-r--r-- | Build/source/texk/dviout-util/tests/tpicpn.dvi | bin | 0 -> 1956 bytes | |||
-rw-r--r-- | Build/source/texk/dviout-util/tests/tpicpn.tex | 84 | ||||
-rw-r--r-- | Build/source/texk/dviout-util/tests/tpicpnout.dvi | bin | 0 -> 1980 bytes | |||
-rw-r--r-- | Build/source/texk/dviout-util/tests/tpicsh.dvi | bin | 0 -> 724 bytes | |||
-rw-r--r-- | Build/source/texk/dviout-util/tests/tpicsh.tex | 41 |
10 files changed, 204 insertions, 38 deletions
diff --git a/Build/source/texk/dviout-util/ChangeLog b/Build/source/texk/dviout-util/ChangeLog index 78ad897718e..04ce0ca6c4e 100644 --- a/Build/source/texk/dviout-util/ChangeLog +++ b/Build/source/texk/dviout-util/ChangeLog @@ -1,3 +1,10 @@ +2018-10-14 Hironobu Yamashita <h.y.acetaminophen@gmail.com> + + * dvispc.c: Fix a bug that modification for tpic_pn was + not working (my previous fault). Minimize correction + for tpic_pn, report effective tpic_pn properly. + * tests/tpicpn.{tex,dvi}, tests/tpicsh.{tex,dvi}: Added. + 2018-10-13 Hironobu Yamashita <h.y.acetaminophen@gmail.com> * dvispc.c: Stop support for pdf:bann, pe:eann which was diff --git a/Build/source/texk/dviout-util/Makefile.am b/Build/source/texk/dviout-util/Makefile.am index 590e6a19eef..1ae55c4b30c 100644 --- a/Build/source/texk/dviout-util/Makefile.am +++ b/Build/source/texk/dviout-util/Makefile.am @@ -32,13 +32,15 @@ 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/tpicsh.tex tests/tpicsh.dvi \ tests/reverse.tex tests/reverse.dvi tests/reverseout.dvi \ 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*reverseout.dvi \ + x*tpicpnout.dvi x*reverseout.dvi \ 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 25ba6730748..a015c5a0db5 100644 --- a/Build/source/texk/dviout-util/Makefile.in +++ b/Build/source/texk/dviout-util/Makefile.in @@ -560,17 +560,18 @@ 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/reverse.tex \ - tests/reverse.dvi tests/reverseout.dvi 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 + 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/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*reverseout.dvi x*write.dvi x*writeout.dvi \ - oldindep.dvi xoldindep.cfn xjis.cfn xeufm10.cfn xeufm10.ed.cfn \ - xcmr10.cfn xupjisr-h.cfn + x*oldindepout.dvi x*tpicpnout.dvi x*reverseout.dvi 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/dvispc.c b/Build/source/texk/dviout-util/dvispc.c index 1f4face7df3..eecd552fdb1 100644 --- a/Build/source/texk/dviout-util/dvispc.c +++ b/Build/source/texk/dviout-util/dvispc.c @@ -253,12 +253,15 @@ char *out_pages ="T-L"; int total_book_page; /* non-stack specials */ -int f_background = 0; char background[MAX_LEN]; -int f_pdf_bgcolor = 0; +int f_background = 0; /* in each page, 0: not found; 1: found */ char pdf_bgcolor[MAX_LEN]; -int f_pn = 0; +int f_pdf_bgcolor = 0; /* in each page, 0: not found; 1: found */ char tpic_pn[MAX_LEN]; +char tpic_pn_prev[MAX_LEN]; +int f_pn = 0; /* in each page, 0: not found and not actually used; + 1: found before actual use + -1: not found before actual use */ /* stack specials */ int color_depth; @@ -897,7 +900,7 @@ lastpage: if(isdigit(*++out_pages)){ fseek(dvi->file_ptr, 0, SEEK_SET); for(size = dim->page_index[1]; size > 0; size--) write_byte(read_byte(dvi->file_ptr), fp); /* Write preamble */ - /* [Process 1] start the first page */ + /* [Process 1] Start writing the first page. */ current = ftell(fp); /* position of 1-st BOP */ for(size = 41; size > 0; size--) /* Write BOP and c[] */ write_byte(read_byte(dvi->file_ptr), fp); @@ -906,9 +909,8 @@ lastpage: if(isdigit(*++out_pages)){ for(page = 1; page <= dim->total_page; page++){ /* page loop start */ fseek(dvi->file_ptr, dim->page_index[page], SEEK_SET); - f_background = 0; - f_pdf_bgcolor = 0; - pos = interpret(dvi->file_ptr); /* pos = position of EOP + 1 */ + pos = interpret(dvi->file_ptr); /* scanned the whole page content; now + pos = position of EOP + 1 */ if(f_debug){ fprintf(fp_out, "[%d]", page); /* if(page <= dim->total_page){ */ /* always true inside loop */ @@ -929,45 +931,63 @@ lastpage: if(isdigit(*++out_pages)){ 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(tpic_pn[0] && f_pn < 0){ - fprintf(fp_out, "\n%s", tpic_pn); - flag++; + 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"); - f_needs_corr++; + fprintf(fp_out, "\n"); /* at least one special printed */ + f_needs_corr += flag; } /* } */ + if(tpic_pn[0]) /* save current status of tpic_pn */ + strncpy(tpic_pn_prev, tpic_pn, MAX_LEN); } if(f_mode == EXE2CHECK) continue; /* skip loop if (f_mode == EXE2CHECK); * remainings in this loop are for (f_mode == EXE2MODIFY) */ - /* [Process 2] at the beginning of each page, - recover from stack underflow, and put non-stack specials if necessary */ - while(color_under > 0){ /* recover underflow of color stack */ + /* [Process 2] At the beginning of each page, + put non-stack specials if necessary. + Also, if the page is suffering from stack underflow, + open lacking stacks beforehand */ + while(color_under > 0){ /* recover underflow of color stack */ write_sp(fp, "color push Black"); f_needs_corr++; color_under--; } - while(pdf_color_under > 0){ /* recover underflow of pdf:bcolor ... pdf:ecolor stack */ + while(pdf_color_under > 0){ /* recover underflow of pdf:bcolor ... pdf:ecolor stack */ write_sp(fp, "pdf:bcolor [0]"); f_needs_corr++; pdf_color_under--; } - if(background[0] && !f_background){ /* no background in this page */ + if(background[0] && !f_background){ /* background from the former page is effective */ write_sp(fp, background); f_needs_corr++; } - if(pdf_bgcolor[0] && !f_pdf_bgcolor){ /* no pdf:bgcolor in this page */ + if(pdf_bgcolor[0] && !f_pdf_bgcolor){ /* pdf:bgcolor from the former page is effective */ write_sp(fp, pdf_bgcolor); f_needs_corr++; } -// while(pdf_annot_under > 0){ /* recover underflow of pdf:bann ... pdf:eann stack */ +// 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]) + fprintf(stderr, "\nCannot find valid tpic pn." + "\nPlease check your LaTeX source."); + else{ + write_sp(fp, tpic_pn_prev); + f_needs_corr++; + } + } /* [Process 3] write contents of the current page */ fseek(dvi->file_ptr, dim->page_index[page]+45, SEEK_SET); @@ -1005,15 +1025,15 @@ lastpage: if(isdigit(*++out_pages)){ write_sp(fp, pdf_color_pt[count]); // for(count = 0; count < pdf_annot_depth; count++) // write_sp(fp, pdf_annot_pt[count]); - if(tpic_pn[0]) { - write_sp(fp, tpic_pn); - f_needs_corr++; - } f_needs_corr += color_depth; f_needs_corr += pdf_color_depth; // f_needs_corr += pdf_annot_depth; - if(tpic_pn[0]) - f_needs_corr++; + /* Special case for tpic_pn: + save current status of tpic_pn now, before it is (probably) + overwritten after scanning the whole next page. + Note that pn can have different values in the same page! */ + if(tpic_pn[0]) /* save current status of tpic_pn */ + strncpy(tpic_pn_prev, tpic_pn, MAX_LEN); } } /* page loop end */ @@ -1270,6 +1290,9 @@ int strsubcmp_n(char *s, char *t) uint s_work(FILE *dvi) { int code, mode, tmp = 0; + f_background = 0; + f_pdf_bgcolor = 0; + f_pn = 0; while ((code = (uchar)read_byte(dvi)) != EOP){ if(code >= 128){ @@ -1328,8 +1351,7 @@ skip: while (tmp--) f_pn = 1; }else if(!f_pn && (!strsubcmp(special, "pa") || /* pa: tpic pen at */ - !strsubcmp(special, "ar") || /* ar: draw circle */ - !strsubcmp(special, "ia")) ) /* ia: fill */ + !strsubcmp(special, "ar")) ) /* ar: draw circle */ f_pn = -1; else if(!strsubcmp(special, "color")) /* color push/pop */ sp_color(special); diff --git a/Build/source/texk/dviout-util/dvispc.test b/Build/source/texk/dviout-util/dvispc.test index 518529a048c..fb327ff59ac 100755 --- a/Build/source/texk/dviout-util/dvispc.test +++ b/Build/source/texk/dviout-util/dvispc.test @@ -81,6 +81,15 @@ diff --strip-trailing-cr $testdir/oldindep.spc $testdir/oldindep.spc \ # that version can be distinguished from the new version by # exit code 1 for usage without argument. (the above line did it!) +# correction for tpicpn.dvi is needed but should be minimal +./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 +rm -f x0tpicshout.dvi +./dvispc $testdir/tpicsh.dvi x0tpicshout.dvi && \ + if test -f x0tpicshout.dvi; then exit 1; else echo; fi + ## page independence in reverse order which requires prior scanning ./dvispc -c $testdir/reverse.dvi xreverseout.dvi && \ cmp $testdir/reverseout.dvi xreverseout.dvi && echo || exit 1 diff --git a/Build/source/texk/dviout-util/tests/tpicpn.dvi b/Build/source/texk/dviout-util/tests/tpicpn.dvi Binary files differnew file mode 100644 index 00000000000..fd51acd340c --- /dev/null +++ b/Build/source/texk/dviout-util/tests/tpicpn.dvi diff --git a/Build/source/texk/dviout-util/tests/tpicpn.tex b/Build/source/texk/dviout-util/tests/tpicpn.tex new file mode 100644 index 00000000000..a32ea3d793d --- /dev/null +++ b/Build/source/texk/dviout-util/tests/tpicpn.tex @@ -0,0 +1,84 @@ +% tpic pn -> pa (-> fp etc.), ar +\documentclass{article} +\begin{document} +\unitlength 0.001in + +PN 30 (explicit)\par +\begin{picture}(850,550)(-50,-500) + \special{pn 30}% + \special{ar 400 250 400 250 0 6.28319}% + \put(400,-250){\makebox(0,0){document}}% +\end{picture} +\newpage + +PN 30 (implicit from previous page)\par +\begin{picture}(850,550)(-50,-500) + \special{ar 400 250 400 250 0 6.28319}% + \put(400,-250){\makebox(0,0){document}}% +\end{picture} +\newpage + +PN 5 (explicit)\par +\begin{picture}(850,550)(-50,-500) + \special{pn 5}% + \special{ar 400 250 400 250 0 6.28319}% + \put(400,-250){\makebox(0,0){document}}% +\end{picture} +\newpage + +No TPIC picture +\newpage + +PN 5 (implicit from previous page)\par +\begin{picture}(850,550)(-50,-500) + \special{ar 400 250 400 250 0 6.28319}% + \put(400,-250){\makebox(0,0){document}}% +\end{picture} +\newpage + +PN 5 (implicit from previous page)\par +Note that IA has nothing to do with PN!\par +\begin{picture}(850,550)(-50,-500) + \special{sh 0.1} + \special{ia 400 250 400 250 0 6.28319}% + \put(400,-250){\makebox(0,0){document}}% +\end{picture} +\newpage + +PN 30 (explicit)\par +\begin{picture}(600,400)(0,-300) + \special{pn 30}% + \special{pa 100 0}% + \special{pa 500 0}% + \special{pa 500 200}% + \special{pa 100 200}% + \special{pa 100 0}% + \special{fp}% +\end{picture} +\newpage + +PN 30 (implicit from previous page)\par +\begin{picture}(600,400)(0,-300) + \special{pa 100 0}% + \special{pa 500 0}% + \special{pa 500 200}% + \special{pa 100 200}% + \special{pa 100 0}% + \special{fp}% +\end{picture} +\newpage + +PN 30 (implicit from previous page) and PN 5 in the middle\par +\begin{picture}(850,550)(-50,-500) + \special{pa 100 0}% + \special{pa 500 0}% + \special{pa 500 200}% + \special{pa 100 200}% + \special{pa 100 0}% + \special{fp}% + \special{pn 5}% + \special{ar 400 250 400 250 0 6.28319}% +\end{picture} +\newpage + +\end{document} diff --git a/Build/source/texk/dviout-util/tests/tpicpnout.dvi b/Build/source/texk/dviout-util/tests/tpicpnout.dvi Binary files differnew file mode 100644 index 00000000000..ba96cdb486f --- /dev/null +++ b/Build/source/texk/dviout-util/tests/tpicpnout.dvi diff --git a/Build/source/texk/dviout-util/tests/tpicsh.dvi b/Build/source/texk/dviout-util/tests/tpicsh.dvi Binary files differnew file mode 100644 index 00000000000..62574b3f03b --- /dev/null +++ b/Build/source/texk/dviout-util/tests/tpicsh.dvi diff --git a/Build/source/texk/dviout-util/tests/tpicsh.tex b/Build/source/texk/dviout-util/tests/tpicsh.tex new file mode 100644 index 00000000000..534672485d0 --- /dev/null +++ b/Build/source/texk/dviout-util/tests/tpicsh.tex @@ -0,0 +1,41 @@ +% tpic sh -> pa (-> fp, ip etc), ar, ia +% No correction is needed for this file! +\documentclass{article} +\begin{document} +\unitlength 0.001in + +SH (explicit)\par +\begin{picture}(850,550)(-50,-500) + \special{pn 8}% + \special{sh}% + \special{ia 350 200 400 250 0 6.28319}% + \special{sh 0}% + \special{ar 400 250 400 250 0 6.28319}% + \put(400,-250){\makebox(0,0){document}}% +\end{picture} +\newpage + +SH 0.1 (explicit)\par +\begin{picture}(600,400)(0,-300) + \special{pn 30}% + \special{sh 0.1}% + \special{pa 100 0}% + \special{pa 500 0}% + \special{pa 500 200}% + \special{pa 100 200}% + \special{pa 100 0}% + \special{fp}% +\end{picture} + +SH 0 (implicit: SH should not be inherited from the previous one!)\par +\begin{picture}(600,400)(0,-300) + \special{pn 30}% + \special{pa 100 0}% + \special{pa 500 0}% + \special{pa 500 200}% + \special{pa 100 200}% + \special{pa 100 0}% + \special{fp}% +\end{picture} + +\end{document} |