summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3sys.dtx
blob: 46ee4aabd322acd45fa88dc3704d6d5e93ba4d5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
% \iffalse meta-comment
%
%% File: l3sys.dtx Copyright (C) 2015-2017 The LaTeX3 Project
%
% 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
%
% This file is part of the "l3kernel bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
%    https://github.com/latex3/latex3
%
% for those people who are interested.
%
%<*driver>
\documentclass[full]{l3doc}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \title{^^A
%   The \pkg{l3sys} package\\System/runtime functions^^A
% }
%
% \author{^^A
%  The \LaTeX3 Project\thanks
%    {^^A
%      E-mail:
%        \href{mailto:latex-team@latex-project.org}
%          {latex-team@latex-project.org}^^A
%    }^^A
% }
%
% \date{Released 2017/11/14}
%
% \maketitle
%
% \begin{documentation}
%
% \section{The name of the job}
%
% \begin{variable}[added = 2015-09-19]{\c_sys_jobname_str}
%   Constant that gets the \enquote{job name} assigned when \TeX{} starts.
%   \begin{texnote}
%     This copies the contents of the primitive \tn{jobname}. It is a constant
%     that is set by \TeX{} and should not be overwritten by the package.
%   \end{texnote}
% \end{variable}
%
% \section{Date and time}
% 
% \begin{variable}[added = 2015-09-22]
%   {
%     \c_sys_minute_int,
%     \c_sys_hour_int,
%     \c_sys_day_int,
%     \c_sys_month_int,
%     \c_sys_year_int,
%   }
%   The date and time at which the current job was started: these are
%   all reported as integers.
%   \begin{texnote}
%     Whilst the underlying primitives can be altered by the user, this
%     interface to the time and date is intended to be the \enquote{real}
%     values.
%   \end{texnote}
% \end{variable}
%
% \section{Engine}
%
% \begin{function}[added = 2015-09-07, EXP, pTF]
%   {
%     \sys_if_engine_luatex:,
%     \sys_if_engine_pdftex:,
%     \sys_if_engine_ptex:  ,
%     \sys_if_engine_uptex: ,
%     \sys_if_engine_xetex:
%   }
%   \begin{syntax}
%     \cs{sys_if_engine_pdftex:TF} \Arg{true code} \Arg{false code}
%   \end{syntax}
%   Conditionals which allow engine-specific code to be used. The names
%   follow naturally from those of the engine binaries: note that the
%   |(u)ptex| tests are for \epTeX{} and \eupTeX{} as \pkg{expl3} requires
%   the \eTeX{} extensions. Each conditional is true for
%   \emph{exactly one} supported engine. In particular,
%   |\sys_if_engine_ptex_p:| is true for \epTeX{} but false for \eupTeX{}.
% \end{function}
%
% \begin{variable}[added = 2015-09-19]{\c_sys_engine_str}
%   The current engine given as a lower case string: one of
%   |luatex|, |pdftex|, |ptex|, |uptex| or |xetex|.
% \end{variable}
%
% \section{Output format}
%
% \begin{function}[added = 2015-09-19, EXP, pTF]
%   {
%     \sys_if_output_dvi:,
%     \sys_if_output_pdf:
%   }
%   \begin{syntax}
%     \cs{sys_if_output_dvi:TF} \Arg{true code} \Arg{false code}
%   \end{syntax}
%   Conditionals which give the current output mode the \TeX{} run is
%   operating in. This is always one of two outcomes, DVI mode or
%   PDF mode. The two sets of conditionals are thus complementary and
%   are both provided to allow the programmer to emphasise the most
%   appropriate case.
% \end{function}
%
% \begin{variable}[added = 2015-09-19]{\c_sys_output_str}
%   The current output mode given as a lower case string: one of
%   |dvi| or |pdf|.
% \end{variable}
%
% \end{documentation}
%
% \begin{implementation}
%
% \section{\pkg{l3sys} implementation}
%
%    \begin{macrocode}
%<*initex|package>
%    \end{macrocode}
%
% \subsection{The name of the job}
%
% \begin{variable}{\c_sys_jobname_str}
%   Inherited from the \LaTeX3 name for the primitive: this needs to
%   actually contain the text of the job name rather than the name of
%   the primitive, of course.
%    \begin{macrocode}
%<*initex>
\tex_everyjob:D \exp_after:wN
  {
    \tex_the:D \tex_everyjob:D
    \str_const:Nx \c_sys_jobname_str { \tex_jobname:D }
  }
%</initex>
%<*package>
\str_const:Nx \c_sys_jobname_str { \tex_jobname:D }
%</package>
%    \end{macrocode}
% \end{variable}
%
% \subsection{Time and date}
%
% \begin{variable}
%   {
%     \c_sys_minute_int,
%     \c_sys_hour_int,
%     \c_sys_day_int,
%     \c_sys_month_int,
%     \c_sys_year_int,
%   }
%   Copies of the information provided by \TeX{}
%    \begin{macrocode}
\int_const:Nn \c_sys_minute_int
  { \int_mod:nn { \tex_time:D } { 60 } }
\int_const:Nn \c_sys_hour_int
  { \int_div_truncate:nn { \tex_time:D } { 60 } }
