From 912207fe0fa25d21837ced09dcd689c68e449ef7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 5 Sep 2012 21:10:05 +0000 Subject: Added extra formatting argument indexing method to Bu::String::FormatProxy. You can now use %{3} so that arguments can be followed by a digit. --- src/stable/string.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/stable/string.cpp') diff --git a/src/stable/string.cpp b/src/stable/string.cpp index d1f76aa..dd484fd 100644 --- a/src/stable/string.cpp +++ b/src/stable/string.cpp @@ -1269,10 +1269,30 @@ Bu::String Bu::String::FormatProxy::end() const else { String sNum; - while( s && *s >= '0' && *s <= '9' ) + if( *s == '{' ) { - sNum += *s; s++; + while( s && *s >= '0' && *s <= '9' ) + { + sNum += *s; + s++; + } + if( !s || *s != '}' ) + { + delete[] aArg; + throw Bu::ExceptionBase( + "Argument started with a '{' but terminated " + "with a '%c' instead of '}'.", *s ); + } + s++; + } + else + { + while( s && *s >= '0' && *s <= '9' ) + { + sNum += *s; + s++; + } } int iIndex = strtol( sNum.getStr(), 0, 10 )-1; if( iIndex < 0 || iIndex >= iCount ) -- cgit v1.2.3