summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/morewrites
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-07-24 16:55:17 +0000
committerKarl Berry <karl@freefriends.org>2012-07-24 16:55:17 +0000
commit3accf11dd41cac5f2c81b83a2a712c77ffab2b6a (patch)
treee1b5a34217c371d2c469c5b9d79fe6b12f3624e4 /Master/texmf-dist/tex/latex/morewrites
parentc1841336503cc8eb2355c2eab40012c856f18369 (diff)
morewrites (18jul12)
git-svn-id: svn://tug.org/texlive/trunk@27138 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/morewrites')
-rw-r--r--Master/texmf-dist/tex/latex/morewrites/morewrites.sty540
-rw-r--r--Master/texmf-dist/tex/latex/morewrites/primargs.sty197
2 files changed, 423 insertions, 314 deletions
diff --git a/Master/texmf-dist/tex/latex/morewrites/morewrites.sty b/Master/texmf-dist/tex/latex/morewrites/morewrites.sty
index 202c539dc7a..fe8cbf1ee6e 100644
--- a/Master/texmf-dist/tex/latex/morewrites/morewrites.sty
+++ b/Master/texmf-dist/tex/latex/morewrites/morewrites.sty
@@ -9,7 +9,7 @@
%% Communicate any suggestions for changing this package
%% to Bruno Le Floch (blflatex@gmail.com).
%%
-%% File: morewrites.dtx Copyright (C) 2011 Bruno Le Floch
+%% File: morewrites.dtx Copyright (C) 2011-2012 Bruno Le Floch
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -20,322 +20,231 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: morewrites.dtx 0.1 2011-09-09 00:00:00Z bruno $
- {Always room for a new write}%
\ProvidesExplPackage
- {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
-\RequirePackage{expl3}
-\cs_new_eq:NN \mw_tex_openin:w \tex_openin:D
-\cs_new_eq:NN \mw_tex_read:w \tex_read:D
-\cs_new_eq:NN \mw_etex_readline:w \etex_readline:D
-\cs_new_eq:NN \mw_tex_closein:w \tex_closein:D
-\cs_new_eq:NN \mw_tex_immediate:w \tex_immediate:D
-\cs_new_eq:NN \mw_tex_openout:w \tex_openout:D
-\cs_new_eq:NN \mw_tex_write:w \tex_write:D
-\cs_new_eq:NN \mw_tex_closeout:w \tex_closeout:D
-\cs_new_eq:NN \mw_tex_shipout:w \tex_shipout:D
-\int_new:N \g_mw_late_write_int
-\prop_new:N \g_mw_writes_prop
-\newread \g_mw_read
-\tl_const:Nn \c_mw_tmp_file_tl { \jobname.mw }
-\newwrite \g_mw_write
-\seq_new:N \g_mw_reserved_writes_seq
-\prg_stepwise_inline:nnnn {0} {1} { \g_mw_write - 1 }
- { \seq_gput_right:Nn \g_mw_reserved_writes_seq {#1} }
-\seq_gput_right:Nn \g_mw_reserved_writes_seq {18}
-\tl_new:N \l_mw_tmpa_tl
-\int_new:N \g_mw_step_int
-\int_new:N \g_mw_tmpa_int
-\newbox \g_mw_box
-\int_new:N \g_mw_stream_int
-\tl_new:N \g_mw_filename_tl
-\tl_new:N \g_mw_text_tl
-\cs_new_eq:NN \mw_scan_stop: \scan_stop:
-\cs_new_protected_nopar:Npn \mw_parse_number:Nw #1
- {
- \tex_afterassignment:D #1
- \tex_global:D \g_mw_stream_int
- }
-\cs_new_protected_nopar:Npn \mw_parse_text:Nw #1
+ {morewrites} {2012/07/10} {0.2} {Always room for a new write}
+\RequirePackage{expl3, primargs}
+\cs_new_eq:NN \__morewrites_tex_immediate:w \tex_immediate:D
+\cs_new_eq:NN \__morewrites_tex_openout:w \tex_openout:D
+\cs_new_eq:NN \__morewrites_tex_write:w \tex_write:D
+\cs_new_eq:NN \__morewrites_tex_closeout:w \tex_closeout:D
+\cs_new_eq:NN \__morewrites_tex_shipout:w \tex_shipout:D
+\int_new:N \g__morewrites_late_write_int
+\prop_new:N \g__morewrites_iow_prop
+\newwrite \g__morewrites_iow
+\newread \g__morewrites_ior
+\tl_new:N \g__morewrites_tmp_file_tl
+\tl_gset:Nn \g__morewrites_tmp_file_tl { \jobname.mw }
+\clist_new:N \g__morewrites_reserved_iow_clist
+\int_step_inline:nnnn {0} {1} { \g__morewrites_iow - 1 }
+ { \clist_gput_right:Nn \g__morewrites_reserved_iow_clist {#1} }
+\clist_gput_right:Nn \g__morewrites_reserved_iow_clist {18}
+\int_new:N \g__morewrites_stream_int
+\cs_new_eq:NN \s__morewrites \scan_stop:
+\tl_new:N \l__morewrites_internal_tl
+\cs_new_protected:Npn \__morewrites_equals_file_name:N #1
{
\group_begin:
\tex_aftergroup:D #1
- \tex_afterassignment:D \mw_parse_text_aux:
- \tex_toks:D \c_zero =
- }
-\cs_new_protected_nopar:Npn \mw_parse_text_aux:
- {
- \tl_gset:Nx \g_mw_text_tl { \tex_the:D \tex_toks:D \c_zero }
- \group_end:
- }
-\cs_new_protected_nopar:Npn \mw_parse_equals_filename:Nw #1
- {
- \peek_meaning_remove:NTF =
- { \mw_parse_filename:Nw #1 } { \mw_parse_filename:Nw #1 }
- }
-\cs_new_protected_nopar:Npn \mw_parse_filename:Nw #1
- {
- \group_begin:
- \group_align_safe_begin:
- \tex_aftergroup:D #1
- \tl_gclear:N \g_mw_filename_tl
- \mw_parse_filename_loop:w
- }
-\cs_new_protected_nopar:Npn \mw_parse_filename_loop:w
- { \peek_gafter:Nw \mw_parse_filename_loop_test: }
-\cs_new_protected_nopar:Npn \mw_parse_filename_loop_test:
- {
- \exp_after:wN \if_meaning:w \exp_not:N \g_peek_token \g_peek_token
- \exp_after:wN \use_ii:nn
- \else:
- \exp_after:wN \use_i:nn
- \fi:
- { \exp_after:wN \mw_parse_filename_loop:w }
- {
- \token_if_cs:NTF \g_peek_token
- { \mw_parse_filename_end: }
- {
- \mw_parse_filename_space_test:NTF \g_peek_token
- { \mw_parse_filename_space_do:w }
- {
- \exp_after:wN \mw_parse_filename_push:w
- \token_to_meaning:N
- }
- }
- }
+ \primargs_remove_equals:N \__morewrites_parse_file_name:
}
-\cs_new_protected_nopar:Npn \mw_parse_filename_end:
+\cs_new_protected:Npn \__morewrites_parse_file_name:
+ { \primargs_get_file_name:N \group_end: }
+\cs_new_protected_nopar:Npn \__morewrites_immediate:w
+ { \primargs_read_x_token:N \__morewrites_immediate_ii: }
+\cs_new_protected_nopar:Npn \__morewrites_immediate_ii:
{
- \group_align_safe_end:
- \group_end:
- }
- %^^A TeXlive's behaviour (?): space with any catcode
-\cs_new_protected_nopar:Npn \mw_parse_filename_space_test:NTF
- { \token_if_eq_charcode:NNTF \c_space_token }
-\cs_new_protected_nopar:Npn \mw_parse_filename_space_do:w
- {
- \tex_afterassignment:D \mw_parse_filename_end:
- \cs_set_eq:NN \g_peek_token
- }
-\cs_new_protected_nopar:Npn \mw_parse_filename_push:w #1 ~ %
- {
- \tl_if_in:nnTF { math ~ alignment ~ macro } { #1 }
- { \mw_parse_filename_push_three:w }
- { \mw_parse_filename_push_two:w }
- }
-\cs_new_protected_nopar:Npn \mw_parse_filename_push_two:w #1 ~ #2
- {
- \tl_gput_right:Nn \g_mw_filename_tl {#2}
- \mw_parse_filename_loop:w
- }
-\cs_new_protected_nopar:Npn \mw_parse_filename_push_three:w #1 ~ #2 ~ #3
- {
- \tl_gput_right:Nn \g_mw_filename_tl {#3}
- \mw_parse_filename_loop:w
+ \token_if_eq_meaning:NNT \g_primargs_token \s__morewrites
+ { \__morewrites_immediate_iii:N }
}
-\cs_new:Npn \mw_prg_case_meaning:Nnn #1#2#3
- { \mw_prg_case_meaning_aux:Nw #1 #2 #1 {#3} \q_recursion_stop }
-\cs_new:Npn \mw_prg_case_meaning_aux:Nw #1#2#3
+\cs_new_protected:Npn \__morewrites_immediate_iii:N #1
{
- \token_if_eq_meaning:NNTF #1 #2
- { \prg_case_end:nw {#3} }
- { \mw_prg_case_meaning_aux:Nw #1 }
- }
-\cs_new:Npn \mw_exp_after:Nf #1
- { \exp_after:wN #1 \tex_romannumeral:D -`0 }
-\cs_new_protected_nopar:Npn \mw_immediate:w
- {
- \scan_stop: %^^A?
- \mw_exp_after:Nf \mw_immediate_aux:w
- }
-\cs_new_protected_nopar:Npn \mw_immediate_aux:w
- {
- \peek_meaning:NT \mw_scan_stop:
- { \mw_immediate_mw_scan_stop:N }
- }
-\cs_new_protected_nopar:Npn \mw_immediate_mw_scan_stop:N #1
- {
- \str_if_eq:nnTF { #1 } { \mw_scan_stop: }
- { \mw_immediate_do:NN }
+ \tl_if_eq:nnTF { #1 } { \s__morewrites }
+ { \__morewrites_immediate_iv:NN }
{ #1 }
}
-\cs_new_protected_nopar:Npn \mw_immediate_do:NN #1 #2
+\cs_new_protected:Npn \__morewrites_immediate_iv:NN #1 #2
{
- \exp_args:Nc \mw_parse_number:Nw
+ \exp_args:Nc #1
{
- \exp_after:wN \mw_immediate_do_aux:w
+ \exp_after:wN \__morewrites_immediate_v:w
\token_to_str:N #2
}
}
\use:x
{
- \cs_new_protected_nopar:Npn \exp_not:N \mw_immediate_do_aux:w
- ##1 \tl_to_str:n {mw_} { mw_immediate_ }
+ \cs_new:Npn \exp_not:N \__morewrites_immediate_v:w
+ ##1 \tl_to_str:n { __morewrites } { __morewrites_immediate }
}
-\cs_new_protected_nopar:Npn \mw_immediate_closeout_test:
+\cs_new_protected:Npn \__morewrites_immediate_closeout_test:n #1
{
- \seq_if_in:NVTF \g_mw_reserved_writes_seq \g_mw_stream_int
- { \mw_tex_immediate:w \mw_tex_closeout:w \g_mw_stream_int }
- { \mw_immediate_closeout_aux: }
+ \int_gset:Nn \g__morewrites_stream_int {#1}
+ \clist_if_in:NnTF \g__morewrites_reserved_iow_clist {#1}
+ { \__morewrites_tex_immediate:w \__morewrites_tex_closeout:w \g__morewrites_stream_int }
+ { \__morewrites_immediate_closeout_aux: }
}
-\cs_new_protected_nopar:Npn \mw_immediate_closeout_aux:
+\cs_new_protected_nopar:Npn \__morewrites_immediate_closeout_aux:
{
- \exp_args:NNV \prop_pop:NnNT
- \g_mw_writes_prop \g_mw_stream_int \l_mw_tmpa_tl
+ \exp_args:NNV \prop_pop:NnNT \g__morewrites_iow_prop
+ \g__morewrites_stream_int \l__morewrites_internal_tl
{
- \mw_tex_immediate:w \mw_tex_openout:w
- \g_mw_write \l_mw_tmpa_tl \scan_stop:
- \group_begin:
- \int_set_eq:NN \tex_newlinechar:D \c_minus_one
- \tl_use:c { g_mw_write_ \int_use:N \g_mw_stream_int _tl }
- \tl_gclear:c { g_mw_write_ \int_use:N \g_mw_stream_int _tl }
- \group_end:
- \mw_tex_immediate:w \mw_tex_closeout:w \g_mw_write
+ \__morewrites_immediate_write_and_close:nn
+ { \g__morewrites_stream_int } { \l__morewrites_internal_tl }
}
}
-\cs_new_protected_nopar:Npn \mw_immediate_openout_test:
+\cs_new_protected:Npn \__morewrites_immediate_write_and_close:nn #1#2
{
- \seq_if_in:NVTF \g_mw_reserved_writes_seq \g_mw_stream_int
- { \mw_tex_immediate:w \mw_tex_openout:w \g_mw_stream_int }
- { \mw_parse_equals_filename:Nw \mw_immediate_openout_aux: }
+ \__morewrites_tex_immediate:w \__morewrites_tex_openout:w
+ \g__morewrites_iow #2 \scan_stop:
+ \group_begin:
+ \int_set_eq:NN \tex_newlinechar:D \c_minus_one
+ \tl_use:c { g__morewrites_iow_ \int_eval:n {#1} _tl }
+ \tl_gclear:c { g__morewrites_iow_ \int_eval:n {#1} _tl }
+ \group_end:
+ \__morewrites_tex_immediate:w \__morewrites_tex_closeout:w \g__morewrites_iow
}
-\cs_new_protected_nopar:Npn \mw_immediate_openout_aux:
+\cs_new_protected:Npn \__morewrites_immediate_openout_test:n #1
{
- \mw_immediate_closeout_aux:
- \prop_gput:NVV \g_mw_writes_prop \g_mw_stream_int \g_mw_filename_tl
- \tl_gclear_new:c { g_mw_write_ \int_use:N \g_mw_stream_int _tl }
+ \int_gset:Nn \g__morewrites_stream_int {#1}
+ \clist_if_in:NnTF \g__morewrites_reserved_iow_clist {#1}
+ { \__morewrites_tex_immediate:w \__morewrites_tex_openout:w \g__morewrites_stream_int }
+ { \__morewrites_equals_file_name:N \__morewrites_immediate_openout_aux:n }
}
-\cs_new_protected_nopar:Npn \mw_immediate_write_test:
+\cs_new_protected:Npn \__morewrites_immediate_openout_aux:n #1
{
- \seq_if_in:NVTF \g_mw_reserved_writes_seq \g_mw_stream_int
- { \mw_tex_immediate:w \mw_tex_write:w \g_mw_stream_int }
- { \mw_parse_text:Nw \mw_immediate_write_aux: }
+ \__morewrites_immediate_closeout_aux:
+ \prop_gput:NVn \g__morewrites_iow_prop \g__morewrites_stream_int {#1}
+ \tl_gclear_new:c { g__morewrites_iow_ \int_use:N \g__morewrites_stream_int _tl }
}
-\cs_new_protected_nopar:Npn \mw_immediate_write_aux:
+\cs_new_protected:Npn \__morewrites_immediate_write_test:n #1
{
- \prop_if_in:NVTF \g_mw_writes_prop \g_mw_stream_int
- {
- \mw_tex_immediate:w \mw_tex_openout:w \g_mw_write
- \c_mw_tmp_file_tl \scan_stop:
- \mw_tex_immediate:w \mw_tex_write:w \g_mw_write { \g_mw_text_tl }
- \mw_tex_immediate:w \mw_tex_closeout:w \g_mw_write
- \group_begin:
- \int_set_eq:NN \tex_endlinechar:D \c_minus_one
- \mw_tex_openin:w \g_mw_read \c_mw_tmp_file_tl \scan_stop:
- \mw_immediate_write_aux_readlines:
- \mw_tex_closein:w \g_mw_read
- \group_end:
- }
- {
- \mw_tex_immediate:w \mw_tex_write:w
- \if_num:w \g_mw_stream_int < \c_zero
- -1
- \else:
- 16
- \fi:
- { \g_mw_text_tl }
- }
+ \int_gset:Nn \g__morewrites_stream_int {#1}
+ \clist_if_in:NnTF \g__morewrites_reserved_iow_clist {#1}
+ { \__morewrites_tex_immediate:w \__morewrites_tex_write:w \g__morewrites_stream_int }
+ { \primargs_get_general_text:N \__morewrites_immediate_write_aux:n }
}
-\cs_new_protected_nopar:Npn \mw_immediate_write_aux_readlines:
+\cs_new_protected_nopar:Npn \__morewrites_immediate_write_aux:n
{
- \mw_etex_readline:w \g_mw_read to \l_tmpa_tl
- \ior_if_eof:NF \g_mw_read
- {
- \tl_gput_right:cx
- { g_mw_write_ \int_use:N \g_mw_stream_int _tl }
- { \mw_tex_immediate:w \mw_tex_write:w \g_mw_write { \l_tmpa_tl } }
- \mw_immediate_write_aux_readlines:
- }
+ \prop_if_in:NVTF \g__morewrites_iow_prop \g__morewrites_stream_int
+ { \__morewrites_immediate_write_open:n }
+ { \__morewrites_immediate_write_closed:n }
}
-\cs_new_protected_nopar:Npn \mw_late_aux:nN #1 #2
+\cs_new_protected:Npn \__morewrites_immediate_write_closed:n #1
{
- \int_gincr:N \g_mw_late_write_int
- \tl_const:cx { c_mw_late_write_ \int_use:N \g_mw_late_write_int _tl }
- {
- \int_gset:Nn \exp_not:N \g_mw_stream_int
- { \exp_not:V \g_mw_stream_int }
- #1
- \exp_not:N #2
- }
- \exp_args:NNx \mw_tex_write:w \g_mw_write
- { `( \int_use:N \g_mw_late_write_int ) }
+ \__morewrites_tex_immediate:w \__morewrites_tex_write:w
+ \if_num:w \g__morewrites_stream_int < \c_zero
+ -1
+ \else:
+ 16
+ \fi:
+ {#1}
}
-\cs_new_protected_nopar:Npn \mw_openout:w
- { \mw_scan_stop: \mw_parse_number:Nw \mw_openout_test: }
-\cs_new_protected_nopar:Npn \mw_openout_test:
+\cs_new_protected:Npn \__morewrites_immediate_write_open:n #1
{
- \seq_if_in:NVTF \g_mw_reserved_writes_seq \g_mw_stream_int
- { \mw_tex_openout:w \g_mw_stream_int }
- { \mw_parse_equals_filename:Nw \mw_openout_aux: }
+ \__morewrites_tex_immediate:w \__morewrites_tex_openout:w \g__morewrites_iow
+ \g__morewrites_tmp_file_tl \scan_stop:
+ \__morewrites_tex_immediate:w \__morewrites_tex_write:w \g__morewrites_iow {#1}
+ \__morewrites_tex_immediate:w \__morewrites_tex_closeout:w \g__morewrites_iow
+ \group_begin:
+ \int_set_eq:NN \tex_endlinechar:D \c_minus_one
+ \tex_openin:D \g__morewrites_ior \g__morewrites_tmp_file_tl \scan_stop:
+ \__morewrites_immediate_write_readlines_loop:
+ \tex_closein:D \g__morewrites_ior
+ \group_end:
}
-\cs_new_protected_nopar:Npn \mw_openout_aux:
+\cs_new_protected_nopar:Npn \__morewrites_immediate_write_readlines_loop:
{
- \mw_late_aux:nN
+ \etex_readline:D \g__morewrites_ior to \l__morewrites_internal_tl
+ \ior_if_eof:NF \g__morewrites_ior
{
- \tl_gset:Nn \exp_not:N \g_mw_filename_tl
- { \exp_not:V \g_mw_filename_tl }
+ \tl_gput_right:cx
+ { g__morewrites_iow_ \int_use:N \g__morewrites_stream_int _tl }
+ {
+ \__morewrites_tex_immediate:w \__morewrites_tex_write:w \g__morewrites_iow
+ { \l__morewrites_internal_tl }
+ }
+ \__morewrites_immediate_write_readlines_loop:
}
- \mw_immediate_openout_aux:
- }
-\cs_new_protected_nopar:Npn \mw_write:w
- { \mw_scan_stop: \mw_parse_number:Nw \mw_write_test: }
-\cs_new_protected_nopar:Npn \mw_write_test:
- {
- \seq_if_in:NVTF \g_mw_reserved_writes_seq \g_mw_stream_int
- { \mw_tex_write:w \g_mw_stream_int }
- { \mw_parse_text:Nw \mw_write_aux: }
}
-\cs_new_protected_nopar:Npn \mw_write_aux:
+\cs_new_protected:Npn \__morewrites_late:n #1
{
- \mw_late_aux:nN
+ \int_gincr:N \g__morewrites_late_write_int
+ \tl_const:cx
{
- \tl_gset:Nn \exp_not:N \g_mw_text_tl
- { \exp_not:V \g_mw_text_tl }
+ c__morewrites_late_write_
+ \int_use:N \g__morewrites_late_write_int
+ _tl
}
- \mw_immediate_write_aux:
- }
-\cs_new_protected_nopar:Npn \mw_closeout:w
- { \mw_scan_stop: \mw_parse_number:Nw \mw_closeout_test: }
-\cs_new_protected_nopar:Npn \mw_closeout_test:
- {
- \seq_if_in:NVTF \g_mw_reserved_writes_seq \g_mw_stream_int
- { \mw_tex_closeout:w \g_mw_stream_int }
- { \mw_closeout_aux: }
- }
-\cs_new_protected_nopar:Npn \mw_closeout_aux:
- { \mw_late_aux:nN { } \mw_immediate_closeout_aux: }
-\cs_new_protected_nopar:Npn \mw_before_shipout:
- {
- \mw_tex_immediate:w \mw_tex_openout:w \g_mw_write
- \c_mw_tmp_file_tl \scan_stop:
- }
-\seq_new:N \g_mw_operations_seq
-\cs_new_protected_nopar:Npn \mw_after_shipout:
- {
- \mw_tex_immediate:w \mw_tex_closeout:w \g_mw_write
+ {
+ \int_gset:Nn \exp_not:N \g__morewrites_stream_int
+ { \exp_not:V \g__morewrites_stream_int }
+ \exp_not:n {#1}
+ }
+ \exp_args:NNx \__morewrites_tex_write:w \g__morewrites_iow
+ { `( \int_use:N \g__morewrites_late_write_int ) }
+ }
+\cs_new_protected_nopar:Npn \__morewrites_openout:w
+ { \s__morewrites \primargs_get_number:N \__morewrites_openout_test:n }
+\cs_new_protected:Npn \__morewrites_openout_test:n #1
+ {
+ \int_gset:Nn \g__morewrites_stream_int {#1}
+ \clist_if_in:NnTF \g__morewrites_reserved_iow_clist {#1}
+ { \__morewrites_tex_openout:w \g__morewrites_stream_int }
+ { \__morewrites_equals_file_name:N \__morewrites_openout_aux:n }
+ }
+\cs_new_protected:Npn \__morewrites_openout_aux:n #1
+ { \__morewrites_late:n { \__morewrites_immediate_openout_aux:n {#1} } }
+\cs_new_protected_nopar:Npn \__morewrites_write:w
+ { \s__morewrites \primargs_get_number:N \__morewrites_write_test:n }
+\cs_new_protected:Npn \__morewrites_write_test:n #1
+ {
+ \int_gset:Nn \g__morewrites_stream_int {#1}
+ \clist_if_in:NnTF \g__morewrites_reserved_iow_clist {#1}
+ { \__morewrites_tex_write:w \g__morewrites_stream_int }
+ { \primargs_get_general_text:N \__morewrites_write_aux:n }
+ }
+\cs_new_protected:Npn \__morewrites_write_aux:n #1
+ { \__morewrites_late:n { \__morewrites_immediate_write_aux:n {#1} } }
+\cs_new_protected_nopar:Npn \__morewrites_closeout:w
+ { \s__morewrites \primargs_get_number:N \__morewrites_closeout_test:n }
+\cs_new_protected:Npn \__morewrites_closeout_test:n #1
+ {
+ \int_gset:Nn \g__morewrites_stream_int {#1}
+ \clist_if_in:NnTF \g__morewrites_reserved_iow_clist {#1}
+ { \__morewrites_tex_closeout:w \g__morewrites_stream_int }
+ { \__morewrites_closeout_aux: }
+ }
+\cs_new_protected_nopar:Npn \__morewrites_closeout_aux:
+ { \__morewrites_late:n { \__morewrites_immediate_closeout_aux: } }
+\cs_new_protected_nopar:Npn \__morewrites_before_shipout:
+ {
+ \__morewrites_tex_immediate:w \__morewrites_tex_openout:w \g__morewrites_iow
+ \g__morewrites_tmp_file_tl \scan_stop:
+ }
+%% ^^A todo: \shipout{\immediate\write4{}} => bug.
+\cs_new_protected_nopar:Npn \__morewrites_after_shipout:
+ {
+ \__morewrites_tex_immediate:w \__morewrites_tex_closeout:w \g__morewrites_iow
\group_begin:
\int_set_eq:NN \tex_endlinechar:D \tex_newlinechar:D
+ \char_set_catcode_other:n { \tex_endlinechar:D }
\tl_map_inline:nn { `(0123456789) }
{ \char_set_catcode_other:n {`##1} }
\etex_everyeof:D { `() \exp_not:N }
- \tl_gset:Nx \g_mw_operations_seq
- { \if_false: } \fi:
- \exp_after:wN \mw_after_shipout_loop:ww
- \tex_input:D \c_mw_tmp_file_tl \scan_stop:
+ \exp_args:NNx
\group_end:
- \seq_map_inline:Nn \g_mw_operations_seq
+ \tl_map_inline:nn
{
- \tl_use:c
- { c_mw_late_write_ ##1 _tl }
+ \exp_after:wN \__morewrites_after_shipout_loop:ww
+ \tex_input:D \g__morewrites_tmp_file_tl \c_space_tl %^^A bug?
}
+ { \tl_use:c { c__morewrites_late_write_ ##1 _tl } }
}
-\cs_new:Npn \mw_after_shipout_loop:ww #1 `( #2 )
+\cs_new:Npn \__morewrites_after_shipout_loop:ww #1 `( #2 )
{
- \tl_if_empty:nTF {#2}
- { \if_false: { \fi: } }
+ \tl_if_empty:nF {#2}
{
- \exp_not:N \seq_item:n {#2}
- \mw_after_shipout_loop:ww
+ {#2}
+ \__morewrites_after_shipout_loop:ww
}
}
\IfFileExists{atbegshi.sty}
@@ -344,85 +253,88 @@
\tl_replace_once:Nnn \AtBegShi@Output
{ \AtBegShi@OrgShipout \box \AtBeginShipoutBox }
{
- \mw_before_shipout:
+ \__morewrites_before_shipout:
\AtBegShi@OrgShipout \box \AtBeginShipoutBox
- \mw_after_shipout:
+ \__morewrites_after_shipout:
}
\tl_replace_once:Nnn \AtBegShi@Output
{ \AtBeginShipoutOriginalShipout \box \AtBeginShipoutBox }
{
- \mw_before_shipout:
+ \__morewrites_before_shipout:
\AtBeginShipoutOriginalShipout \box \AtBeginShipoutBox
- \mw_after_shipout:
+ \__morewrites_after_shipout:
}
}
{
- \cs_new_protected_nopar:Npn \mw_shipout:w
+ \int_new:N \g__morewrites_group_level_int
+ \box_new:N \g__morewrites_shipout_box
+ \cs_new_protected_nopar:Npn \__morewrites_shipout:w
{
- \int_gset_eq:NN \g_mw_tmpa_int \etex_currentgrouplevel:D
- \tex_afterassignment:D \mw_shipout_aux:
- \tex_global:D \tex_setbox:D \g_mw_box
+ \int_gset_eq:NN \g__morewrites_group_level_int \etex_currentgrouplevel:D
+ \tex_afterassignment:D \__morewrites_shipout_i:
+ \tex_global:D \tex_setbox:D \g__morewrites_shipout_box
}
- \cs_new_protected_nopar:Npn \mw_shipout_aux:
+ \cs_new_protected_nopar:Npn \__morewrites_shipout_i:
{
- \int_compare:nNnTF { \g_mw_tmpa_int }
+ \int_compare:nNnTF { \g__morewrites_group_level_int }
= { \etex_currentgrouplevel:D }
- { \mw_shipout_aux_ii: }
- { \tex_aftergroup:D \mw_shipout_aux_ii: }
+ { \__morewrites_shipout_ii: }
+ { \tex_aftergroup:D \__morewrites_shipout_ii: }
}
- \cs_new_protected_nopar:Npn \mw_shipout_aux_ii:
+ \cs_new_protected_nopar:Npn \__morewrites_shipout_ii:
{
- \mw_before_shipout:
- \mw_tex_shipout:w \tex_box:D \g_mw_box
- \mw_after_shipout:
+ \__morewrites_before_shipout:
+ \__morewrites_tex_shipout:w \tex_box:D \g__morewrites_shipout_box
+ \__morewrites_after_shipout:
}
- \cs_gset_eq:NN \shipout \mw_shipout:w
+ \AtBeginDocument { \cs_gset_eq:NN \shipout \__morewrites_shipout:w }
}
-\cs_new_protected_nopar:Npn \mw_close_all:
+\int_new:N \g__morewrites_at_end_int
+\int_gset:Nn \g__morewrites_at_end_int { 10 }
+\cs_new_protected_nopar:Npn \__morewrites_close_all:
{
- \prop_map_inline:Nn \g_mw_writes_prop
- {
- \mw_tex_immediate:w \mw_tex_openout:w \g_mw_write ##2 \scan_stop:
- \group_begin:
- \int_set_eq:NN \tex_newlinechar:D \c_minus_one
- \tl_use:c { g_mw_write_ ##1 _tl }
- \tl_gclear:c { g_mw_write_ ##1 _tl }
- \group_end:
- \mw_tex_immediate:w \mw_tex_closeout:w \g_mw_write
- }
- \prop_gclear:N \g_mw_writes_prop
+ \prop_map_function:NN \g__morewrites_iow_prop
+ \__morewrites_immediate_write_and_close:nn
+ \prop_gclear:N \g__morewrites_iow_prop
}
- % \IfFileExists{atveryend.sty} { \use_i:nn } { \use_ii:nn }
- % {
- % \RequirePackage {atveryend} [2011/06/29]
- % \AtVeryVeryEnd { \mw_close_all: }
- % }
- % {
- \cs_new_protected:Npn \mw_put_at_end:Nw #1 #2 \@@end
+\cs_set:Npn \__morewrites_tmp:w #1
+ {
+ \cs_new_protected:Npn \__morewrites_close_all_at_end:w ##1 #1
{
- \tl_if_empty:nTF {#2}
- { #1 \@@end }
- { #2 \mw_put_at_end:Nw #1 \@@end }
+ \int_gdecr:N \g__morewrites_at_end_int
+ \int_compare:nNnTF \g__morewrites_at_end_int > \c_zero
+ {
+ \tl_if_empty:nTF {##1}
+ { ##1 \__morewrites_close_all: }
+ { ##1 \__morewrites_close_all_at_end:w }
+ }
+ { \__morewrites_close_all: ##1 }
+ #1
}
- \AtEndDocument { \mw_put_at_end:Nw \mw_close_all: }
- % }
-\countdef \mw_write_int 17 \scan_stop:
-\cs_new:Npn \mw_newwrite:N #1
+ }
+\exp_args:Nc \__morewrites_tmp:w { @ @ end }
+\AtEndDocument { \__morewrites_close_all_at_end:w }
+\tex_countdef:D \g__morewrites_alloc_int 17 \scan_stop:
+\cs_new:Npn \__morewrites_newwrite:N #1
{
- \if_num:w \mw_write_int = \c_sixteen
- \int_gset:Nn \mw_write_int { 20 }
+ \int_gincr:N \g__morewrites_alloc_int
+ \if_num:w \g__morewrites_alloc_int = \c_sixteen
+ \int_gset:Nn \g__morewrites_alloc_int { 20 }
\fi:
- \int_set_eq:NN \allocationnumber \mw_write_int
- \int_gincr:N \mw_write_int
+ \int_set_eq:NN \allocationnumber \g__morewrites_alloc_int
\cs_undefine:N #1
\int_const:Nn #1 { \allocationnumber }
- \wlog {\string #1=\string \write \the \allocationnumber }
+ \wlog
+ {
+ \token_to_str:N #1
+ = \token_to_str:N \write \int_use:N \allocationnumber
+ }
}
-\cs_gset_eq:NN \immediate \mw_immediate:w
-\cs_gset_eq:NN \openout \mw_openout:w
-\cs_gset_eq:NN \write \mw_write:w
-\cs_gset_eq:NN \closeout \mw_closeout:w
-\cs_gset_eq:NN \newwrite \mw_newwrite:N
+\cs_gset_eq:NN \immediate \__morewrites_immediate:w
+\cs_gset_eq:NN \openout \__morewrites_openout:w
+\cs_gset_eq:NN \write \__morewrites_write:w
+\cs_gset_eq:NN \closeout \__morewrites_closeout:w
+\cs_gset_eq:NN \newwrite \__morewrites_newwrite:N
%%
%%
%% End of file `morewrites.sty'.
diff --git a/Master/texmf-dist/tex/latex/morewrites/primargs.sty b/Master/texmf-dist/tex/latex/morewrites/primargs.sty
new file mode 100644
index 00000000000..81ed7e6c153
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/morewrites/primargs.sty
@@ -0,0 +1,197 @@
+%%
+%% This is file `primargs.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% primargs.dtx (with options: `package')
+%%
+%% Communicate any suggestions for changing this package
+%% to Bruno Le Floch (blflatex@gmail.com).
+%%
+%% File: primargs.dtx Copyright (C) 2012 Bruno Le Floch
+%%
+%% It may be distributed and/or modified under the conditions of the
+%% LaTeX Project Public License (LPPL), either version 1.3c of this
+%% license or (at your option) any later version. The latest version
+%% of this license is in the file
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% -----------------------------------------------------------------------
+\RequirePackage{l3names}
+\ProvidesExplPackage
+ {primargs}{2012/07/10}{0.1}{Parsing~arguments~of~primitives}
+\RequirePackage{expl3}
+\cs_new_protected_nopar:Npn \g__primargs_code_tl { }
+\cs_new_protected_nopar:Npn \__primargs_no_afterassignment:
+ { \tex_afterassignment:D \tex_relax:D }
+\cs_new_protected_nopar:Npn \__primargs_no_localdefs:
+ {
+ \__primargs_no_afterassignment:
+ \int_compare:nNnF \tex_globaldefs:D > \c_zero
+ { \tex_globaldefs:D = \c_zero }
+ }
+\cs_new_protected_nopar:Npn \primargs_read_x_token:N
+ {
+ \group_begin:
+ \__primargs_no_localdefs:
+ \__primargs_read_x_token:N
+ }
+\cs_new_protected_nopar:Npn \__primargs_read_x_token:N
+ {
+ \tex_afterassignment:D \__primargs_read_x_token_ii:N
+ \tex_global:D \tex_futurelet:D \g_primargs_token
+ }
+\cs_new_protected_nopar:Npn \__primargs_read_x_token_ii:N
+ {
+ \exp_after:wN
+ \if_meaning:w \exp_not:N \g_primargs_token \g_primargs_token
+ \group_end:
+ \exp_after:wN \use_none:nnn
+ \fi:
+ \exp_after:wN \__primargs_read_x_token:N \exp_after:wN
+ }
+\cs_new_protected_nopar:Npn \primargs_read_token:N
+ {
+ \group_begin:
+ \__primargs_no_localdefs:
+ \tex_afterassignment:D \group_end:
+ \tex_global:D \tex_futurelet:D \g_primargs_token
+ }
+\cs_new_protected:Npn \primargs_remove_token:N #1
+ {
+ \group_begin:
+ \__primargs_no_localdefs:
+ \tex_aftergroup:D #1
+ \tex_afterassignment:D \group_end:
+ \tex_global:D \tex_let:D \g_primargs_token = ~
+ }
+\cs_new_protected:Npn \primargs_remove_one_optional_space:N #1
+ {
+ \group_begin:
+ \__primargs_no_localdefs:
+ \tex_aftergroup:D #1
+ \primargs_read_x_token:N \__primargs_remove_one_optional_space:
+ }
+\exp_args:NNo \cs_new_protected_nopar:Npn \__primargs_remove_one_optional_space:
+ {
+ \use:n { \if_catcode:w } ~ \exp_not:N \g_primargs_token
+ \exp_after:wN \primargs_remove_token:N
+ \fi:
+ \group_end:
+ }
+\cs_new_protected:Npn \primargs_remove_optional_spaces:N #1
+ {
+ \group_begin:
+ \__primargs_no_localdefs:
+ \tex_aftergroup:D #1
+ \__primargs_remove_optional_spaces:
+ }
+\cs_new_protected_nopar:Npn \__primargs_remove_optional_spaces:
+ { \primargs_read_x_token:N \__primargs_remove_optional_spaces_ii: }
+\exp_args:NNo \cs_new_protected_nopar:Npn \__primargs_remove_optional_spaces_ii:
+ {
+ \use:n { \if_catcode:w } ~ \exp_not:N \g_primargs_token
+ \exp_after:wN \primargs_remove_token:N
+ \exp_after:wN \__primargs_remove_optional_spaces:
+ \else:
+ \exp_after:wN \group_end:
+ \fi:
+ }
+\cs_new_protected:Npn \primargs_remove_equals:N #1
+ {
+ \group_begin:
+ \tex_aftergroup:D #1
+ \primargs_remove_optional_spaces:N \__primargs_remove_equals:
+ }
+\cs_new_protected_nopar:Npn \__primargs_remove_equals:
+ {
+ \if_meaning:w = \g_primargs_token
+ \exp_after:wN \__primargs_remove_equals_ii:NN
+ \fi:
+ \group_end:
+ }
+\cs_new_protected:Npn \__primargs_remove_equals_ii:NN #1#2
+ { \tl_if_eq:nnTF { #2 } { = } { #1 } { #1 #2 } }
+\cs_new_protected:Npn \__primargs_get_rhs:NnN #1#2#3
+ {
+ \group_begin:
+ \__primargs_no_localdefs:
+ \tex_aftergroup:D #3
+ \tl_gset:Nn \g__primargs_code_tl
+ {
+ \use:x
+ {
+ \exp_not:n { #1 = #2 \group_end: }
+ { \tex_the:D #1 }
+ }
+ }
+ \tex_afterassignment:D \g__primargs_code_tl
+ #1 =
+ }
+\cs_generate_variant:Nn \__primargs_get_rhs:NnN { No }
+\cs_new_protected_nopar:Npn \primargs_get_number:N
+ {
+ \__primargs_get_rhs:NoN \tex_deadcycles:D
+ { \tex_the:D \tex_deadcycles:D }
+ }
+\cs_new_protected_nopar:Npn \primargs_get_dimen:N
+ {
+ \__primargs_get_rhs:NoN \tex_hoffset:D
+ { \tex_the:D \tex_hoffset:D }
+ }
+\cs_new_protected_nopar:Npn \primargs_get_glue:N
+ {
+ \__primargs_get_rhs:NoN \tex_topskip:D
+ { \tex_the:D \tex_topskip:D }
+ }
+\cs_new_protected_nopar:Npn \primargs_get_mudimen:N
+ {
+ \msg_warning:nn { primargs } { get-mudimen }
+ \primargs_get_muglue:N
+ }
+\cs_new_protected_nopar:Npn \primargs_get_muglue:N
+ {
+ \__primargs_get_rhs:NoN \tex_thinmuskip:D
+ { \tex_the:D \tex_thinmuskip:D }
+ }
+\cs_new_protected_nopar:Npn \primargs_get_general_text:N
+ { \__primargs_get_rhs:NoN \tex_errhelp:D { { } } }
+\tl_new:N \g__primargs_file_name_tl
+\cs_new_protected:Npn \primargs_get_file_name:N #1
+ {
+ \group_begin:
+ \__primargs_no_localdefs:
+ \tex_aftergroup:D #1
+ \tl_gclear:N \g__primargs_file_name_tl
+ \primargs_remove_optional_spaces:N \__primargs_get_file_name_test:
+ }
+\cs_new_protected_nopar:Npn \__primargs_get_file_name_test:
+ {
+ \token_if_cs:NTF \g_primargs_token
+ { \__primargs_get_file_name_end: }
+ {
+ \token_if_eq_charcode:NNTF \c_space_token \g_primargs_token
+ { \primargs_remove_token:N \__primargs_get_file_name_end: }
+ { \primargs_remove_token:N \__primargs_get_file_name_char: }
+ }
+ }
+\cs_new_protected_nopar:Npn \__primargs_get_file_name_end:
+ { \exp_args:No \group_end: \g__primargs_file_name_tl }
+\cs_new_protected_nopar:Npn \__primargs_get_file_name_char:
+ {
+ \tl_gput_right:Nx \g__primargs_file_name_tl
+ {
+ \exp_after:wN \__primargs_get_file_name_char_ii:w
+ \token_to_meaning:N \g_primargs_token
+ \q_stop
+ }
+ \primargs_read_x_token:N \__primargs_get_file_name_test:
+ }
+\cs_new:Npn \__primargs_get_file_name_char_ii:w #1 ~ #2 ~ #3 \q_stop
+ { \__primargs_get_file_name_char_iii:w #3 ~ #3 ~ \q_stop }
+\cs_new:Npn \__primargs_get_file_name_char_iii:w #1 ~ #2 ~ #3 \q_stop {#2}
+%%
+%%
+%% End of file `primargs.sty'.