texlive[48901] Build/source/texk/dviout-util: import

commits+hironobu at tug.org commits+hironobu at tug.org
Sat Oct 13 17:50:13 CEST 2018


Revision: 48901
          http://tug.org/svn/texlive?view=revision&revision=48901
Author:   hironobu
Date:     2018-10-13 17:50:11 +0200 (Sat, 13 Oct 2018)
Log Message:
-----------
import aminophen/dviout-util at 66be463

Modified Paths:
--------------
    trunk/Build/source/texk/dviout-util/ChangeLog
    trunk/Build/source/texk/dviout-util/Makefile.am
    trunk/Build/source/texk/dviout-util/Makefile.in
    trunk/Build/source/texk/dviout-util/dvispc.c
    trunk/Build/source/texk/dviout-util/dvispc.test

Added Paths:
-----------
    trunk/Build/source/texk/dviout-util/tests/tpicpn.dvi
    trunk/Build/source/texk/dviout-util/tests/tpicpn.tex
    trunk/Build/source/texk/dviout-util/tests/tpicpnout.dvi
    trunk/Build/source/texk/dviout-util/tests/tpicsh.dvi
    trunk/Build/source/texk/dviout-util/tests/tpicsh.tex

Modified: trunk/Build/source/texk/dviout-util/ChangeLog
===================================================================
--- trunk/Build/source/texk/dviout-util/ChangeLog	2018-10-13 11:04:09 UTC (rev 48900)
+++ trunk/Build/source/texk/dviout-util/ChangeLog	2018-10-13 15:50:11 UTC (rev 48901)
@@ -1,3 +1,10 @@
+2018-10-14  Hironobu Yamashita  <h.y.acetaminophen at 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 at gmail.com>
 
 	* dvispc.c: Stop support for pdf:bann, pe:eann which was

Modified: trunk/Build/source/texk/dviout-util/Makefile.am
===================================================================
--- trunk/Build/source/texk/dviout-util/Makefile.am	2018-10-13 11:04:09 UTC (rev 48900)
+++ trunk/Build/source/texk/dviout-util/Makefile.am	2018-10-13 15:50:11 UTC (rev 48901)
@@ -32,6 +32,8 @@
 ## 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 \
@@ -38,7 +40,7 @@
 	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

Modified: trunk/Build/source/texk/dviout-util/Makefile.in
===================================================================
--- trunk/Build/source/texk/dviout-util/Makefile.in	2018-10-13 11:04:09 UTC (rev 48900)
+++ trunk/Build/source/texk/dviout-util/Makefile.in	2018-10-13 15:50:11 UTC (rev 48901)
@@ -560,17 +560,18 @@
 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
 

Modified: trunk/Build/source/texk/dviout-util/dvispc.c
===================================================================
--- trunk/Build/source/texk/dviout-util/dvispc.c	2018-10-13 11:04:09 UTC (rev 48900)
+++ trunk/Build/source/texk/dviout-util/dvispc.c	2018-10-13 15:50:11 UTC (rev 48901)
@@ -253,12 +253,15 @@
 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 @@
         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 @@
 
     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 @@
                 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 @@
                 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 @@
 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 @@
                                 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);

Modified: trunk/Build/source/texk/dviout-util/dvispc.test
===================================================================
--- trunk/Build/source/texk/dviout-util/dvispc.test	2018-10-13 11:04:09 UTC (rev 48900)
+++ trunk/Build/source/texk/dviout-util/dvispc.test	2018-10-13 15:50:11 UTC (rev 48901)
@@ -81,6 +81,15 @@
 # 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

Added: trunk/Build/source/texk/dviout-util/tests/tpicpn.dvi
===================================================================
(Binary files differ)

Index: trunk/Build/source/texk/dviout-util/tests/tpicpn.dvi
===================================================================
--- trunk/Build/source/texk/dviout-util/tests/tpicpn.dvi	2018-10-13 11:04:09 UTC (rev 48900)
+++ trunk/Build/source/texk/dviout-util/tests/tpicpn.dvi	2018-10-13 15:50:11 UTC (rev 48901)

Property changes on: trunk/Build/source/texk/dviout-util/tests/tpicpn.dvi
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Build/source/texk/dviout-util/tests/tpicpn.tex
===================================================================
--- trunk/Build/source/texk/dviout-util/tests/tpicpn.tex	                        (rev 0)
+++ trunk/Build/source/texk/dviout-util/tests/tpicpn.tex	2018-10-13 15:50:11 UTC (rev 48901)
@@ -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}


Property changes on: trunk/Build/source/texk/dviout-util/tests/tpicpn.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Build/source/texk/dviout-util/tests/tpicpnout.dvi
===================================================================
(Binary files differ)

Index: trunk/Build/source/texk/dviout-util/tests/tpicpnout.dvi
===================================================================
--- trunk/Build/source/texk/dviout-util/tests/tpicpnout.dvi	2018-10-13 11:04:09 UTC (rev 48900)
+++ trunk/Build/source/texk/dviout-util/tests/tpicpnout.dvi	2018-10-13 15:50:11 UTC (rev 48901)

Property changes on: trunk/Build/source/texk/dviout-util/tests/tpicpnout.dvi
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Build/source/texk/dviout-util/tests/tpicsh.dvi
===================================================================
(Binary files differ)

Index: trunk/Build/source/texk/dviout-util/tests/tpicsh.dvi
===================================================================
--- trunk/Build/source/texk/dviout-util/tests/tpicsh.dvi	2018-10-13 11:04:09 UTC (rev 48900)
+++ trunk/Build/source/texk/dviout-util/tests/tpicsh.dvi	2018-10-13 15:50:11 UTC (rev 48901)

Property changes on: trunk/Build/source/texk/dviout-util/tests/tpicsh.dvi
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Build/source/texk/dviout-util/tests/tpicsh.tex
===================================================================
--- trunk/Build/source/texk/dviout-util/tests/tpicsh.tex	                        (rev 0)
+++ trunk/Build/source/texk/dviout-util/tests/tpicsh.tex	2018-10-13 15:50:11 UTC (rev 48901)
@@ -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}


Property changes on: trunk/Build/source/texk/dviout-util/tests/tpicsh.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property


More information about the tex-live-commits mailing list