[latex3-commits] [git/LaTeX3-latex3-latex2e] utf8andspace: initial utf8 and space in filenames tests (ef8164b)
Joseph Wright
joseph.wright at morningstar2.co.uk
Sun Mar 10 09:12:39 CET 2019
Repository : https://github.com/latex3/latex2e
On branch : utf8andspace
Link : https://github.com/latex3/latex2e/commit/ef8164b046b5d1ad18eff7e4e9894b221cc0da9a
>---------------------------------------------------------------
commit ef8164b046b5d1ad18eff7e4e9894b221cc0da9a
Author: David Carlisle <d.p.carlisle at gmail.com>
Date: Sun Feb 10 22:58:55 2019 +0000
initial utf8 and space in filenames tests
>---------------------------------------------------------------
ef8164b046b5d1ad18eff7e4e9894b221cc0da9a
base/build.lua | 1 +
base/config-filenames.lua | 5 +
base/ltfinal.dtx | 2 +
base/testfiles-filename/foo bar.png | Bin 0 -> 726 bytes
base/testfiles-filename/one two three.tex | 1 +
base/testfiles-filename/space-test.lvt | 16 ++
base/testfiles-filename/utf-test.lvt | 86 +++++++++
base/utf8andspace.tex | 289 +++++++++++++++++++++++++++++
8 files changed, 400 insertions(+)
diff --git a/base/build.lua b/base/build.lua
index ff4b54d..ed5ca64 100644
--- a/base/build.lua
+++ b/base/build.lua
@@ -49,6 +49,7 @@ sourcefiles =
"sample2e.tex",
"small2e.tex",
"testpage.tex",
+ "utf8andspace.tex"
}
typesetfiles =
{
diff --git a/base/config-filenames.lua b/base/config-filenames.lua
new file mode 100644
index 0000000..73ae32e
--- /dev/null
+++ b/base/config-filenames.lua
@@ -0,0 +1,5 @@
+-- Tests for non Unicode engines
+
+checkengines = {"pdftex,"xetex","luatex""}
+checksearch = false
+testfiledir = "testfiles-filenames"
diff --git a/base/ltfinal.dtx b/base/ltfinal.dtx
index 9987103..ea60c5e 100644
--- a/base/ltfinal.dtx
+++ b/base/ltfinal.dtx
@@ -1096,6 +1096,8 @@
% \begin{macrocode}
\makeatother
\errorstopmode
+\input{utf8andspace}
+\everyjob\expandafter{\the\everyjob\typeout{^^JUTF-8 and SPACE TESTS^^J}}
\dump
%</2ekernel>
% \end{macrocode}
diff --git a/base/testfiles-filename/foo bar.png b/base/testfiles-filename/foo bar.png
new file mode 100755
index 0000000..1d43d9f
Binary files /dev/null and b/base/testfiles-filename/foo bar.png differ
diff --git a/base/testfiles-filename/one two three.tex b/base/testfiles-filename/one two three.tex
new file mode 100644
index 0000000..b85905e
--- /dev/null
+++ b/base/testfiles-filename/one two three.tex
@@ -0,0 +1 @@
+1 2 3
diff --git a/base/testfiles-filename/space-test.lvt b/base/testfiles-filename/space-test.lvt
new file mode 100644
index 0000000..ea2e7b9
--- /dev/null
+++ b/base/testfiles-filename/space-test.lvt
@@ -0,0 +1,16 @@
+\input{utf8andspace}
+\documentclass{article}
+\usepackage{graphicx}
+\listfiles
+\begin{document}
+
+
+\input{one two three}
+
+\includegraphics{foo bar}
+
+
+\includegraphics[scale=2]{foo bar}
+
+
+\end{document}
diff --git a/base/testfiles-filename/utf-test.lvt b/base/testfiles-filename/utf-test.lvt
new file mode 100644
index 0000000..ff39122
--- /dev/null
+++ b/base/testfiles-filename/utf-test.lvt
@@ -0,0 +1,86 @@
+\input{utf8andspace}
+\documentclass{article}
+
+%\usepackage{textcomp}
+
+
+% ----------------------------------------------------------
+
+\input{utf8andspace}
+
+
+\begin{filecontents*}{one two three}
+1 2 3
+\end{filecontents*}
+
+
+\begin{filecontents*}{füße.tex}
+Füße file
+\end{filecontents*}
+
+\begin{filecontents}{füße€€€.tex}
+Expensive feet
+\end{filecontents}
+
+% this needs quotes
+\begin{filecontents*}{"füße im sand.tex"}
+eureka
+\end{filecontents*}
+
+
+
+\includeonly{foo, füße€€€ , öfoo}
+
+\begin{document}
+
+\tableofcontents
+
+\section{A with ref: ``\ref{abß}''}
+
+\label{öfoo}
+
+
+Some refs: \ref{abß} and \ref{öfoo} and \ref{bar€}
+
+\fontencoding{T1}\selectfont
+
+Some refs: \ref{abß} and \ref{öfoo} and \ref{bar€}
+
+\subsection{include tests}
+
+\label{bar€}
+
+\include{füße€€€} % exists
+\include{€€€} % doesn't exist = No file €€€.aux.
+
+\subsection{input tests}
+
+\input{"füße im sand"} % exists
+
+%\input{unknownfüße} % doesn't exist (should give file error)
+ % = File `unknownfüße.tex' not found.
+
+\subsection{@input tests}
+\label{abß}
+
+\makeatletter
+
+\@input{füße} % exists
+\@input{€€€} % doesn't exist (should give warning)
+ % = No file €€€.
+
+\@input{"füße im sand"} % exists
+
+\makeatother
+
+\def\foo{"füße im sand"}
+\input{\foo} % exists
+
+% next one fails
+%\input füße
+
+
+\input{one two three}
+
+\end{document}
+
diff --git a/base/utf8andspace.tex b/base/utf8andspace.tex
new file mode 100644
index 0000000..6c9365f
--- /dev/null
+++ b/base/utf8andspace.tex
@@ -0,0 +1,289 @@
+\makeatletter
+
+
+
+
+
+% quoting spaces
+% a b c -> "a b c"
+% "a b c" -> "a b c"
+% a" "b" "c -> "a b c"
+% -> ""
+\def\quote at name#1{"\quote@@name#1\@gobble""}
+\def\quote@@name#1"{#1\quote@@name}
+
+
+% utf8
+
+\long\def\UTFviii at two@octets{%
+ \ifx\protect\relax
+ \ifincsname
+ \expandafter\expandafter\expandafter
+ \UTF at twoharmless@octets
+ \fi
+ \else
+ \expandafter\UTF at twoharmless@octets
+ \fi
+ \UTFviii at two@octets at do
+}
+
+
+\long\def\UTFviii at three@octets{%
+ \ifx\protect\relax
+ \ifincsname
+ \expandafter\expandafter\expandafter
+ \UTF at threeharmless@octets
+ \fi
+ \else
+ \expandafter\UTF at threeharmless@octets
+ \fi
+ \UTFviii at three@octets at do
+}
+
+
+\long\def\UTFviii at four@octets{%
+ \ifx\protect\relax
+ \ifincsname
+ \expandafter\expandafter\expandafter
+ \UTF at fourharmless@octets
+ \fi
+ \else
+ \expandafter\UTF at fourharmless@octets
+ \fi
+ \UTFviii at four@octets at do
+}
+
+
+
+\long\def\UTFviii at two@octets at do#1#2{\expandafter
+ \UTFviii at defined\csname u8:#1\string#2\endcsname}
+\long\def\UTFviii at three@octets at do#1#2#3{\expandafter
+ \UTFviii at defined\csname u8:#1\string#2\string#3\endcsname}
+\long\def\UTFviii at four@octets at do#1#2#3#4{\expandafter
+ \UTFviii at defined\csname u8:#1\string#2\string#3\string#4\endcsname}
+
+
+\long\def\UTF at twoharmless@octets#1#2{\string#2\string}
+\long\def\UTF at threeharmless@octets#1#2#3{\string#2\string#3\string}
+\long\def\UTF at fourharmless@octets#1#2#3#4{\string#2\string#3\string#4\string}
+
+
+% the next one isn't quite safe as \@curr at file bight get changed by
+% another test (see 25 year old bug fixed this morning, but that can
+% be mended
+
+\long\def \IfFileExists#1#2#3{%
+ \set at curr@file{#1}%
+ \edef\q at curr@file{\expandafter\quote at name\expandafter{\@curr at file}}%
+ \openin\@inputcheck\q at curr@file\space
+ \ifeof\@inputcheck
+ \ifx\input at path\@undefined
+ \def\reserved at a{#3}%
+ \else
+ \def\reserved at a{\@iffileonpath\q at curr@file{#2}{#3}}%
+ \fi
+ \else
+ \closein\@inputcheck
+ \edef\@filef at und{\q at curr@file\space }%
+ \def\reserved at a{#2}%
+ \fi
+ \reserved at a}
+
+\long\def \InputIfFileExists#1#2{%
+ \IfFileExists{#1}%
+ {#2\@addtofilelist{#1}\@@input \@filef at und}}
+
+\def\set at curr@file#1{%
+ \begingroup
+ \escapechar\m at ne
+ \xdef\@curr at file{\expandafter\string\csname #1\endcsname}%
+ \endgroup
+}
+
+\def\@iinput#1{%
+ \InputIfFileExists{#1}{}%
+ {\filename at parse\@curr at file
+ \edef\reserved at a{\noexpand\@missingfileerror
+ {\filename at area\filename at base}%
+ {\ifx\filename at ext\relax tex\else\filename at ext\fi}}%
+ \reserved at a}}
+
+
+\def\@include#1 {%
+ \clearpage
+ \set at curr@file{#1}%
+ \if at filesw
+ \immediate\write\@mainaux{\string\@input{\@curr at file.aux}}%
+ \fi
+ \@tempswatrue
+ \if at partsw
+ \@tempswafalse
+ \@for\reserved at a:=\@partlist\do
+ {\ifx\reserved at a\@curr at file\@tempswatrue\fi}%
+ \fi
+ \if at tempswa
+ \let\@auxout\@partaux
+ \if at filesw
+ \immediate\openout\@partaux \@curr at file.aux
+ \immediate\write\@partaux{\relax}%
+ \fi
+ \@input@{\@curr at file.tex}%
+ \clearpage
+ \@writeckpt{\@curr at file}%
+ \if at filesw
+ \immediate\closeout\@partaux
+ \fi
+ \else
+ \deadcycles\z@
+ \@nameuse{cp@\@curr at file}%
+ \fi
+ \let\@auxout\@mainaux}
+
+% that zapspace ... hmmm
+
+\def\includeonly#1{%
+ \@partswtrue
+ \set at curr@file{\zap at space#1 \@empty}%
+ \let\@partlist\@curr at file
+ }
+
+
+\begingroup%
+\@tempcnta=1
+\loop
+ \catcode\@tempcnta=12 %
+ \advance\@tempcnta\@ne %
+\ifnum\@tempcnta<32 %
+\repeat %
+\catcode`\*=11 %
+\catcode`\^^M\active%
+\catcode`\^^L\active\let^^L\relax%
+\catcode`\^^I\active%
+\gdef\filec at ntents#1{%
+ \set at curr@file{#1}%
+ \edef\q at curr@file{\expandafter\quote at name\expandafter{\@curr at file}}%
+ \openin\@inputcheck\q at curr@file \space %
+ \ifeof\@inputcheck%
+ \@latex at warning@no at line%
+ {Writing file `\@currdir\@curr at file'}%
+ \chardef\reserved at c15 %
+ \ch at ck7\reserved at c\write%
+ \immediate\openout\reserved at c\q at curr@file\relax%
+ \else%
+ \closein\@inputcheck%
+ \@latex at warning@no at line%
+ {File `\@curr at file' already exists on the system.\MessageBreak%
+ Not generating it from this source}%
+ \let\write\@gobbletwo%
+ \let\closeout\@gobble%
+ \fi%
+ \if at tempswa%
+ \immediate\write\reserved at c{%
+ \@percentchar\@percentchar\space%
+ \expandafter\@gobble\string\LaTeX2e file `\@curr at file'^^J%
+ \@percentchar\@percentchar\space generated by the %
+ `\@currenvir' \expandafter\@gobblefour\string\newenvironment^^J%
+ \@percentchar\@percentchar\space from source `\jobname' on %
+ \number\year/\two at digits\month/\two at digits\day.^^J%
+ \@percentchar\@percentchar}%
+ \fi%
+ \let\do\@makeother\dospecials%
+ \count@ 128\relax%
+ \loop%
+ \catcode\count@ 11\relax%
+ \advance\count@ \@ne%
+ \ifnum\count@<\@cclvi%
+ \repeat%
+ \edef\E{\@backslashchar end\string{\@currenvir\string}}%
+ \edef\reserved at b{%
+ \def\noexpand\reserved at b%
+ ####1\E####2\E####3\relax}%
+ \reserved at b{%
+ \ifx\relax##3\relax%
+ \immediate\write\reserved at c{##1}%
+ \else%
+ \edef^^M{\noexpand\end{\@currenvir}}%
+ \ifx\relax##1\relax%
+ \else%
+ \@latex at warning{Writing text `##1' before %
+ \string\end{\@currenvir}\MessageBreak as last line of \@curr at file}%
+ \immediate\write\reserved at c{##1}%
+ \fi%
+ \ifx\relax##2\relax%
+ \else%
+ \@latex at warning{%
+ Ignoring text `##2' after \string\end{\@currenvir}}%
+ \fi%
+ \fi%
+ ^^M}%
+ \catcode`\^^L\active%
+ \let\L\@undefined%
+ \def^^L{\expandafter\ifx\csname L\endcsname\relax\fi ^^J^^J}%
+ \catcode`\^^I\active%
+ \let\I\@undefined%
+ \def^^I{\expandafter\ifx\csname I\endcsname\relax\fi\space}%
+ \catcode`\^^M\active%
+ \edef^^M##1^^M{%
+ \noexpand\reserved at b##1\E\E\relax}}%
+\endgroup%
+
+
+
+
+% graphics
+
+\def\unquote at name#1{\quote@@name#1\@gobble"}
+
+
+\AtBeginDocument{%
+\def\Gin at getbase#1{%
+ \edef\Gin at tempa{%
+ \def\noexpand\@tempa####1#1\space{%
+ \def\noexpand\Gin at base{"####1"}}}%
+ \IfFileExists{\filename at area\filename at base#1}%
+ {\Gin at tempa
+\edef\uq at filef@und{\expandafter\unquote at name\expandafter{\@filef at und}}%
+ \expandafter\@tempa\uq at filef@und
+ \edef\Gin at ext{#1}}{}}%
+
+\def\Ginclude at graphics#1{%
+ \edef\Gin at extensions{\detokenize\expandafter{\Gin at extensions}}%
+ \begingroup
+ \let\input at path\Ginput at path
+ \set at curr@file{#1}%
+ \edef\uq at curr@file{\expandafter\unquote at name\expandafter{\@curr at file}}%
+ \expandafter\filename at parse\expandafter{\uq at curr@file}%
+ \edef\filename at area{\expandafter\quote at name\expandafter{\filename at area}}%
+ \edef\filename at base{\expandafter\quote at name\expandafter{\filename at base}}%
+ \ifx\filename at ext\relax
+ \@for\Gin at temp:=\Gin at extensions\do{%
+ \ifx\Gin at ext\relax
+ \Gin at getbase\Gin at temp
+ \fi}%
+ \else
+ \Gin at getbase{\Gin at sepdefault\filename at ext}%
+ \ifx\Gin at ext\relax
+ \@warning{File `#1' not found}%
+ \def\Gin at base{\filename at area\filename at base}%
+ \edef\Gin at ext{\Gin at sepdefault\filename at ext}%
+ \fi
+ \fi
+ \ifx\Gin at ext\relax
+ \@latex at error{File `#1' not found}%
+ {I could not locate the file with any of these extensions:^^J%
+ \Gin at extensions^^J\@ehc}%
+ \else
+ \@ifundefined{Gin at rule@\Gin at ext}%
+ {\ifx\Gin at rule@*\@undefined
+ \@latex at error{Unknown graphics extension: \Gin at ext}\@ehc
+ \else
+ \expandafter\Gin at setfile\Gin at rule@*{\Gin at base\Gin at ext}%
+ \fi}%
+ {\expandafter\expandafter\expandafter\Gin at setfile
+ \csname Gin at rule@\Gin at ext\endcsname{\Gin at base\Gin at ext}}%
+ \fi
+ \endgroup}
+}
+\makeatother
+
+
More information about the latex3-commits
mailing list