\int_const:Nn \c_sys_day_int   { \tex_day:D }
\int_const:Nn \c_sys_month_int { \tex_month:D }
\int_const:Nn \c_sys_year_int  { \tex_year:D }
%    \end{macrocode}
% \end{variable}
%
% \subsection{Detecting the engine}
%
% \begin{macro}[pTF, EXP]
%   {
%     \sys_if_engine_luatex:,
%     \sys_if_engine_pdftex:,
%     \sys_if_engine_ptex:,
%     \sys_if_engine_uptex:,
%     \sys_if_engine_xetex:
%   }
% \begin{variable}{\c_sys_engine_str}
%   Set up the engine tests on the basis exactly one test should be true.
%   Mainly a case of looking for the appropriate marker primitive. For
%   \upTeX{}, there is a complexity in that setting |-kanji-internal=sjis|
%   or |-kanji-internal=euc| effective makes it more like \pTeX{}. In those
%   cases we therefore report \pTeX{} rather than \upTeX{}.
%    \begin{macrocode}
\clist_map_inline:nn { lua , pdf , p , up , xe }
  {
    \cs_new_eq:cN { sys_if_engine_ #1 tex:T }  \use_none:n
    \cs_new_eq:cN { sys_if_engine_ #1 tex:F }  \use:n
    \cs_new_eq:cN { sys_if_engine_ #1 tex:TF } \use_ii:nn
    \cs_new_eq:cN { sys_if_engine_ #1 tex_p: } \c_false_bool
  }
\cs_if_exist:NT \luatex_luatexversion:D
  {
    \cs_gset_eq:NN \sys_if_engine_luatex:T  \use:n
    \cs_gset_eq:NN \sys_if_engine_luatex:F  \use_none:n
    \cs_gset_eq:NN \sys_if_engine_luatex:TF \use_i:nn
    \cs_gset_eq:NN \sys_if_engine_luatex_p: \c_true_bool
    \str_const:Nn \c_sys_engine_str { luatex }
  }
\cs_if_exist:NT \pdftex_pdftexversion:D
  {
    \cs_gset_eq:NN \sys_if_engine_pdftex:T  \use:n
    \cs_gset_eq:NN \sys_if_engine_pdftex:F  \use_none:n
    \cs_gset_eq:NN \sys_if_engine_pdftex:TF \use_i:nn
    \cs_gset_eq:NN \sys_if_engine_pdftex_p: \c_true_bool
    \str_const:Nn \c_sys_engine_str { pdftex }
  }
\cs_if_exist:NT \ptex_kanjiskip:D
  {
    \bool_lazy_and:nnTF
      { \cs_if_exist_p:N \uptex_disablecjktoken:D }
      { \int_compare_p:nNn { \ptex_jis:D "2121 } = { "3000 } }
      {
        \cs_gset_eq:NN \sys_if_engine_uptex:T  \use:n
        \cs_gset_eq:NN \sys_if_engine_uptex:F  \use_none:n
        \cs_gset_eq:NN \sys_if_engine_uptex:TF \use_i:nn
        \cs_gset_eq:NN \sys_if_engine_uptex_p: \c_true_bool
        \str_const:Nn \c_sys_engine_str { uptex }
      }
      {
        \cs_gset_eq:NN \sys_if_engine_ptex:T  \use:n
        \cs_gset_eq:NN \sys_if_engine_ptex:F  \use_none:n
        \cs_gset_eq:NN \sys_if_engine_ptex:TF \use_i:nn
        \cs_gset_eq:NN \sys_if_engine_ptex_p: \c_true_bool
        \str_const:Nn \c_sys_engine_str { ptex }
      }
  }
\cs_if_exist:NT \xetex_XeTeXversion:D
  {
    \cs_gset_eq:NN \sys_if_engine_xetex:T  \use:n
    \cs_gset_eq:NN \sys_if_engine_xetex:F  \use_none:n
    \cs_gset_eq:NN \sys_if_engine_xetex:TF \use_i:nn
    \cs_gset_eq:NN \sys_if_engine_xetex_p: \c_true_bool
    \str_const:Nn \c_sys_engine_str { xetex }
  }
%    \end{macrocode}
% \end{variable}
% \end{macro}
%
% \subsection{Detecting the output}
%
% \begin{macro}[pTF, EXP]
%   {
%     \sys_if_output_dvi:,
%     \sys_if_output_pdf:
%   }
% \begin{variable}{\c_sys_output_str}
%   This is a simple enough concept: the two views here are complementary.
%    \begin{macrocode}
\int_compare:nNnTF
  { \cs_if_exist_use:NF \pdftex_pdfoutput:D { 0 } } > { 0 }
  {
    \cs_new_eq:NN \sys_if_output_dvi:T  \use_none:n
    \cs_new_eq:NN \sys_if_output_dvi:F  \use:n
    \cs_new_eq:NN \sys_if_output_dvi:TF \use_ii:nn
    \cs_new_eq:NN \sys_if_output_dvi_p: \c_false_bool
    \cs_new_eq:NN \sys_if_output_pdf:T  \use:n
    \cs_new_eq:NN \sys_if_output_pdf:F  \use_none:n
    \cs_new_eq:NN \sys_if_output_pdf:TF \use_i:nn
    \cs_new_eq:NN \sys_if_output_pdf_p: \c_true_bool
    \str_const:Nn \c_sys_output_str { pdf }
  }
  {
    \cs_new_eq:NN \sys_if_output_dvi:T  \use:n
    \cs_new_eq:NN \sys_if_output_dvi:F  \use_none:n
    \cs_new_eq:NN \sys_if_output_dvi:TF \use_i:nn
    \cs_new_eq:NN \sys_if_output_dvi_p: \c_true_bool
    \cs_new_eq:NN \sys_if_output_pdf:T  \use_none:n
    \cs_new_eq:NN \sys_if_output_pdf:F  \use:n
    \cs_new_eq:NN \sys_if_output_pdf:TF \use_ii:nn
    \cs_new_eq:NN \sys_if_output_pdf_p: \c_false_bool
    \str_const:Nn \c_sys_output_str { dvi }
  }
%    \end{macrocode}
% \end{variable}
% \end{macro}
%
%    \begin{macrocode}
%</initex|package>
%    \end{macrocode}
%
%\end{implementation}
%
%\PrintIndex