summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/eptexdir
diff options
context:
space:
mode:
authorHironobu Yamashita <h.y.acetaminophen@gmail.com>2018-09-04 11:29:21 +0000
committerHironobu Yamashita <h.y.acetaminophen@gmail.com>2018-09-04 11:29:21 +0000
commit35a9ca73f13ae06f707401c60906a1ce537aafc3 (patch)
treecadd4c1d092e797d76a9b02cf96dc0e5bcfbf822 /Build/source/texk/web2c/eptexdir
parente68200b37960f8500ddb8bcf15ae734ee8a8009d (diff)
eptexdir: add new primitive \readpapersizespecial (H. Kitagawa)
git-svn-id: svn://tug.org/texlive/trunk@48574 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/eptexdir')
-rw-r--r--Build/source/texk/web2c/eptexdir/ChangeLog6
-rw-r--r--Build/source/texk/web2c/eptexdir/eptex.ech50
-rw-r--r--Build/source/texk/web2c/eptexdir/eptex_version.h2
-rw-r--r--Build/source/texk/web2c/eptexdir/pdfutils.ch131
-rw-r--r--Build/source/texk/web2c/eptexdir/tests/pdforigin.sh10
-rw-r--r--Build/source/texk/web2c/eptexdir/tests/pdforigin.tex40
-rw-r--r--Build/source/texk/web2c/eptexdir/tests/pdfpagewidth.tex24
7 files changed, 214 insertions, 49 deletions
diff --git a/Build/source/texk/web2c/eptexdir/ChangeLog b/Build/source/texk/web2c/eptexdir/ChangeLog
index 01656e2453d..7405935c1ae 100644
--- a/Build/source/texk/web2c/eptexdir/ChangeLog
+++ b/Build/source/texk/web2c/eptexdir/ChangeLog
@@ -1,3 +1,9 @@
+2018-09-01 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
+
+ * eptex.ech, pdfutils.ch: New primitive \readpapersizespecial.
+ * eptex.ech, eptex_version.h: e-pTeX version 180901.
+ * tests/pdforigin.tex, tests/pdfpagewidth.tex: Added.
+
2018-05-18 Joseph Wright <joseph.wright@morningstar2.co.uk>
Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
diff --git a/Build/source/texk/web2c/eptexdir/eptex.ech b/Build/source/texk/web2c/eptexdir/eptex.ech
index 9bc07f80450..057904b52cb 100644
--- a/Build/source/texk/web2c/eptexdir/eptex.ech
+++ b/Build/source/texk/web2c/eptexdir/eptex.ech
@@ -8,7 +8,11 @@
%% \lastnodesubtype: the (internal) subtype of the last node
%% -1: null
%% fallback to 0 if not explicitly set
-
+%% \readpapersizespecial
+%% 1: papersize special automatically sets \pdfpage{width,height} (quick hack).
+%% 0: off
+%% The default value is 1.
+%%
@x e-pTeX: logo
\def\eTeX{$\varepsilon$-\TeX}
@@ -22,8 +26,8 @@
@y
@d eTeX_version_string=='-2.6' {current \eTeX\ version}
@#
-@d epTeX_version_string=='-180518'
-@d epTeX_version_number==180518
+@d epTeX_version_string=='-180901'
+@d epTeX_version_number==180901
@z
@x e-pTeX: banner
@@ -66,6 +70,22 @@ In \epTeX\ the |subtype| field is |qi(16*box_lr+box_dir)|.
@d set_box_dir(#) == subtype(#):=box_lr(#)*16+set_box_dir_end
@z
+@x [17]
+@d saving_hyph_codes_code=etex_int_base+8 {save hyphenation codes for languages}
+@d eTeX_state_code=etex_int_base+9 {\eTeX\ state variables}
+@y
+@d saving_hyph_codes_code=etex_int_base+8 {save hyphenation codes for languages}
+@d read_papersize_special_code=etex_int_base+9
+@d eTeX_state_code=etex_int_base+10 {\eTeX\ state variables}
+@z
+
+@x [17]
+@d saving_hyph_codes==int_par(saving_hyph_codes_code)
+@y
+@d saving_hyph_codes==int_par(saving_hyph_codes_code)
+@d read_papersize_special==int_par(read_papersize_special_code)
+@z
+
@x [26.413] l.8343 - e-pTeX: scan_something_internal
var m:halfword; {|chr_code| part of the operand token}
@y
@@ -240,6 +260,15 @@ end
@d set_box_lr_end(#) == qi(16*(#))
@z
+@x [35]
+@<Initialize table entries...@>=
+text_baseline_shift_factor:=1000;
+@y
+@<Initialize table entries...@>=
+text_baseline_shift_factor:=1000;
+read_papersize_special:=1;
+@z
+
@x
@!last_node_type:integer; {used to implement \.{\\lastnodetype}}
@y
@@ -469,6 +498,21 @@ last_node_char_code: print_esc("lastnodechar");
last_node_subtype_code: print_esc("lastnodesubtype");
@z
+@x
+primitive("savinghyphcodes",assign_int,int_base+saving_hyph_codes_code);@/
+@!@:saving_hyph_codes_}{\.{\\savinghyphcodes} primitive@>
+@y
+primitive("savinghyphcodes",assign_int,int_base+saving_hyph_codes_code);@/
+@!@:saving_hyph_codes_}{\.{\\savinghyphcodes} primitive@>
+primitive("readpapersizespecial",assign_int,int_base+read_papersize_special_code);@/
+@!@:read_papersize_special_}{\.{\\readpapersizespecial} primitive@>
+@z
+
+@x
+saving_hyph_codes_code:print_esc("savinghyphcodes");
+@y
+read_papersize_special_code:print_esc("readpapersizespecial");
+@z
@x e-pTeX: font_char_{wd,ht,dp,ic}_code l.27306
if (font_bc[q]<=cur_val)and(font_ec[q]>=cur_val) then
begin i:=char_info(q)(qi(cur_val));
diff --git a/Build/source/texk/web2c/eptexdir/eptex_version.h b/Build/source/texk/web2c/eptexdir/eptex_version.h
index c69432abf1a..28bcc2bf34e 100644
--- a/Build/source/texk/web2c/eptexdir/eptex_version.h
+++ b/Build/source/texk/web2c/eptexdir/eptex_version.h
@@ -1 +1 @@
-#define EPTEX_VERSION "180518"
+#define EPTEX_VERSION "180901"
diff --git a/Build/source/texk/web2c/eptexdir/pdfutils.ch b/Build/source/texk/web2c/eptexdir/pdfutils.ch
index 6c92d35682d..92c41b2e1ee 100644
--- a/Build/source/texk/web2c/eptexdir/pdfutils.ch
+++ b/Build/source/texk/web2c/eptexdir/pdfutils.ch
@@ -8,7 +8,6 @@
%%
%% \pdfsavepos and co.
%% (\pdfsavepos, \pdfpage{width,height}, \pdflast{x,y}pos)
-%% papersize special automatically sets \pdfpage{width,height} (quick hack).
%%
%% \pdffiledump: for bmpsize package by Heiko Oberdiek
%%
@@ -1197,7 +1196,7 @@ procedure special_out(@!p:pointer);
label done;
var old_setting:0..max_selector; {holds print |selector|}
@!k:pool_pointer; {index into |str_pool|}
-@!s,@!t,@!cw: scaled;
+@!s,@!t,@!cw, @!num, @!denom: scaled;
@!bl: boolean;
@!i: small_number;
@z
@@ -1205,7 +1204,8 @@ var old_setting:0..max_selector; {holds print |selector|}
@x
pool_ptr:=str_start[str_ptr]; {erase the string}
@y
-@<Determine whether this \.{\\special} is a papersize special@>;
+if read_papersize_special>0 then
+ @<Determine whether this \.{\\special} is a papersize special@>;
done: pool_ptr:=str_start[str_ptr]; {erase the string}
@z
@@ -1460,56 +1460,97 @@ end
A \.{DVI} file does not have the information of the page height,
which is needed to implement \.{\\pdflastypos} correctly.
To keep the information of the page height, I (H.~Kitagawa)
-adopted \.{\\pdfpageheight} primitive from pdf\TeX. However, in \pTeX (and \hbox{\epTeX}),
-the papersize special \.{\\special\{papersize=|width|,|height|\}} is commonly used
-for specifying page width/height. Hence, I decided that the papersize special also
-changes the value of \.{\\pdfpagewidth} and \.{\\pdfpageheight}.
-The following routine does this.
-
-In present implementation, the ``valid'' papersize special, which can be interpreted by
-this routine, is in the following form:
-$$\hbox{\.{\\special\char"7Bpapersize=}$x$\.{pt,}$y$\.{pt\char"7D}}$$
-where $x$\thinspace pt and $y$\thinspace pt are positive dimensions which \TeX\ can comprehend.
-No spaces are allowed in the above form, and only ``pt'' is allowed for unit, for simplicity.
+adopted \.{\\pdfpageheight} primitive from pdf\TeX.
-@d ifps==if k=pool_ptr then goto done else if
-@d sop(#)==so(str_pool[(#)])
+In \pTeX (and \hbox{\epTeX}), the papersize special
+\.{\\special\{papersize=\<width>,\<height>\}} is commonly used
+for specifying page width/height.
+If \.{\\readpapersizespecial} is greater than~0, the papersize special also
+changes the value of \.{\\pdfpagewidth} and \.{\\pdfpageheight}.
+This process is done in the following routine.
+
+{\def\<#1>{\langle\hbox{#1\/}\rangle}
+In present implementation, the papersize special $\<special>$,
+which can be interpreted by this routine, is defined as follows.
+$$\eqalign{%
+ \<special> &\longrightarrow \.{papersize=}\<length>\.{,}\<length>\cr
+ \<length> &\longrightarrow \<decimal>
+ \<optional~\.{true}>\<physical unit>\cr
+ \<decimal> &\longrightarrow \.{.} \mid \<digit>\<decimal> \mid
+ \<decimal>\<digit>\cr
+}$$}
+Note that any space, ``\.{,}'' as a decimal separator, minus~symbol
+are neither permitted.
+
+@d ifps(#)==@+if k+(#)>pool_ptr then goto done @+ else @+ if
+@d sop(#)==so(str_pool[#])
+@f ifps==if
@<Determine whether this \.{\\special} is a papersize special@>=
-if pool_ptr-str_start[str_ptr]<=10 then goto done;
-k:=str_start[str_ptr];
-if (sop(k+0)<>'p')or(sop(k+1)<>'a')or(sop(k+2)<>'p')or
- (sop(k+3)<>'e')or(sop(k+4)<>'r')or(sop(k+5)<>'s')or
- (sop(k+6)<>'i')or(sop(k+7)<>'z')or(sop(k+8)<>'e') then goto done;
-k:=k+9; ifps sop(k)='=' then incr(k);
+begin k:=str_start[str_ptr];@/
+ifps(10) @,
+ (sop(k+0)<>'p')or(sop(k+1)<>'a')or(sop(k+2)<>'p')or
+ (sop(k+3)<>'e')@|or(sop(k+4)<>'r')or(sop(k+5)<>'s')or
+ (sop(k+6)<>'i')or(sop(k+7)<>'z')@|or(sop(k+8)<>'e')or
+ (sop(k+9)<>'=') then goto done;
+k:=k+10;
@<Read dimensions in the argument in the papersize special@>;
-incr(k); ifps sop(k)<>',' then goto done else incr(k); cw:=t;
-@<Read dimensions in the argument in the papersize special@>;
-geq_word_define(dimen_base+pdf_page_width_code,cw);
-geq_word_define(dimen_base+pdf_page_height_code,t);
-cur_page_height := t; cur_page_width := cw;
-if (dvi_dir=dir_tate)or(dvi_dir=dir_dtou) then begin
+ifps(1) @, sop(k)=',' then begin
+ incr(k); cw:=s;
+ @<Read dimensions in the argument in the papersize special@>;
+ if pool_ptr>k then goto done;
+ geq_word_define(dimen_base+pdf_page_width_code,cw);
+ geq_word_define(dimen_base+pdf_page_height_code,s);@|
+ cur_page_height := s; cur_page_width := cw;
+ if (dvi_dir=dir_tate)or(dvi_dir=dir_dtou) then begin
t:=cur_page_height; cur_page_height:=cur_page_width;
cur_page_width:=t; end;
-
-@ @<Read dimensions in the argument in the papersize special@>=
-s:=1; t:=0; bl:=true;
-while (k<pool_ptr)and(bl) do begin
- if (sop(k)>='0')and (sop(k)<='9') then begin t:=10*t+sop(k)-'0'; incr(k); end
- else begin bl:=false; end;
end;
-t:=t*unity;
-ifps sop(k)='.' then begin incr(k); bl:=true; i:=0;
- while (k<pool_ptr)and(bl)and(i<=17) do begin
- if (sop(k)>='0')and (sop(k)<='9') then begin
- dig[i]:=sop(k)-'0'; incr(k); incr(i); end
- else begin bl:=false; incr(k); incr(i); end;
+end;
+
+@
+
+@d if_ps_unit(#)==if bl then @+ begin @+ ifps(2) sop(k)=(#) @, if_ps_unit_two
+@d if_ps_unit_two(#)==and (sop(k+1)=(#)) then begin bl:=false; k:=k+2; if_ps_unit_end
+@d if_ps_unit_end(#)==# @+ end @+ end;
+
+@d do_ps_conversion(#)==num:=#; do_ps_conversion_end
+@d do_ps_conversion_end(#)==
+ s:=xn_over_d(s,num,#); s:=s*unity+((num*t+@'200000*remainder) div #)
+
+@<Read dimensions in the argument in the papersize special@>=
+s:=0; t:=0; bl:=true;
+while (k<pool_ptr)and bl do
+ if (sop(k)>='0')and (sop(k)<='9') then begin s:=10*s+sop(k)-'0'; incr(k); @+end
+ else bl:=false;
+ifps(1) sop(k)='.' then
+ begin incr(k); bl:=true; i:=0; dig[0]:=0;
+ while (k<pool_ptr)and bl do begin
+ if (sop(k)>='0')and (sop(k)<='9') then
+ begin if i<17 then begin dig[i]:=sop(k)-'0'; incr(i); @+end;
+ incr(k); end
+ else bl:=false;
end;
- t:=s*(t+round_decimals(i-1));
-end
-else if (sop(k)>='0')and(sop(k)<='9') then goto done
-else begin t:=s*t; incr(k); end;
-ifps sop(k-1)<>'p' then goto done; ifps sop(k)<>'t' then goto done;
+ t:=round_decimals(i);
+ end;
+if k+4>pool_ptr then
+ if (sop(k)='t')and(sop(k+1)='r')and(sop(k+2)='u')and(sop(k+3)='e') then
+ k:=k+4;
+if mag<>1000 then
+ begin s:=xn_over_d(s,1000,mag);
+ t:=(1000*t+@'200000*remainder) div mag;
+ s:=s+(t div @'200000); t:=t mod @'200000;
+end;
+bl:=true;@/
+if_ps_unit('p')('t')(s:=s*unity+t)@/
+if_ps_unit('i')('n')(do_ps_conversion(7227)(100))@/
+if_ps_unit('p')('c')(do_ps_conversion(12)(1))@/
+if_ps_unit('c')('m')(do_ps_conversion(7227)(254))@/
+if_ps_unit('m')('m')(do_ps_conversion(7227)(2540))@/
+if_ps_unit('b')('p')(do_ps_conversion(7227)(7200))@/
+if_ps_unit('d')('d')(do_ps_conversion(1238)(1157))@/
+if_ps_unit('c')('c')(do_ps_conversion(14856)(1157))@/
+if_ps_unit('s')('p')(do_nothing)
@ Finally, we declare some routine needed for \.{\\pdffilemoddate}.
diff --git a/Build/source/texk/web2c/eptexdir/tests/pdforigin.sh b/Build/source/texk/web2c/eptexdir/tests/pdforigin.sh
new file mode 100644
index 00000000000..0889a39508b
--- /dev/null
+++ b/Build/source/texk/web2c/eptexdir/tests/pdforigin.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+etex pdforigin.tex && etex pdforigin.tex
+dvips pdforigin
+ps2pdf pdforigin.ps && mv pdforigin.pdf pdforigin_etex_dvips.pdf
+dvipdfmx pdforigin && mv pdforigin.pdf pdforigin_etex_dvipdfmx.pdf
+eptex pdforigin.tex && eptex pdforigin.tex
+dvipdfmx pdforigin && mv pdforigin.pdf pdforigin_eptex_dvipdfmx.pdf
+pdftex pdforigin.tex && pdftex pdforigin.tex && mv pdforigin.pdf pdforigin_pdftex.pdf
+xetex pdforigin.tex && xetex pdforigin.tex && mv pdforigin.pdf pdforigin_xetex.pdf
+
diff --git a/Build/source/texk/web2c/eptexdir/tests/pdforigin.tex b/Build/source/texk/web2c/eptexdir/tests/pdforigin.tex
new file mode 100644
index 00000000000..ab64ac932b9
--- /dev/null
+++ b/Build/source/texk/web2c/eptexdir/tests/pdforigin.tex
@@ -0,0 +1,40 @@
+\mag=3000
+
+\newdimen\XPOS\newdimen\YPOS\newread\TMP
+\openin\TMP=\jobname.tmp
+\ifeof\TMP\else\closein\TMP\input \jobname.tmp\fi
+\immediate\openout\TMP=\jobname.tmp
+\topskip0pt
+\ifdefined\pagewidth
+ \pagewidth=10truein\pageheight=10truein
+\else\ifdefined\pdfpagewidth
+ \pdfpagewidth=10truein\pdfpageheight=10truein
+\fi\fi
+
+\shipout\hbox{%
+ \special{papersize=10truein,10truein}%
+ \pdfsavepos%
+ \write\TMP{\noexpand\XPOS=\the\pdflastxpos sp\noexpand\YPOS=\the\pdflastypos sp}%
+ \smash{%
+ \llap{\hss\vrule height 1pt depth 0pt width \XPOS}%
+ \llap{\hss\vrule height 2.4pt depth -2pt width 1in}%
+ \llap{\hss\vrule height 4pt depth -3.2pt width 1truein}%
+ \llap{\vrule height 1in depth 0pt width 0.4pt\kern.8pt%
+ \vrule height 1truein depth 0pt width 0.8pt}%
+ \rlap{%
+ \vrule height 0pt depth \dimexpr\YPOS+5truept width .4pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS+4truept width .4pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS+3truept width .4pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS+2truept width .4pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS+1truept width .4pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS width .8pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS-1truept width .4pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS-2truept width .4pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS-3truept width .4pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS-4truept width .4pt\kern.8pt
+ \vrule height 0pt depth \dimexpr\YPOS-5truept width .4pt\kern.8pt%
+ }%
+ }%
+}
+\end
+
diff --git a/Build/source/texk/web2c/eptexdir/tests/pdfpagewidth.tex b/Build/source/texk/web2c/eptexdir/tests/pdfpagewidth.tex
new file mode 100644
index 00000000000..c285d7601db
--- /dev/null
+++ b/Build/source/texk/web2c/eptexdir/tests/pdfpagewidth.tex
@@ -0,0 +1,24 @@
+%#!eptex
+
+\def\TEST#1{%
+ \pdfpagewidth0pt\pdfpageheight0pt
+ \shipout\hbox{\special{#1}}%
+ \message{<\the\pdfpagewidth, \the\pdfpageheight>}%
+}
+\count0=0
+\readpapersizespecial=1
+\TEST{papersize=10pt,20pt} % OK
+\TEST{papersize=10pt,20zw} % `zw' is not supported
+\TEST{papersize=10pt,20ex} % `ex' is neither
+\TEST{papersize=1pt,2} % no unit
+\TEST{papersize 10pc,20pc} % there is no `='
+\TEST{papersize=10pcA,20pc}%
+\TEST{papersize=10pc,20pcs}%
+\TEST{papersize=10pt,-20pt}% negative value
+\TEST{papersize=0pt,20000.6sp}% OK
+\TEST{papersize=30.2pt,665pt}% OK
+
+\readpapersizespecial=0
+\TEST{papersize=10pt,20pt}
+
+\end