summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-09-30 23:19:37 +0000
committerKarl Berry <karl@freefriends.org>2008-09-30 23:19:37 +0000
commita8313d1d7bc7774a95f17646587669488918504e (patch)
tree4ed34828105f4309e85040fa98e43ef4bc1ecaf1 /Master
parentdce187f15bc2f38254310954436811a3927ea72d (diff)
xstring update (30sep08)
git-svn-id: svn://tug.org/texlive/trunk@10806 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/generic/xstring/test_etex.pdfbin0 -> 29628 bytes
-rw-r--r--Master/texmf-dist/doc/generic/xstring/test_etex.tex (renamed from Master/texmf-dist/doc/latex/xstring/test_etex.tex)0
-rw-r--r--Master/texmf-dist/doc/generic/xstring/test_latex.pdf (renamed from Master/texmf-dist/doc/latex/xstring/test_latex.pdf)bin52707 -> 52742 bytes
-rw-r--r--Master/texmf-dist/doc/generic/xstring/test_latex.tex (renamed from Master/texmf-dist/doc/latex/xstring/test_latex.tex)0
-rw-r--r--Master/texmf-dist/doc/generic/xstring/xstring_doc_en.pdf (renamed from Master/texmf-dist/doc/latex/xstring/xstring_doc_en.pdf)bin194495 -> 194565 bytes
-rw-r--r--Master/texmf-dist/doc/generic/xstring/xstring_doc_en.tex (renamed from Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex)2
-rw-r--r--Master/texmf-dist/doc/generic/xstring/xstring_doc_fr.pdf (renamed from Master/texmf-dist/doc/latex/xstring/xstring_doc_fr.pdf)bin205460 -> 205716 bytes
-rw-r--r--[-rwxr-xr-x]Master/texmf-dist/doc/generic/xstring/xstring_doc_fr.tex (renamed from Master/texmf-dist/doc/latex/xstring/xstring_doc_fr.tex)0
-rw-r--r--Master/texmf-dist/doc/latex/xstring/README91
-rw-r--r--Master/texmf-dist/doc/latex/xstring/test_etex.pdfbin29601 -> 0 bytes
-rw-r--r--Master/texmf-dist/tex/generic/xstring/xstring.tex (renamed from Master/texmf-dist/tex/latex/xstring/xstring.tex)259
11 files changed, 115 insertions, 237 deletions
diff --git a/Master/texmf-dist/doc/generic/xstring/test_etex.pdf b/Master/texmf-dist/doc/generic/xstring/test_etex.pdf
new file mode 100644
index 00000000000..979cc8e9974
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/xstring/test_etex.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xstring/test_etex.tex b/Master/texmf-dist/doc/generic/xstring/test_etex.tex
index a629c1a9958..a629c1a9958 100644
--- a/Master/texmf-dist/doc/latex/xstring/test_etex.tex
+++ b/Master/texmf-dist/doc/generic/xstring/test_etex.tex
diff --git a/Master/texmf-dist/doc/latex/xstring/test_latex.pdf b/Master/texmf-dist/doc/generic/xstring/test_latex.pdf
index ba8e585e3d3..e9c4346c407 100644
--- a/Master/texmf-dist/doc/latex/xstring/test_latex.pdf
+++ b/Master/texmf-dist/doc/generic/xstring/test_latex.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xstring/test_latex.tex b/Master/texmf-dist/doc/generic/xstring/test_latex.tex
index 72437521de2..72437521de2 100644
--- a/Master/texmf-dist/doc/latex/xstring/test_latex.tex
+++ b/Master/texmf-dist/doc/generic/xstring/test_latex.tex
diff --git a/Master/texmf-dist/doc/latex/xstring/xstring_doc_en.pdf b/Master/texmf-dist/doc/generic/xstring/xstring_doc_en.pdf
index a16122cadbb..d4ccc06b234 100644
--- a/Master/texmf-dist/doc/latex/xstring/xstring_doc_en.pdf
+++ b/Master/texmf-dist/doc/generic/xstring/xstring_doc_en.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex b/Master/texmf-dist/doc/generic/xstring/xstring_doc_en.tex
index 88e65f4d514..7cbb5a76425 100644
--- a/Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex
+++ b/Master/texmf-dist/doc/generic/xstring/xstring_doc_en.tex
@@ -392,7 +392,7 @@ Tests if the strings \argu{stringA} and \argu{stringB} are equal, \emph{except}
\item The definition of \emph{number} is given with the macro \verb|IfDecimal| (see page~\pageref{ifdecimal}), and thus :
\item \guill{+} signs are optional;
\item Decimal separator can be a dot or a comma;
- \item It is possible to evaluate an algebric expression with the $\varepsilon$-\TeX{} primitive \verb|\numexpr|, keeping in mind that it operate on integers only, and that results of divisions are \emph{rounded} and not truncated! It is wiser to avoid with no integer calculation.
+ \item It is possible to evaluate an algebric expression with the $\varepsilon$-\TeX{} primitive \verb|\numexpr|, keeping in mind that it operate on integers only, and that results of divisions are \emph{rounded} and not truncated!
\end{Conditions}
\exemple|\IfEq{a1b2c3}{a1b2c3}{true}{false}|
diff --git a/Master/texmf-dist/doc/latex/xstring/xstring_doc_fr.pdf b/Master/texmf-dist/doc/generic/xstring/xstring_doc_fr.pdf
index 60f854cf3f2..23f8bcb2dd1 100644
--- a/Master/texmf-dist/doc/latex/xstring/xstring_doc_fr.pdf
+++ b/Master/texmf-dist/doc/generic/xstring/xstring_doc_fr.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xstring/xstring_doc_fr.tex b/Master/texmf-dist/doc/generic/xstring/xstring_doc_fr.tex
index 5d7226b1862..5d7226b1862 100755..100644
--- a/Master/texmf-dist/doc/latex/xstring/xstring_doc_fr.tex
+++ b/Master/texmf-dist/doc/generic/xstring/xstring_doc_fr.tex
diff --git a/Master/texmf-dist/doc/latex/xstring/README b/Master/texmf-dist/doc/latex/xstring/README
deleted file mode 100644
index e0e96d9f9f0..00000000000
--- a/Master/texmf-dist/doc/latex/xstring/README
+++ /dev/null
@@ -1,91 +0,0 @@
- _________________
-
- xstring package
- v1.3
- 2008/09/21
- _________________
-
-----------------------------------------------------------------------------
- Warning!
-This package does not require LaTeX (although eTeX is still required).
-Consequently, the xstring.tex file should be installed in the tex/ subtree.
-----------------------------------------------------------------------------
-This package provides macros manipulating strings, such as:
- * tests:
- - does a string contains at least n times an another?
- - does a string starts (or ends) with another? etc.
- - is a string an integer? A decimal?
- - are 2 strings equal?
- - is a string equal to several cases?
- * extractions of substrings:
- - what is on the left (or the right) of the nth occurrence of a
- substring;
- - what is between the occurrences of 2 substrings;
- - substring between 2 positions;
- - split a string, etc.
- * substitution of all (or the n first) occurrences of a substring
- for an other substring;
- * calculation of numbers:
- - length of a string;
- - position of the nth occurrence of a substring;
- - how many times a string contains a substring?
- - comparison of strings: position of the first difference.
-
-For programming purposes, other macros allow to use special characters
-(& ~ \ { } _ # $ ^ %) with the macros manipulating strings.
-
-This bundle contains :
- * xstring.sty (the sty file for LaTeX)
- * xstring.tex (the package itself)
- * xstring_doc_en.tex and xstring_doc_en.pdf (manual in english)
- * xstring_doc_fr.tex and xstring_doc_fr.pdf (manual in french)
- * test_etex.tex and test_etex.pdf (test file to compile with etex)
- * test_latex.tex and test_latex.pdf (test file to compile with LaTeX)
- * README (this file)
-
-#######################################################################
-#######################################################################
-
-----------------------------------------------------------------------------
- Attention !
-Cette extension ne nécessite pas LaTeX (bien que eTeX soit toujours requis).
-Par conséquent, le fichier xstring.tex devrait être installé dans le sous
-répertoire tex/.
-----------------------------------------------------------------------------
-Cette extension regroupe un ensemble de macros manipulant des chaînes
-de caractères :
- * des tests :
- - une chaîne en contient elle une autre au moins n fois ?
- - une chaîne commence t-elle ou finit-elle par une autre ? etc.
- - une chaîne est-elle un entier relatif ? Un décimal ?
- - deux chaînes sont-elles égales ?
- - une chaîne est elle égale à plusieurs cas ?
- * des extractions de chaines :
- - renvoi de ce qui se trouve avant (ou après) la nieme occurrence
- d'une sous-chaîne;
- - renvoi de ce qui se trouve entre les occurrences de 2 sous-chaînes;
- - sous-chaîne comprise entre 2 positions;
- - coupure d'une chaîne, etc.
- * le remplacement de toutes ou des n premières occurrences d'une
- sous-chaîne par une autre sous-chaîne;
- * des calculs de nombres :
- - longueur d'une chaîne;
- - position de la la nieme occurrence d'une sous-chaîne;
- - comptage du nombre d'occurrences d'une sous-chaîne dans une autre.
- - comparaison de 2 chaînes : position du 1er caractère différent.
-
-D'autres commandes permettent de traiter les caractères spéciaux
-(& ~ \ { } _ # $ ^ %) de façon à les utiliser dans les arguments des macros
-de ce package, ce qui permet d'utiliser ces macros à fins de programmation.
-
-Ce paquet contient :
- * xstring.sty (le fichier sty pour LaTeX)
- * xstring.tex (le package lui même)
- * xstring_doc_en.tex and xstring_doc_en.pdf (manuel en anglais)
- * xstring_doc_fr.tex and xstring_doc_fr.pdf (manuel en français)
- * test_etex.tex and test_etex.pdf (fichier test à compiler avec etex)
- * test_latex.tex and test_latex.pdf (fichier test à compiler avec LaTeX)
- * README (ce fichier)
-
- Christian Tellechea
- <unbonpetit@gmail.com> \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/xstring/test_etex.pdf b/Master/texmf-dist/doc/latex/xstring/test_etex.pdf
deleted file mode 100644
index 35c205d4ef2..00000000000
--- a/Master/texmf-dist/doc/latex/xstring/test_etex.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/tex/latex/xstring/xstring.tex b/Master/texmf-dist/tex/generic/xstring/xstring.tex
index 27ab19f1b6c..fc87bcb824a 100644
--- a/Master/texmf-dist/tex/latex/xstring/xstring.tex
+++ b/Master/texmf-dist/tex/generic/xstring/xstring.tex
@@ -1,9 +1,9 @@
% __________________________________________________
% | |
% | |
-% | xstring v1.3 |
+% | xstring v1.3a |
% | |
-% | September 21 2008 |
+% | September 29 2008 |
% | |
% |__________________________________________________|
%
@@ -35,10 +35,10 @@
% test_latex.tex, test_latex.pdf (test file with LaTeX)
% test_etex.tex, test_etex.pdf (test file with Plain eTeX)
%
-\def\xstringversion {1.3}
-\def\xstringdate {2008/09/21}
-\def\xstringfrenchdate {21 septembre 2008}
-\def\xstringenglishdate{September $21^{\mathrm{st}}$ 2008}
+\def\xstringversion {1.3a}
+\def\xstringdate {2008/09/29}
+\def\xstringfrenchdate {29 septembre 2008}
+\def\xstringenglishdate{September $29^{\mathrm{th}}$ 2008}
\edef\CurrentAtCatcode{\the\catcode`\@}
\catcode`\@=11
\newwrite\@xs@unused% pour les messages
@@ -72,9 +72,6 @@
\def\@empty{}
\fi% fin des définitions LaTeX
-\def\@xs@gobblefirstchar#1#2\@nil{#2}
-\def\@xs@returnfirstchar#1#2\@nil{#1}
-
% Gestion des messages d'erreur
\def\@xs@linenumber{on input line \the\inputlineno}
\def\@xs@errorwrite#1#2{%
@@ -208,28 +205,25 @@
\let\@xs@def\edef% on définit\@xs@call avec \edef
\def\@xs@expand##1{##1}}% et on neutralise \@xs@expand
-
-% Cette macro interne enlève le 1er caractère de la chaine passée en argument
-\def\@xs@RemoveFirst#1[#2]{%
- \ifx\@empty#1\@empty
- \edef#2{}%
+% Cette macro interne renvoie le 1er caractère de la chaine passée en argument
+\def\@xs@firstchar#1{%
+ \expandafter\ifx\expandafter\@empty\@xs@beforespace#1 \@nil\@empty
+ \ifx\@empty#1\@empty\else\space\fi
\else
- \@xs@IfBeginWith{#1}{ }%
- {\@xs@StrBehind[1]{#1}{ }[#2]}%
- {\def\@xs@RemoveFirst@ii##1##2\@nil{\edef#2{##2}}%
- \@xs@RemoveFirst@ii#1\@nil}%
+ \@xs@returnfirstchar#1\@nil
\fi}
-% Cette macro interne renvoie le 1er caractère de la chaine passée en argument
-\def\@xs@ReturnFirst#1[#2]{%
- \ifx\@empty#1\@empty%
- \edef#2{}%
+% Cette macro interne enlève le 1er caractère de la chaine passée en argument
+\def\@xs@removefirstchar#1{%
+ \expandafter\ifx\expandafter\@empty\@xs@beforespace#1 \@nil\@empty
+ \ifx\@empty#1\@empty\else\@xs@afterspace#1\@nil\fi
\else
- \@xs@IfBeginWith{#1}{ }%
- {\edef#2{ }}%
- {\def\@xs@ReturnFirst@ii##1##2\@nil{\edef#2{##1}}%
- \@xs@ReturnFirst@ii#1\@nil}%
+ \@xs@gobblefirstchar#1\@nil
\fi}
+\def\@xs@beforespace#1 #2\@nil{#1}
+\def\@xs@afterspace#1 #2\@nil{#2}
+\def\@xs@gobblefirstchar#1#2\@nil{#2}
+\def\@xs@returnfirstchar#1#2\@nil{#1}
% Cette macro interne est utilisée dans les macros étoilées pour :
% 1) développer l'argument selon qu'on a choisit \fullexpandarg
@@ -261,7 +255,7 @@
\expandafter\@xs@OneArg\expandafter{\number\numexpr##1+#1-1}%
\@xs@expand@and@addtomacro\@xs@newlines{\noexpand\@xs@assign{\expandafter\noexpand\csname @xs@arg@\romannumeral\numexpr##1\endcsname}{\@xs@myarg}}%
\@xs@expand@and@addtomacro\@xs@newargs{{\noexpand\@xs@expand\expandafter\noexpand\csname @xs@arg@\romannumeral\numexpr##1\endcsname}}%
- \ifnum##1<#2
+ \ifnum##1<#2\relax
\def\@xs@next{\expandafter\@xs@buildlines\number\numexpr##1+1\relax\@nil}%
\expandafter\@xs@next
\fi}
@@ -317,62 +311,56 @@
% \def \@xs@NOM[##1]##2##3##4[##5]{#5}
\@xs@temp@}
-% Cette macro teste si une chaine (#2) en contient au moins (#1) fois une autre (#3)
-% Au final, \@xs@behind@IfSubStr et \@xs@before@IfSubStr contiennent
-% ce qui se trouve après et avant la (#1)èmé occurrence de la chaine (#2)
-% si elle existe,et contiennent des chaines vides sinon.
\def\@xs@strip@delimit#1\@delimit#2\@nil{#1}
-\def\@xs@IfSubStr@case@false{%
- \let\@xs@result@If\@secondoftwo% on exécute #5
- \def\@xs@behind@IfSubStr{}%
- \def\@xs@before@IfSubStr{}}
-\@xs@newmacro\IfSubStr{1}{2}{0}{%
- \ifnum#1<\@ne% on gère les cas spéciaux
- \@xs@BadNumArg
- \@xs@IfSubStr@case@false
- \else
- \ifx\@empty#2\@empty\@xs@ArgEmpty\fi
- \ifx\@empty#3\@empty
- \@xs@ArgEmpty
- \@xs@IfSubStr@case@false
+% Cette macro coupe la chaine #1 après la #3ème occurrence de la sous chaine #2
+% \@xs@beforeoccurwith : contient ce qui se trouve avant cette occurrence y compris l'occurrence
+% \@xs@beforeoccurwithout : idem mais sans l'occurrence
+% \@xs@behindoccur : contient ce qui se trouve après l'occurrence
+% si l'occurrence n'existe pas ou qu'un des arguments est vide, toutes les chaines renvoyées sont vides
+\def\@xs@cutafteroccur#1#2#3{% #1 est la chaine, #2 est le pattern, #3 est la nième occurence souhaitée
+ \def\@xs@cutafteroccur@i##1\@nil##2#2##3\@nil{% ##1 est le compteur
+ \def\@xs@next{\relax}%
+ \ifx\@empty##3\@empty% rien après cette occurrence ?
+ \def\@xs@beforeoccurwith{}\def\@xs@beforeoccurwithout{}\def\@xs@behindoccur{}% occurrence non trouvée -> on met tout à \empty
\else
- \def\@xs@before@IfSubStr{}%
- \def\@xs@IfSubStr@i##1\@nil##2#3##3\@nil{% ##1 est le compteur
- \def\@xs@next{\relax}%
- \ifx\@empty##3\@empty% rien après la sous chaine ?
- \@xs@IfSubStr@case@false
- \else% si ce qu'il est reste n'est pas vide
- \ifnum##1<#1% tant que le nombre d'occurrence n'est pas atteint
- \edef\@xs@before@IfSubStr{\@xs@before@IfSubStr##2#3}% on ajoute la chaine restante à \@xs@before@IfSubStr
- \def\@xs@next{\expandafter\@xs@IfSubStr@i\number\numexpr##1+1\relax\@nil##3\@nil}% on recommence après être sorti de \if...\fi
- \else
- \let\@xs@result@If\@firstoftwo% nombre d'occurrences atteint : on renvoie #4
- \edef\@xs@before@IfSubStr{\@xs@before@IfSubStr##2}%
- \edef\@xs@behind@IfSubStr{\@xs@strip@delimit##3\@nil}%
- \fi
- \fi
- \@xs@next}%
- \@xs@IfSubStr@i1\@nil#2\@delimit#3\@nil% \@delimit pour éviter le cas de \IfSubStr{a}{aa}{V}{F} qui renverrait V
+ \ifnum##1<#3\relax% tant que le nombre d'occurrence n'est pas atteint
+ \expandafter\def\expandafter\@xs@beforeoccurwith\expandafter{\@xs@beforeoccurwith##2#2}% on ajoute la chaine restante
+ \def\@xs@next{\expandafter\@xs@cutafteroccur@i\number\numexpr##1+1\relax\@nil##3\@nil}% on recommence après être sorti des \if...\fi
+ \else
+ \expandafter\def\expandafter\@xs@beforeoccurwithout\expandafter{\@xs@beforeoccurwith##2}% on ajoute la chaine restante une dernière fois sans le pattern ici
+ \expandafter\def\expandafter\@xs@beforeoccurwith\expandafter{\@xs@beforeoccurwith##2#2}% et avec le pattern ici
+ \expandafter\def\expandafter\@xs@behindoccur\expandafter{\@xs@strip@delimit##3\@nil}%
+ \fi
\fi
- \fi
- \@xs@result@If}
+ \@xs@next}%
+ \def\@xs@beforeoccurwith{}\def\@xs@beforeoccurwithout{}\def\@xs@behindoccur{}%
+ \ifnum#3>\z@
+ \ifx\@empty#2\@empty\@xs@ArgEmpty\else\@xs@cutafteroccur@i\@ne\@nil#1\@delimit#2\@nil\fi
+ \else\@xs@BadNumArg\fi}
+
+\@xs@newmacro\IfSubStr{1}{2}{0}{%
+ \@xs@cutafteroccur{#2}{#3}{#1}%
+ \ifx\@xs@behindoccur\@xs@beforeoccurwith
+ \expandafter\@secondoftwo
+ \else
+ \expandafter\@firstoftwo
+ \fi}
\@xs@newmacro\IfBeginWith{}{2}{0}{%
- \@xs@IfSubStr[\@ne]{#1}{#2}%
- {\ifx\@empty\@xs@before@IfSubStr\@empty
- \let\@xs@result@If\@firstoftwo%
- \else
- \let\@xs@result@If\@secondoftwo%
- \fi}%
- {\let\@xs@result@If\@secondoftwo}%
- \@xs@result@If}
+ \@xs@cutafteroccur{#1}{#2}{\@ne}%
+ \def\@xs@next{#2}%
+ \ifx\@xs@next\@xs@beforeoccurwith
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
\@xs@newmacro\IfEndWith{}{2}{0}{%
\@xs@StrCount{#1}{#2}[\@xs@result@If]%
\ifnum\@xs@result@If=\z@
\let\@xs@result@If\@secondoftwo%
\else
- \ifx\@empty\@xs@after@StrCount\@empty
+ \ifx\@empty\@xs@after@StrCount
\let\@xs@result@If\@firstoftwo%
\else
\let\@xs@result@If\@secondoftwo%
@@ -382,13 +370,13 @@
\@xs@newmacro\IfSubStrBefore{1,1}{3}{0}{\@xs@IfSubStrBefore@i[#1]{#2}{#3}{#4}}
\def\@xs@IfSubStrBefore@i[#1,#2]#3#4#5{%
- \@xs@IfSubStr[#2]{#3}{#5}%
- {\expandafter\@xs@IfSubStr\expandafter[\expandafter#1\expandafter]\expandafter{\@xs@before@IfSubStr}{#4}%
- {\let\@xs@result@If\@firstoftwo}%
- {\let\@xs@result@If\@secondoftwo}%
- }%
- {\let\@xs@result@If\@secondoftwo}%
- \@xs@result@If}
+ \@xs@cutafteroccur{#3}{#5}{#2}%
+ \expandafter\@xs@cutafteroccur\expandafter{\@xs@beforeoccurwithout}{#4}{#1}%
+ \ifx\@xs@behindoccur\@xs@beforeoccurwith
+ \expandafter\@secondoftwo
+ \else
+ \expandafter\@firstoftwo
+ \fi}
\@xs@newmacro\IfSubStrBehind{1,1}{3}{0}{\@xs@IfSubStrBehind@i[#1]{#2}{#3}{#4}}
\def\@xs@IfSubStrBehind@i[#1,#2]#3#4#5{\@xs@IfSubStrBefore@i[#2,#1]{#3}{#5}{#4}}
@@ -485,26 +473,21 @@
% Renvoie ce qui est à gauche de l'occurence n°#1 de la sous chaine #3 dans la chaine
\@xs@newmacro\StrBefore{1}{2}{1}{%
- \@xs@IfSubStr[#1]{#2}{#3}%
- {\@xs@ReturnResult{\@xs@before@IfSubStr}{#4}}%
- {\@xs@ReturnResult{}{#4}}}
+ \@xs@cutafteroccur{#2}{#3}{#1}%
+ \@xs@ReturnResult{\@xs@beforeoccurwithout}{#4}}
% Renvoie ce qui est à droite de l'occurence n°#1 de la sous chaine #3 dans la chaine #2
\@xs@newmacro\StrBehind{1}{2}{1}{%
- \@xs@IfSubStr[#1]{#2}{#3}%
- {\@xs@ReturnResult{\@xs@behind@IfSubStr}{#4}}%
- {\@xs@ReturnResult{}{#4}}}
+ \@xs@cutafteroccur{#2}{#3}{#1}%
+ \@xs@ReturnResult{\@xs@behindoccur}{#4}}
% Renvoie ce qui est strictement compris entre les occurrences n°#1 et n°#2
% des chaines #4 et #5 dans la chaine #3
\@xs@newmacro\StrBetween{1,1}{3}{1}{\@xs@StrBetween@i[#1]{#2}{#3}{#4}[#5]}
\def\@xs@StrBetween@i[#1,#2]#3#4#5[#6]{%
- \@xs@IfSubStr[#2]{#3}{#5}%
- {\expandafter\@xs@IfSubStr\expandafter[\expandafter#1\expandafter]\expandafter{\@xs@before@IfSubStr}{#4}%
- {\@xs@ReturnResult{\@xs@behind@IfSubStr}{#6}}%
- {\@xs@ReturnResult{}{#6}}%
- }%
- {\@xs@ReturnResult{}{#6}}}
+ \@xs@cutafteroccur{#3}{#5}{#2}%
+ \expandafter\@xs@cutafteroccur\expandafter{\@xs@beforeoccurwithout}{#4}{#1}%
+ \@xs@ReturnResult{\@xs@behindoccur}{#6}}
% Remplace les #1 premières occurences de la chaine #3
% par la chaine #4 dans la chaine #2
@@ -518,7 +501,7 @@
\def\@xs@StrSubstitute@i##1\@nil##2#3##3\@nil{% ici, on compte les occurrences : ##1 est le compteur
\edef\@xs@result@StrSubstitute{\@xs@result@StrSubstitute##2#4}% on recopie jusqu'à la 1ere occurrence, et on remplace #3 par #4
\@xs@IfSubStr[1]{##3}{#3}% tant que la chaine restante contient #3
- {\ifnum##1<#1% tant qu'on n'a pas atteint la bonne occurrence,
+ {\ifnum##1<#1\relax% tant qu'on n'a pas atteint la bonne occurrence,
\def\@xs@next{\expandafter\@xs@StrSubstitute@i\number\numexpr##1+1\relax\@nil##3\@nil}%
\else
\def\@xs@next{\edef\@xs@result@StrSubstitute{\@xs@result@StrSubstitute##3}}%
@@ -545,15 +528,17 @@
\@xs@newmacro\StrDel{0}{2}{1}{\@xs@StrSubstitute[#1]{#2}{#3}{}[#4]}
% Compte combien de caractères contient la chaine #1 ?
-\@xs@newmacro\StrLen{}{1}{1}{\@xs@StrLen@i#1\@nil0\@nil#2\@nil}
-\def\@xs@StrLen@i#1\@nil#2\@nil#3\@nil{% #2 est le compteur
- \ifx\@empty#1\@empty
- \@xs@ReturnResult{\number\numexpr#2}{#3}%
- \else
- \@xs@RemoveFirst{#1}[\@xs@remain@StrLen]%
- \def\@xs@next{\expandafter\expandafter\expandafter\@xs@StrLen@i\expandafter\@xs@remain@StrLen\expandafter\@nil\number\numexpr#2+1\relax\@nil#3\@nil}%
- \expandafter\@xs@next
- \fi}
+\@xs@newmacro\StrLen{}{1}{1}{%
+ \def\@xs@StrLen@i##1{% ##1 est le compteur
+ \ifx\@empty\@xs@remain@StrLen
+ \@xs@ReturnResult{\number\numexpr##1}{#2}%
+ \else
+ \edef\@xs@remain@StrLen{\expandafter\@xs@removefirstchar\expandafter{\@xs@remain@StrLen}}%
+ \def\@xs@next{\expandafter\@xs@StrLen@i\expandafter{\number\numexpr##1+1}}%
+ \expandafter\@xs@next
+ \fi}%
+ \def\@xs@remain@StrLen{#1}%
+ \@xs@StrLen@i\z@}
\@xs@newmacro\StrSplit{}{2}{0}{\@xs@StrSplit@i{#2}{#1}}
\def\@xs@StrSplit@i#1#2#3#4{%
@@ -562,9 +547,8 @@
\def\@xs@StrSplit@ii##1\@nil{%
\def\@xs@next{\relax}%
\ifnum##1<#1\relax% tant que c'est pas fini
- \expandafter\@xs@ReturnFirst\expandafter{#4}[\@xs@next]% prend le 1er caractère
- \edef#3{#3\@xs@next}% l'ajoute au résultat final
- \expandafter\@xs@RemoveFirst\expandafter{#4}[#4]% puis l'enlève de la chaine
+ \edef#3{#3\expandafter\@xs@firstchar\expandafter{#4}}% prend le 1er caractère l'ajoute au résultat final
+ \edef#4{\expandafter\@xs@removefirstchar\expandafter{#4}}% puis l'enlève de la chaine
\ifx\@empty#4\@empty
\else
\def\@xs@next{\expandafter\@xs@StrSplit@ii\number\numexpr##1+1\relax\@nil}% on recommence sauf s'il ne reste plus rien
@@ -574,36 +558,12 @@
\def#3{}\def#4{#2}%
\@xs@StrSplit@ii0\@nil}
-\def\StrMid{\@ifstar{\let\@xs@assign\@xs@expand@and@detokenize\@xs@StrMid@@}{\let\@xs@assign\@xs@expand@and@assign\@xs@StrMid@@}}
-\def\@xs@StrMid@@#1#2#3{%
- \@xs@def\@xs@First@StrMid{\@xs@expand#2}%
- \@xs@def\@xs@Last@StrMid{\@xs@expand#3}% position début et fin
- \ifnum#2>#3\@xs@BadNumArg\fi
- \@xs@assign{\@xs@arg@i}{#1}%
- \edef\@xs@call{\noexpand\@testopt{\noexpand\@xs@StrMid{\@xs@expand\@xs@arg@i}}{}}%
- \@xs@call}
-
-\def\@xs@StrMid#1[#2]{%
-% renvoie la sous chaine de #1 comprise entre les positions \@xs@First@StrMid et \@xs@Last@StrMid
- \@xs@StrLen{#1}[\@len@StrMid]%
- \ifnum\@xs@First@StrMid>\@xs@Last@StrMid% mauvais ordre ?
- \@xs@ReturnResult{}{#2}% on renvoie rien
- \else
- \ifnum\@xs@First@StrMid<\@ne% 1ère position trop petite ?
- \edef\@xs@First@StrMid{1}% on limite à 1
- \@xs@BadNumArg% avertissement
- \fi
- \ifnum\@xs@Last@StrMid>\@len@StrMid% dernière position trop grande ?
- \edef\@xs@Last@StrMid{\@len@StrMid}% on limite à la longueur de la chaine
- \@xs@BadNumArg% avertissement
- \fi
- \expandafter\@xs@StrSplit@i\expandafter{\numexpr\@xs@First@StrMid-1}{#1}\@xs@before@StrMid\@xs@behind@StrMid
- \expandafter\expandafter\expandafter
- \@xs@StrSplit@i\expandafter\expandafter\expandafter
- {\expandafter\expandafter\expandafter
- \numexpr\@xs@Last@StrMid-\@xs@First@StrMid+2\relax\expandafter}\expandafter{\@xs@behind@StrMid}\@xs@result@StrMid\@xs@before@StrMid
- \@xs@ReturnResult{\@xs@result@StrMid}{#2}%
- \fi}
+% De la chaine #1, renvoie ce qui se trouve entre les positions
+% #2 et #3, caractères aux positions compris !
+\@xs@newmacro\StrMid{}{3}{1}{%
+ \@xs@StrSplit{#1}{#3}\@xs@BeforeMid\@xs@BehindMid
+ \expandafter\expandafter\expandafter\@xs@StrSplit\expandafter\expandafter\expandafter{\expandafter\@xs@BeforeMid\expandafter}\expandafter{\number\numexpr#2-1}\@xs@BeforeMid\@xs@BehindMid
+ \@xs@ReturnResult{\@xs@BehindMid}{#4}}
% supprime #2 caractères à gauche dans la chaine #1
\@xs@newmacro\StrGobbleLeft{}{2}{1}{%
@@ -632,8 +592,7 @@
\@xs@ReturnResult{}{#3}%
\else
\expandafter\@xs@StrSplit@i\expandafter{\numexpr#2-1}{#1}\@xs@call\@xs@result@StrChar
- \expandafter\@xs@ReturnFirst\expandafter{\@xs@result@StrChar}[\@xs@result@StrChar@]%
- \@xs@ReturnResult{\@xs@result@StrChar@}{#3}%
+ \@xs@ReturnResult{\expandafter\@xs@firstchar\expandafter{\@xs@result@StrChar}}{#3}%
\fi}
% Combien de fois compte t-on #2 dans #1 ?
@@ -656,15 +615,12 @@
% renvoie la position de l'occurrence #1 de la sous chaine #3 dans la chaine #2
\@xs@newmacro\StrPosition{1}{2}{1}{%
- \ifx\@empty#3\@empty%
- \@xs@ArgEmpty
+ \@xs@cutafteroccur{#2}{#3}{#1}%
+ \ifx\@xs@beforeoccurwith\@xs@afteroccur
\@xs@ReturnResult{0}{#4}%
\else
- \@xs@IfSubStr[#1]{#2}{#3}%
- {\expandafter\@xs@StrLen\expandafter{\@xs@before@IfSubStr}[\@xs@lenbefore@StrPosition]%
- \@xs@ReturnResult{\number\numexpr\@xs@lenbefore@StrPosition+1}{#4}%
- }%
- {\@xs@ReturnResult{0}{#4}}%
+ \expandafter\@xs@StrLen\expandafter{\@xs@beforeoccurwithout}[\@xs@next]%
+ \@xs@ReturnResult{\number\numexpr\@xs@next+1}{#4}%
\fi}
\def\comparestrict{\let\@xs@comparecoeff\@ne}
@@ -697,7 +653,7 @@
\@xs@next}%
\@xs@StrLen{#1}[\@xs@LenA@StrCompare]%
\@xs@StrLen{#2}[\@xs@LenB@StrCompare]%
- \ifnum\@xs@LenB@StrCompare<\@xs@LenA@StrCompare
+ \ifnum\@xs@LenB@StrCompare<\@xs@LenA@StrCompare\relax
\def\@xs@stringA{#1}\def\@xs@stringB{#2}%
\else
\def\@xs@stringA{#2}\def\@xs@stringB{#1}%
@@ -768,4 +724,17 @@
% - Nouvelle macro \StrCompare
% Compare 2 chaînes et renvoie la position du
% 1er caractère différent. Renvoie 0 si elles sont
-% égales \ No newline at end of file
+% égales
+%------------------------------------------------------------
+% v1.3a 29/9/2008
+% - Correction d'un bug : \expandafter#1
+% dans les macros \IfSubStrBefore et \StrBetween
+% qui buggue si #1 est un nombre > 9 !
+% - Ré écriture de \@xs@firstchar et \@xs@gobblefirstchar
+% qui deviennent purement développables.
+% - Ré écriture de \StrLen
+% - Nouvelle macro interne \@xs@cutafteroccur
+% Coupe la chaine après la nième occurrence d'une
+% sous chaine.
+% - Code amélioré de \StrMid, \StrLeft, \StrGobbleLeft,
+% \StrRight, \StrGobbleRight grace à \@xs@cutafteroccur \ No newline at end of file