From 3c2f50b92407533aabaef1823006032eedd6ef90 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Tue, 17 Jun 2014 22:32:09 +0000
Subject: l3

git-svn-id: svn://tug.org/texlive/trunk@34268 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/latex/l3kernel/l3file.dtx | 54 ++++++++++++++++------
 1 file changed, 40 insertions(+), 14 deletions(-)

(limited to 'Master/texmf-dist/source/latex/l3kernel/l3file.dtx')

diff --git a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
index 45bb0ec7adf..2c9210f8d76 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
@@ -37,7 +37,7 @@
 \documentclass[full]{l3doc}
 %</driver>
 %<*driver|package>
-\GetIdInfo$Id: l3file.dtx 4737 2014-05-05 07:37:48Z joseph $
+\GetIdInfo$Id: l3file.dtx 4890 2014-05-26 20:59:31Z joseph $
   {L3 File and I/O operations}
 %</driver|package>
 %<*driver>
@@ -83,8 +83,9 @@
 % may contain both literal items and expandable content, which should on
 % full expansion be the desired file name.  Any active characters (as
 % declared in \cs{l_char_active_seq}) will \emph{not} be expanded,
-% allowing the direct use of these in file names.
-% Spaces are not allowed in file names.
+% allowing the direct use of these in file names. File names will be quoted
+% using |"| tokens if they contain spaces: as a result, |"| tokens are
+% \emph{not} permitted in file names.
 %
 % \section{File operation functions}
 %
@@ -500,7 +501,7 @@
 %
 % \subsection{Internal file functions and variables}
 %
-% \begin{variable}{\l__file_internal_name_ior}
+% \begin{variable}{\g__file_internal_ior}
 %   Used to test for the existence of files when opening.
 % \end{variable}
 %
@@ -638,9 +639,13 @@
 %    \end{macrocode}
 % \end{variable}
 %
-% \begin{macro}[aux]{\@@_name_sanitize:nn}
+% \begin{macro}[int]{\@@_name_sanitize:nn}
+% \begin{macro}[int, aux]{\@@_name_sanitize_aux:n}
 %   For converting a token list to a string where active characters are treated
-%   as strings from the start.
+%   as strings from the start. The logic to the quoting normalisation is the
+%   same as used by \texttt{lualatexquotejobname}: check for balanced |"|, and
+%   assuming they balance strip all of them out before quoting the entire name
+%   if it contains spaces.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_name_sanitize:nn #1#2
   {
@@ -650,20 +655,42 @@
       \tl_set:Nx \l_@@_internal_name_tl {#1}
       \tl_set:Nx \l_@@_internal_name_tl
         { \tl_to_str:N \l_@@_internal_name_tl }
-      \tl_if_in:NnT \l_@@_internal_name_tl { ~ }
+      \int_compare:nNnTF
         {
-          \__msg_kernel_error:nnx { kernel } { space-in-file-name }
-            { \l_@@_internal_name_tl }
-          \tl_remove_all:Nn \l_@@_internal_name_tl { ~ }
+          \int_mod:nn
+            {
+              0 \tl_map_function:NN \l_@@_internal_name_tl
+                \@@_name_sanitize_aux:n
+            }
+            \c_two
         }
+        = \c_zero
+        {
+          \tl_remove_all:Nn \l_@@_internal_name_tl { " }
+          \tl_if_in:NnT \l_@@_internal_name_tl { ~ }
+            {
+              \tl_set:Nx \l_@@_internal_name_tl
+                { " \exp_not:V \l_@@_internal_name_tl " }
+            }
+        }
+        {
+          \__msg_kernel_error:nnx { kernel } { unbalanced-quote-in-filename }
+            { \l_@@_internal_name_tl }
+        }  
       \use:x
         {
           \group_end:
           \exp_not:n {#2} { \l_@@_internal_name_tl }
         }
   }
+\cs_new:Npn \@@_name_sanitize_aux:n #1
+  {
+    \str_if_eq:nnT {#1} { " }
+      { + \c_one }
+  }
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\file_add_path:nN}
 % \begin{macro}[aux]{\@@_add_path:nN, \@@_add_path_search:nN}
@@ -1710,11 +1737,10 @@
     All~16~are~currently~in~use,~and~something~wanted~to~open~
     another~one.
   }
-\__msg_kernel_new:nnnn { kernel } { space-in-file-name }
-  { Space~in~file~name~'#1'. }
+\__msg_kernel_new:nnnn { kernel } { unbalanced-quote-in-filename }
+  { Unbalanced~quotes~in~file~name~'#1'. }
   {
-    Spaces~are~not~permitted~in~files~loaded~by~LaTeX: \\
-    Further~errors~may~follow!
+    File~names~must~contain~balanced~numbers~of~quotes~(").
   }
 %    \end{macrocode}
 %
-- 
cgit v1.2.3

