summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/coolstr
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-12-31 23:32:12 +0000
committerKarl Berry <karl@freefriends.org>2006-12-31 23:32:12 +0000
commite7c5a338a8a39e0964862cc028a9cef4c7ccf6e8 (patch)
tree844a266171d3ccce462d151426611a2287ed2c98 /Master/texmf-dist/tex/latex/coolstr
parent2935ee2140aaffed80b7fbf5d7650e0bcb065d99 (diff)
coolstr update (31dec06)
git-svn-id: svn://tug.org/texlive/trunk@3073 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/coolstr')
-rw-r--r--Master/texmf-dist/tex/latex/coolstr/coolstr.sty191
1 files changed, 140 insertions, 51 deletions
diff --git a/Master/texmf-dist/tex/latex/coolstr/coolstr.sty b/Master/texmf-dist/tex/latex/coolstr/coolstr.sty
index c74aff34b76..3b23fcc86ef 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/09/17 v1.0 COntent Oriented LaTeX Strings]
+ [2006/12/30 v2.0a COntent Oriented LaTeX Strings]
\RequirePackage{ifthen}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
@@ -35,110 +35,185 @@
\newcounter{COOL@strlen}%
\newcommand{\COOL@strEnd}{\%\%\%}
\newcommand{\COOL@intEnd}{\%@\%@\%@}
+\let\COOL@strStop=\relax
\newcommand{\setstrEnd}[1]{\renewcommand{\COOL@strEnd}{#1}}
\newcounter{COOL@strpointer}
\def\COOL@strgobble[#1]#2#3{%
-\ifthenelse{\equal{#3}{\COOL@strEnd}}
+\ifthenelse{\equal{#3}{\COOL@strEnd}}%
{%
-\ifthenelse{\value{COOL@strpointer}=#1}
+\ifthenelse{\value{COOL@strpointer}=#1}%
{%
-#2
+#2%
}%
{%
}%
}%
{%
-\ifthenelse{\value{COOL@strpointer}=#1}
+\ifthenelse{\value{COOL@strpointer}=#1}%
{%
-#2
+#2%
}%
{%
}%
\stepcounter{COOL@strpointer}%
-\COOL@strgobble[#1]#3
+\COOL@strgobble[#1]#3%
}%
}
\newcommand{\strchar}[2]{%
\setcounter{COOL@strpointer}{1}%
\COOL@strgobble[#2]#1\COOL@strEnd%
}
-\newboolean{COOL@firstdecimalfound}
-\newboolean{COOL@seconddecimalfound}
-\newboolean{COOL@efound}
-\newboolean{COOL@digitfound}
-
-\def\COOL@numericgobbler#1#2{%
-\ifthenelse{\equal{#2}{\COOL@strEnd}}%
+\newcommand{\strlen}[1]{%
+\strchar{#1}{0}
+\arabic{COOL@strpointer}%
+}
+\newcommand{\strlenstore}[2]{%
+\strchar{#1}{0}%
+\setcounter{#2}{COOL@strpointer}%
+}
+\newboolean{COOL@charmatch}
+\def\COOL@strcomparegobble[#1]<#2>#3#4{%
+\ifthenelse{\equal{#4}{\COOL@strEnd}}%
{%
-\ifthenelse{`#1 < `0 \OR `#1 > `9}%
+\ifthenelse{\value{COOL@strpointer}=#1 \AND \equal{#2}{#3} }%
{%
-Not Numeric%
+\setboolean{COOL@charmatch}{true}%
}%
{%
-Is Numeric%
}%
}%
{%
-\ifthenelse{ `#1 < `0 \OR `#1 > `9 }%
-{%
-\ifthenelse{ `#1 = `. }%
+\ifthenelse{\value{COOL@strpointer}=#1 \AND \equal{#2}{#3} }%
{%
-\ifthenelse{ \boolean{COOL@seconddecimalfound} }%
+\setboolean{COOL@charmatch}{true}%
+}%
{%
-Not numeric%
}%
+\stepcounter{COOL@strpointer}%
+\COOL@strcomparegobble[#1]<#2>#4%
+}%
+}
+\newcommand{\ifstrchareq}[5]{%
+\setboolean{COOL@charmatch}{false}%
+\setcounter{COOL@strpointer}{1}%
+\COOL@strcomparegobble[#2]<#3>#1\COOL@strEnd\relax%
+\ifthenelse{ \boolean{COOL@charmatch} }%
{%
-\ifthenelse{ \boolean{COOL@firstdecimalfound} }%
+#4%
+}%
{%
-\ifthenelse{ \boolean{COOL@efound} }%
+#5%
+}%
+}
+\newcommand{\ifstrleneq}[4]{%
+\strchar{#1}{0}%
+\ifthenelse{ \value{COOL@strpointer} = #2 }%
{%
-\setboolean{COOL@seconddecimalfound}{true}%
-\COOL@numericgobbler#2%
+#3%
}%
{%
-Not numeric%
+#4%
}%
+}
+\newboolean{COOL@decimalfound}
+\newboolean{COOL@decimal}
+\def\COOL@decimalgobbler#1#2\COOL@strEnd{%
+\ifthenelse{\equal{#2}{\COOL@strStop}}%
+{%
+\ifthenelse{`#1 < `0 \OR `#1 > `9}%
+{%
+\ifthenelse{ `#1 = `. \AND \NOT \value{COOL@strpointer} = 1 \AND \NOT \boolean{COOL@decimalfound} }%
+{%
}%
{%
-\setboolean{COOL@firstdecimalfound}{true}%
-\COOL@numericgobbler#2%
+\setboolean{COOL@decimal}{false}%
+}%
}%
+{%
}%
}%
{%
-\ifthenelse{ \(`#1 = `E\) \OR \(`#1 = `e\) }%
+\ifthenelse{ `#1 < `0 \OR `#1 > `9 }%
{%
-\ifthenelse{ \boolean{COOL@efound} \OR \NOT \boolean{COOL@digitfound} }%
+\ifthenelse{ `#1 = `. \AND \NOT \boolean{COOL@decimalfound} }%
{%
-Not numeric%
+\setboolean{COOL@decimalfound}{true}%
}%
+{\ifthenelse{ \(`#1 = `+ \OR `#1 = `-\) \AND \value{COOL@strpointer} = 1 }%
{%
-\setboolean{COOL@efound}{true}%
-\COOL@numericgobbler#2%
}%
+{%
+\setboolean{COOL@decimal}{false}%
+}}%
+}%
+{}%
+\stepcounter{COOL@strpointer}%
+\COOL@decimalgobbler#2\COOL@strEnd%
}%
+}
+\newcommand{\isdecimal}[2]{%
+\setcounter{COOL@strpointer}{1}%
+\setboolean{COOL@decimalfound}{false}%
+\setboolean{COOL@decimal}{true}%
+\expandafter\COOL@decimalgobbler#1\COOL@strStop\COOL@strEnd%
+\ifthenelse{ \boolean{COOL@decimal} }%
{%
-Not Numeric
+\setboolean{#2}{true}%
}%
+{%
+\setboolean{#2}{false}%
}%
}%
+\newboolean{COOL@numeric}%
+\def\COOL@eparser#1e#2\COOL@strEnd{%
+\xdef\COOL@num@magnitude{#1}%
+\xdef\COOL@num@exponent{#2}%
+}
+\def\COOL@ecorrector#1e\COOL@strStop{%
+\xdef\COOL@num@exponent{#1}%
+}
+\def\COOL@Eparser#1E#2\COOL@strEnd{%
+\xdef\COOL@num@magnitude{#1}%
+\xdef\COOL@num@exponent{#2}%
+}
+\def\COOL@Ecorrector#1E\COOL@strStop{%
+\xdef\COOL@num@exponent{#1}%
+}
+\newcommand{\isnumeric}[2]{%
+\COOL@eparser#1e\COOL@strStop\COOL@strEnd%
+\ifthenelse{ \equal{\COOL@num@exponent}{\COOL@strStop} }%
+{%
+\COOL@Eparser#1E\COOL@strStop\COOL@strEnd%
+\ifthenelse{ \equal{\COOL@num@exponent}{\COOL@strStop} }%
{%
-\setboolean{COOL@digitfound}{true}%
-\COOL@numericgobbler#2%
+\gdef\COOL@num@exponent{0}%
}%
+{%
+\expandafter\COOL@Ecorrector\COOL@num@exponent%
}%
}
-\newcommand{\isnumeric}[1]{%
-\setboolean{COOL@firstdecimalfound}{false}%
-\setboolean{COOL@seconddecimalfound}{false}%
-\setboolean{COOL@efound}{false}%
-\setboolean{COOL@digitfound}{false}%
-\COOL@numericgobbler#1\COOL@strEnd%
+{%
+\expandafter\COOL@ecorrector\COOL@num@exponent%
+}%
+\isdecimal{\COOL@num@magnitude}{COOL@numeric}%
+\ifthenelse{ \boolean{COOL@numeric} }%
+{%
+\isdecimal{\COOL@num@exponent}{COOL@numeric}%
+\ifthenelse{ \boolean{COOL@numeric} }%
+{%
+\setboolean{#2}{true}%
+}%
+{%
+\setboolean{#2}{false}%
+}%
+}%
+{%
+\setboolean{#2}{false}%
+}%
}
-\let\COOL@strStop=\relax
\newboolean{COOL@isint}
\def\COOL@intgobbler#1#2\COOL@strEnd{%
-\ifcat#11
+\ifcat#11%
\ifthenelse{\equal{#2}{\COOL@strStop}}%
{%
\ifthenelse{`#1 < `0 \OR `#1 > `9}%
@@ -146,24 +221,38 @@ Not Numeric
\setboolean{COOL@isint}{false}%
}%
{%
-\setboolean{COOL@isint}{true}%
}%
}%
{%
\ifthenelse{ `#1 < `0 \OR `#1 > `9 }%
{%
+\ifthenelse{ `#1 = `+ \OR `#1 = `- \AND \value{COOL@strpointer} = 1 }%
+{}%
+{%
\setboolean{COOL@isint}{false}%
}%
+}%
{%
-\setboolean{COOL@digitfound}{true}%
-\COOL@intgobbler#2\COOL@strEnd%
}%
+\stepcounter{COOL@strpointer}%
+\COOL@intgobbler#2\COOL@strEnd%
}%
-\else
+\else%
\setboolean{COOL@isint}{false}%
-\fi
+\fi%
+}
+\newcommand{\isint}[2]{%
+\setcounter{COOL@strpointer}{1}%
+\setboolean{COOL@isint}{true}%
+\COOL@intgobbler#1\COOL@strStop\COOL@strEnd%
+\ifthenelse{ \boolean{COOL@isint} }%
+{%
+\setboolean{#2}{true}%
+}%
+{%
+\setboolean{#2}{false}%
+}%
}
-\newcommand{\isint}[1]{\COOL@intgobbler#1\COOL@strStop\COOL@strEnd}
\endinput
%%
%% End of file `coolstr.sty'.