summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/coolstr
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-01-15 01:13:25 +0000
committerKarl Berry <karl@freefriends.org>2007-01-15 01:13:25 +0000
commitc7a76f56847244cd1a2206a8cd63aadc943dad05 (patch)
treeee8facc05e32e05c5d0adcc5182e3325cd02c98c /Master/texmf-dist/tex/latex/coolstr
parent545819791cfa7c73fbb4a62ddb84e10327f0c419 (diff)
coolstr update
git-svn-id: svn://tug.org/texlive/trunk@3491 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/coolstr')
-rw-r--r--Master/texmf-dist/tex/latex/coolstr/coolstr.sty96
1 files changed, 91 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/latex/coolstr/coolstr.sty b/Master/texmf-dist/tex/latex/coolstr/coolstr.sty
index 3b23fcc86ef..6035e3567d1 100644
--- a/Master/texmf-dist/tex/latex/coolstr/coolstr.sty
+++ b/Master/texmf-dist/tex/latex/coolstr/coolstr.sty
@@ -13,7 +13,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{coolstr}
- [2006/12/30 v2.0a COntent Oriented LaTeX Strings]
+ [2007/01/08 v2.1 COntent Oriented LaTeX Strings]
\RequirePackage{ifthen}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
@@ -64,12 +64,98 @@
\COOL@strgobble[#2]#1\COOL@strEnd%
}
\newcommand{\strlen}[1]{%
-\strchar{#1}{0}
+\ifthenelse{\equal{#1}{}}%
+{%
+0%
+}%
+{%
+\strchar{#1}{0}%
\arabic{COOL@strpointer}%
+}%
}
\newcommand{\strlenstore}[2]{%
+\ifthenelse{\equal{#1}{}}%
+{%
+\setcounter{#2}{0}%
+}%
+{%
\strchar{#1}{0}%
-\setcounter{#2}{COOL@strpointer}%
+\setcounter{#2}{\value{COOL@strpointer}}%
+}%
+}
+\newcounter{COOL@str@index}
+\newcounter{COOL@str@start}
+\newcounter{COOL@str@end}
+\newcommand{\substr}[3]{%
+\strlenstore{#1}{COOL@strlen}%
+\ifthenelse{#2 < 0 \AND \NOT #2 < -\value{COOL@strlen}}%
+{%
+\setcounter{COOL@str@index}{\value{COOL@strlen}}%
+\addtocounter{COOL@str@index}{#2}%
+\addtocounter{COOL@str@index}{1}%
+}%
+{\ifthenelse{#2 > 0 \AND \NOT #2 > \value{COOL@strlen}}%
+{%
+\setcounter{COOL@str@index}{#2}%
+}%
+{%
+\setcounter{COOL@str@index}{0}%
+}}%
+\ifthenelse{\equal{#3}{beg}}%
+{%
+\setcounter{COOL@str@start}{1}%
+\setcounter{COOL@str@end}{\value{COOL@str@index}}%
+}%
+{\ifthenelse{\equal{#3}{end}}%
+{%
+\setcounter{COOL@str@start}{\value{COOL@str@index}}%
+\setcounter{COOL@str@end}{\value{COOL@strlen}}%
+}%
+{\ifthenelse{#3 < 0}%
+{%
+\setcounter{COOL@str@start}{\value{COOL@str@index}}%
+\addtocounter{COOL@str@start}{#3}%
+\addtocounter{COOL@str@start}{1}%
+\ifthenelse{\NOT \value{COOL@str@start} > 0}{\setcounter{COOL@str@start}{1}}{}%
+\setcounter{COOL@str@end}{\value{COOL@str@index}}%
+}%
+{\ifthenelse{#3 > 0}%
+{%
+\setcounter{COOL@str@start}{\value{COOL@str@index}}%
+\setcounter{COOL@str@end}{\value{COOL@str@index}}%
+\addtocounter{COOL@str@end}{#3}%
+\addtocounter{COOL@str@end}{-1}%
+\ifthenelse{\value{COOL@str@end} > \value{COOL@strlen}}{\setcounter{COOL@str@end}{\value{COOL@strlen}}}{}%
+}%
+{%
+\setcounter{COOL@str@index}{0}%
+}}}}%
+\ifthenelse{ \value{COOL@str@index} = 0 }%
+{%
+}%
+{%
+\setcounter{COOL@strpointer}{1}%
+\COOL@substrgobbler#1\COOL@strStop\COOL@strEnd%
+}%
+}
+\def\COOL@substrgobbler#1#2\COOL@strEnd{%
+\ifthenelse{\equal{#2}{\COOL@strStop}}%
+{%
+\ifthenelse{ \value{COOL@strpointer} < \value{COOL@str@start} \OR \value{COOL@strpointer} > \value{COOL@str@end} }%
+{}%
+{%
+#1%
+}%
+}%
+{%
+\ifthenelse{ \value{COOL@strpointer} < \value{COOL@str@start} \OR \value{COOL@strpointer} > \value{COOL@str@end} }%
+{}%
+{%
+#1%
+}%
+\stepcounter{COOL@strpointer}%
+\COOL@substrgobbler#2\COOL@strEnd%
+}%
}
\newboolean{COOL@charmatch}
\def\COOL@strcomparegobble[#1]<#2>#3#4{%
@@ -106,8 +192,8 @@
}%
}
\newcommand{\ifstrleneq}[4]{%
-\strchar{#1}{0}%
-\ifthenelse{ \value{COOL@strpointer} = #2 }%
+\strlenstore{#1}{COOL@strlen}%
+\ifthenelse{ \value{COOL@strlen} = #2 }%
{%
#3%
}%