aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-09-05 19:29:29 +0000
committerMike Buland <eichlan@xagasoft.com>2012-09-05 19:29:29 +0000
commit69d1606ac97547896a0ede8dee5e59fc4a5de7c2 (patch)
tree0bbbd7d92387c2c810e33cf594e9406485da6915 /src
parent67a4bba2ce4be36a23d75d9ae060579d554f6a17 (diff)
downloadlibbu++-69d1606ac97547896a0ede8dee5e59fc4a5de7c2.tar.gz
libbu++-69d1606ac97547896a0ede8dee5e59fc4a5de7c2.tar.bz2
libbu++-69d1606ac97547896a0ede8dee5e59fc4a5de7c2.tar.xz
libbu++-69d1606ac97547896a0ede8dee5e59fc4a5de7c2.zip
Fixed silly bug involving juxtaposed replacement tokens in
Bu::String::FormatProxy substitutions.
Diffstat (limited to '')
-rw-r--r--src/stable/string.cpp6
-rw-r--r--src/unit/string.unit8
2 files changed, 11 insertions, 3 deletions
diff --git a/src/stable/string.cpp b/src/stable/string.cpp
index 621da93..4cef6b1 100644
--- a/src/stable/string.cpp
+++ b/src/stable/string.cpp
@@ -1252,7 +1252,7 @@ Bu::String::FormatProxy::operator Bu::String() const
1252 } 1252 }
1253 Bu::MemBuf mbOut; 1253 Bu::MemBuf mbOut;
1254 Bu::Formatter f( mbOut ); 1254 Bu::Formatter f( mbOut );
1255 for( String::const_iterator s = rFmt.begin(); s; s++ ) 1255 for( String::const_iterator s = rFmt.begin(); s; )
1256 { 1256 {
1257 if( *s == '%' ) 1257 if( *s == '%' )
1258 { 1258 {
@@ -1278,14 +1278,14 @@ Bu::String::FormatProxy::operator Bu::String() const
1278 } 1278 }
1279 1279
1280 f << (*aArg[iIndex]).format << (*aArg[iIndex]).value; 1280 f << (*aArg[iIndex]).format << (*aArg[iIndex]).value;
1281 if( s ) 1281 continue;
1282 f << *s;
1283 } 1282 }
1284 } 1283 }
1285 else 1284 else
1286 { 1285 {
1287 f << *s; 1286 f << *s;
1288 } 1287 }
1288 s++;
1289 } 1289 }
1290 1290
1291 delete[] aArg; 1291 delete[] aArg;
diff --git a/src/unit/string.unit b/src/unit/string.unit
index acef0d5..dfa0c38 100644
--- a/src/unit/string.unit
+++ b/src/unit/string.unit
@@ -573,6 +573,14 @@ suite String
573 unitTest( Bu::String(" \tHello \t\t\r\nthere\r\n \t").trimWhitespace() 573 unitTest( Bu::String(" \tHello \t\t\r\nthere\r\n \t").trimWhitespace()
574 == "Hello \t\t\r\nthere" ); 574 == "Hello \t\t\r\nthere" );
575 } 575 }
576
577 test format1
578 {
579 unitTest( (Bu::String)Bu::String("%1").arg( 12, Bu::Fmt().width(3) ) == " 12" );
580 unitTest( (Bu::String)Bu::String("%1 %2").arg("IQ").arg(4, Bu::Fmt().plus()) == "IQ +4" );
581 unitTest( (Bu::String)Bu::String("%1%2").arg("IQ").arg(4, Bu::Fmt().plus()) == "IQ+4" );
582 unitTest( (Bu::String)Bu::String("Sup #%1-Guy!").arg( 1 ) == "Sup #1-Guy!" );
583 }
576} 584}
577// 03F09CA4F58AC8CA0E80F0D9D409D0A60700A192270004BC3A99E91D0001034F544603362E35013103313130019CA4F58AC8CA0E0002830800002C4200008AC200EBF7D9D4090127BB010000E3 585// 03F09CA4F58AC8CA0E80F0D9D409D0A60700A192270004BC3A99E91D0001034F544603362E35013103313130019CA4F58AC8CA0E0002830800002C4200008AC200EBF7D9D4090127BB010000E3
578// 586//