diff options
author | Hironobu Yamashita <h.y.acetaminophen@gmail.com> | 2017-09-09 17:17:10 +0000 |
---|---|---|
committer | Hironobu Yamashita <h.y.acetaminophen@gmail.com> | 2017-09-09 17:17:10 +0000 |
commit | 1f88188d33aa368bed61fd2195622cd0649659b4 (patch) | |
tree | 54faf990b5f1af6e960128ec6b606f41d5d5c63f | |
parent | 9ca200015531cf14e5df3bad6c7eef4d539601bc (diff) |
\epTeXinputencoding works also with the terminal (H. Kitagawa and N. Abe)
git-svn-id: svn://tug.org/texlive/trunk@45249 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/ptexenc/ChangeLog | 5 | ||||
-rw-r--r-- | Build/source/texk/ptexenc/ptexenc.c | 10 | ||||
-rw-r--r-- | Build/source/texk/ptexenc/ptexenc/ptexenc.h | 1 | ||||
-rw-r--r-- | Build/source/texk/web2c/eptexdir/ChangeLog | 6 | ||||
-rw-r--r-- | Build/source/texk/web2c/eptexdir/eptex.defines | 1 | ||||
-rw-r--r-- | Build/source/texk/web2c/eptexdir/eptex.ech | 55 | ||||
-rw-r--r-- | Build/source/texk/web2c/euptexdir/ChangeLog | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/euptexdir/euptex.defines | 1 |
8 files changed, 72 insertions, 11 deletions
diff --git a/Build/source/texk/ptexenc/ChangeLog b/Build/source/texk/ptexenc/ChangeLog index 6b9328f3494..4be1dd3272e 100644 --- a/Build/source/texk/ptexenc/ChangeLog +++ b/Build/source/texk/ptexenc/ChangeLog @@ -1,3 +1,8 @@ +2017-09-09 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> + + * ptexenc.c, ptexenc/ptexenc.h: Add a new function setstdinenc() for the + primitive \epTeXinputencoding in e-(u)pTeX. + 2017-03-18 Karl Berry <karl@tug.org> * version.ac (ptexenc_version): 1.3.5dev => 1.3.5 for TL17. diff --git a/Build/source/texk/ptexenc/ptexenc.c b/Build/source/texk/ptexenc/ptexenc.c index 92e6b866853..83842ccdaaa 100644 --- a/Build/source/texk/ptexenc/ptexenc.c +++ b/Build/source/texk/ptexenc/ptexenc.c @@ -840,6 +840,7 @@ long input_line2(FILE *fp, unsigned char *buff, long pos, return last; } +// set encode of stdin if fp = NULL boolean setinfileenc(FILE *fp, const char *str) { int enc; @@ -849,6 +850,15 @@ boolean setinfileenc(FILE *fp, const char *str) return true; } +boolean setstdinenc(const char *str) +{ + int enc; + enc = string_to_enc(str); + if (enc < 0) return false; + infile_enc[fileno(stdin)] = enc; + return true; +} + #ifdef WIN32 void clear_infile_enc(FILE *fp) { diff --git a/Build/source/texk/ptexenc/ptexenc/ptexenc.h b/Build/source/texk/ptexenc/ptexenc/ptexenc.h index db5410e7f98..b42d050f156 100644 --- a/Build/source/texk/ptexenc/ptexenc/ptexenc.h +++ b/Build/source/texk/ptexenc/ptexenc/ptexenc.h @@ -83,6 +83,7 @@ extern PTENCDLL long input_line2(FILE *fp, unsigned char *buff, long pos, /* set current encoding */ extern PTENCDLL boolean setinfileenc(FILE *fp, const char *str); +extern PTENCDLL boolean setstdinenc(const char *str); #ifdef WIN32 extern PTENCDLL void clear_infile_enc(FILE *fp); diff --git a/Build/source/texk/web2c/eptexdir/ChangeLog b/Build/source/texk/web2c/eptexdir/ChangeLog index f7fb353f567..5d5f963409d 100644 --- a/Build/source/texk/web2c/eptexdir/ChangeLog +++ b/Build/source/texk/web2c/eptexdir/ChangeLog @@ -1,3 +1,9 @@ +2017-09-09 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> + and Noriyuki Abe <abenori@math.sci.hokudai.ac.jp> + + * eptex.ech: \epTeXinputencoding works also with the terminal. + * eptex.defines: Add a new function setstdinenc(). + 2017-09-06 Noriyuki Abe <abenori@math.sci.hokudai.ac.jp> * eptex.ech: fix a bug in \epTeXinputencoding. diff --git a/Build/source/texk/web2c/eptexdir/eptex.defines b/Build/source/texk/web2c/eptexdir/eptex.defines index 8af65b6678e..e6d9a441504 100644 --- a/Build/source/texk/web2c/eptexdir/eptex.defines +++ b/Build/source/texk/web2c/eptexdir/eptex.defines @@ -20,6 +20,7 @@ @define function inputline2 (); @define function setinfileenc (); +@define function setstdinenc (); @define function fromJIS (); @define function fromEUC (); diff --git a/Build/source/texk/web2c/eptexdir/eptex.ech b/Build/source/texk/web2c/eptexdir/eptex.ech index 5702c3a4b95..af94d280aad 100644 --- a/Build/source/texk/web2c/eptexdir/eptex.ech +++ b/Build/source/texk/web2c/eptexdir/eptex.ech @@ -339,18 +339,51 @@ epTeX_input_encoding_code:@<Implement \.{\\epTeXinputencoding}@>; @x @ @<Finish the extensions@>= @y -@ @<Implement \.{\\epTeXinputencoding}@>= - begin - scan_file_name; - pack_cur_name; - if setinfileenc(input_file[in_open],stringcast(name_of_file+1)) = false then - begin - wlog_cr; - wlog('Unknown encoding `'); - fputs(stringcast(name_of_file + 1), log_file); - wlog(''''); +@ @<Declare procedures needed in |do_ext...@>= +procedure eptex_set_input_encoding; +var j,k:integer; +begin + scan_file_name; + pack_cur_name; + if state=token_list then + begin k:=input_ptr-1; j:=-1; + while k>=0 do + begin if input_stack[k].state_field=token_list then decr(k) + else if input_stack[k].name_field>19 then + begin j:=input_stack[k].index_field; k:=-1; end + else begin j:=-(name+1); k:=-1; end + end end - end + else if name>19 then j:=index else j:=-(name+1); + if (j>=0) or (j=-1) or (j=-18) then begin + k:=true; + if j>= 0 then k:=setinfileenc(input_file[j],stringcast(name_of_file+1)) + else k:=setstdinenc(stringcast(name_of_file+1)); + if k = false then + begin begin_diagnostic; + print_nl("Unknown encoding `"); + case selector of + term_and_log: begin wterm(stringcast(name_of_file + 1)); + wlog(stringcast(name_of_file + 1)); end; + log_only: wlog(stringcast(name_of_file + 1)); + term_only: wterm(stringcast(name_of_file + 1)); + endcases; + print("'"); end_diagnostic(false); + end + end + else + begin begin_diagnostic; j:=-j-1; + print_ln; + print_nl("Warning: \epTeXinputencoding is ignored, since I am current reading"); + print_nl("from "); + if j>=18 then print("a pseudo file created by \scantokens.") + else begin print("input stream "); print_int(j); print("."); end; + end_diagnostic(false); + end +end; + +@ @<Implement \.{\\epTeXinputencoding}@>= +eptex_set_input_encoding @ @<Finish the extensions@>= @z diff --git a/Build/source/texk/web2c/euptexdir/ChangeLog b/Build/source/texk/web2c/euptexdir/ChangeLog index 986e39a0758..c3b51dd825b 100644 --- a/Build/source/texk/web2c/euptexdir/ChangeLog +++ b/Build/source/texk/web2c/euptexdir/ChangeLog @@ -1,3 +1,7 @@ +2017-09-09 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> + + * euptex.defines: Add a new function setstdinenc(). + 2017-04-24 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> * euptex.ch0: Adapt to changes in ptexdir/ptex-base.ch (p\TeX -> \pTeX). diff --git a/Build/source/texk/web2c/euptexdir/euptex.defines b/Build/source/texk/web2c/euptexdir/euptex.defines index 7f10e36304a..b2035a4af2e 100644 --- a/Build/source/texk/web2c/euptexdir/euptex.defines +++ b/Build/source/texk/web2c/euptexdir/euptex.defines @@ -25,6 +25,7 @@ @define function inputline2 (); @define function setinfileenc (); +@define function setstdinenc (); @define function fromJIS (); @define function fromEUC (); |