[latex3-commits] [git/LaTeX3-latex3-latex3] master: Use \ifeof approach to test pseudo-files (35a2576ea)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Sep 3 13:32:52 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/35a2576eac9452dd95642f9c83669a6353f94f02

>---------------------------------------------------------------

commit 35a2576eac9452dd95642f9c83669a6353f94f02
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Sep 3 12:32:52 2019 +0100

    Use \ifeof approach to test pseudo-files
    
    The \pdffilesize primitive reports nothing for e.g.
    /dev/null.


>---------------------------------------------------------------

35a2576eac9452dd95642f9c83669a6353f94f02
 l3kernel/l3candidates.dtx | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index a73fb11ce..37a71ed1b 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -2234,7 +2234,9 @@
 %   Detecting the platform on \LuaTeX{} is easy: for other engines, we use
 %   the fact that the two common cases have special null files. It is possible
 %   to probe further (see package \pkg{platform}), but that requires shell
-%   escape and seems unlikely to be useful.
+%   escape and seems unlikely to be useful. As the test here is not using
+%   real files, we have to use a \enquote{raw} approach to checking for
+%   \enquote{files}.
 %    \begin{macrocode}
 \sys_if_engine_luatex:TF
   {
@@ -2242,15 +2244,25 @@
       { \lua_now:n { tex.print(os.type) } }
   }
   {
-    \file_if_exist:nTF { nul: }
-      {
-        \file_if_exist:nF { /dev/null }
-          { \str_const:Nn \c_sys_platform_str { windows } }
-      }
-      {
-        \file_if_exist:nT { /dev/null }
-          { \str_const:Nn \c_sys_platform_str { unix } }
-      }
+    \group_begin:
+      \cs_set_eq:Nc \g_@@_internal_ior { g_ _file_internal_ior }
+      \cs_set_protected:Npn \@@_if_exist:nTF #1#2#3
+        {
+          \__kernel_ior_open:Nn \g_@@_internal_ior {#1}
+          \ior_if_eof:NTF \g_@@_internal_ior {#3} {#2}
+        }
+      \@@_if_exist:nTF { nul: }
+        {
+          \@@_if_exist:nTF { /dev/null }
+            { }
+            { \str_const:Nn \c_sys_platform_str { windows } }
+        }
+        {
+          \@@_if_exist:nTF { /dev/null }
+            { \str_const:Nn \c_sys_platform_str { unix } }
+            { }
+        }
+    \group_end:
   }
 \cs_if_exist:NF \c_sys_platform_str
   { \str_const:Nn \c_sys_platform_str { unknown }  }





More information about the latex3-commits mailing list