diff options
author | Norbert Preining <preining@logic.at> | 2006-11-06 01:06:06 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2006-11-06 01:06:06 +0000 |
commit | 6ebd159ea2e62827f832b12137ec75a322e32ec0 (patch) | |
tree | 317793a8c1f76e8d6dcf3046420392fbd599f4ba /Master/texmf-dist/tex/latex/substr | |
parent | 3d2caaeddabf9f9bf2b309c6d3ba42e6b5dc71fa (diff) |
Again loads of updates due to a long train ride
updates to: eskdx screenplay syntax (dvi->pdf) swebib substr (dvi->pdf)
stdpage (one new test file) stdclsdv (dvi->pdf) ssqquote sseq
sprite splitbib snapshot (pdf doc) smartref (new doc)
smalltableof (new doc) siggraph sidecap shorttoc (new doc)
sffms script (new doc) scientificpaper (new doc) scale
savefnmark (new doc) sauterfonts (new doc) rtkinenc (new doc)
added to tpm-ctan-check: tableaux syntax swebib svn supertabular substr
subfloat subeqnarray subeqn stdpage stdclsdv stage stack ssqquote
sseq srcltx sprite splitbib splines spie soul snapshot smartref
smalltableof slideshow siggraph sidecap showlabels showdim
shorttoc shadbox sffms seqsplit semaphor script scientificpaper
scalebar scale savetrees savesym savefnmark sauterfonts rtkinenc
most of them license checked in the TeX Catalogue
git-svn-id: svn://tug.org/texlive/trunk@2392 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/substr')
-rw-r--r-- | Master/texmf-dist/tex/latex/substr/substr.sty | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/latex/substr/substr.sty b/Master/texmf-dist/tex/latex/substr/substr.sty index 1537f872fba..d7c0ca12612 100644 --- a/Master/texmf-dist/tex/latex/substr/substr.sty +++ b/Master/texmf-dist/tex/latex/substr/substr.sty @@ -27,10 +27,18 @@ %% Counts the number of appearances of <substring> in <string> and %% returns it as text. %% -%% \SubStringsToCounter}{counter}{substring}{string} +%% \SubStringsToCounter{counter}{substring}{string} %% Counts the number of appearances of <substring> in <string> and %% sets the counter <counter> to that value. %% +%% \IfBeforeSubStringEmpty{substring}{string}{true part}{false part} +%% Calls <true part> if <substring> is equal to the beginning of <string>. +%% Else call <false part>. +%% +%% \IfBehindSubStringEmpty{substring}{string}{true part}{false part} +%% Calls <true part> if <substring> is equal to the end of <string>. +%% Else call <false part>. +%% %% %% History of this package: %% @@ -45,7 +53,7 @@ %% who improved and rewrote many parts of it. %% %% -%% Copyright 2000 Harald Harders +%% Copyright 2000, 2005 Harald Harders %% %% This program can be redistributed and/or modified under the terms %% of the LaTeX Project Public License Distributed from CTAN @@ -53,15 +61,15 @@ %% version 1 of the License, or any later version. %% %% -%% 2000-06-15 +%% 2005-11-29 %% Harald Harders %% h.harders@tu-bs.de %% -\ProvidesPackage{substr}[2000/06/15] +\ProvidesPackage{substr}[2005/11/29 v1.1 Handle substrings] %% % expands the first and second argument with % \protected@edef and calls #3 with them: -\newcommand{\su@ExpandTwoArgs}[3]{% +\newcommand\su@ExpandTwoArgs[3]{% \protected@edef\su@SubString{#1}% \protected@edef\su@String{#2}% \expandafter\expandafter\expandafter#3% @@ -71,11 +79,11 @@ } %% %% tests if #1 in #2. If yes execute #3, else #4 -\newcommand*{\IfSubStringInString}[2]{% +\newcommand*\IfSubStringInString[2]{% \su@ExpandTwoArgs{#1}{#2}\su@IfSubStringInString } %% -\newcommand*{\su@IfSubStringInString}[2]{% +\newcommand*\su@IfSubStringInString[2]{% \def\su@compare##1#1##2\@nil{% \def\su@param{##2}% \ifx\su@param\@empty @@ -92,30 +100,56 @@ \let\IfCharInString\IfSubStringInString %% %% returns the part of the string behind the found substring -\newcommand*{\BehindSubString}[2]{% +\newcommand*\BehindSubString[2]{% \su@ExpandTwoArgs{#1}{#2}\su@BehindSubString } -\newcommand*{\su@BehindSubString}[2]{% +\newcommand*\su@BehindSubString[2]{% \def\su@rest##1#1##2\@nil{##2}% \IfSubStringInString{#1}{#2}{\su@rest#2\@nil}{}% } %% %% returns the part of the string before the found substring -\newcommand*{\BeforeSubString}[2]{% +\newcommand*\BeforeSubString[2]{% \su@ExpandTwoArgs{#1}{#2}\su@BeforeSubString } -\newcommand*{\su@BeforeSubString}[2]{% +\newcommand*\su@BeforeSubString[2]{% \def\su@rest##1#1##2\@nil{##1}% \IfSubStringInString{#1}{#2}{\su@rest#2\@nil}{#2}% } %% +%% calls #3 if part of string before substring is empty, otherwise calls #4. +\newcommand*\IfBeforeSubStringEmpty[2]{% + \su@ExpandTwoArgs{#1}{#2}\su@IfBeforeSubStringEmpty +} +%% +\newcommand*\su@IfBeforeSubStringEmpty[4]{% + \def\su@rest##1#1##2\@nil{##1}% + \IfSubStringInString{#1}{#2}{% + \edef\su@resta{\su@rest#2\@nil}% + \ifx\@empty\su@resta #3\else #4\fi + }{#4}% +} +%% +%% calls #3 if part of string after substring is empty, otherwise calls #4. +\newcommand*\IfBehindSubStringEmpty[2]{% + \su@ExpandTwoArgs{#1}{#2}\su@IfBehindSubStringEmpty +} +%% +\newcommand*\su@IfBehindSubStringEmpty[4]{% + \def\su@rest##1#1##2\@nil{##2}% + \IfSubStringInString{#1}{#2}{% + \edef\su@resta{\su@rest#2\@nil}% + \ifx\@empty\su@resta #3\else #4\fi + }{#4}% +} +%% %% counter for counting appearances \newcounter{su@anzahl} %% % #1: String % #2: Substring % #3: Counter -\newcommand*{\su@StringSubstringCounter}[3]{% +\newcommand*\su@StringSubstringCounter[3]{% \su@IfSubStringInString{#2}{#1}{% \stepcounter{#3}% \def\su@rest##1#2##2\@nil{##2}% @@ -124,10 +158,10 @@ }{}% } %% -\newcommand*{\CountSubStrings}[2]{% +\newcommand*\CountSubStrings[2]{% \su@ExpandTwoArgs{#1}{#2}\su@CountSubStrings } -\newcommand*{\su@CountSubStrings}[2]{% +\newcommand*\su@CountSubStrings[2]{% \setcounter{su@anzahl}{0}% \su@StringSubstringCounter{#2}{#1}{su@anzahl}% \thesu@anzahl @@ -135,13 +169,13 @@ % #1: counter % #2: substring % #3: string -\newcommand*{\SubStringsToCounter}[3]{% +\newcommand*\SubStringsToCounter[3]{% \su@ExpandTwoArgs{#2}{#3}\su@SubStringsToCounter{#1}% } % #1: substring % #2: string % #3: counter -\newcommand*{\su@SubStringsToCounter}[3]{% +\newcommand*\su@SubStringsToCounter[3]{% \setcounter{#3}{0}% \su@StringSubstringCounter{#2}{#1}{#3}% } |