diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-10-20 21:06:49 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-10-20 21:06:49 +0000 |
commit | 68b8b5136677435a84da7d277e78470ac4a41a64 (patch) | |
tree | 8fc93d4776793be3ba16295b6b1acf1ac3f045b1 | |
parent | 80f6dabd288b6d4048204416b15a90130a78a6f7 (diff) | |
download | libbu++-68b8b5136677435a84da7d277e78470ac4a41a64.tar.gz libbu++-68b8b5136677435a84da7d277e78470ac4a41a64.tar.bz2 libbu++-68b8b5136677435a84da7d277e78470ac4a41a64.tar.xz libbu++-68b8b5136677435a84da7d277e78470ac4a41a64.zip |
Hopefully this fixes some really out there fstring corner casese.
Diffstat (limited to '')
-rw-r--r-- | src/fbasicstring.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/fbasicstring.h b/src/fbasicstring.h index 19853f5..4c33479 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h | |||
@@ -1118,7 +1118,7 @@ namespace Bu | |||
1118 | */ | 1118 | */ |
1119 | chr *getStr() | 1119 | chr *getStr() |
1120 | { | 1120 | { |
1121 | if( core->pFirst == NULL ) | 1121 | if( core->pFirst == NULL || core->nLength == 0 ) |
1122 | return (chr *)""; | 1122 | return (chr *)""; |
1123 | 1123 | ||
1124 | flatten(); | 1124 | flatten(); |
@@ -1133,7 +1133,7 @@ namespace Bu | |||
1133 | */ | 1133 | */ |
1134 | const chr *getStr() const | 1134 | const chr *getStr() const |
1135 | { | 1135 | { |
1136 | if( core->pFirst == NULL ) | 1136 | if( core->pFirst == NULL || core->nLength == 0 ) |
1137 | return (chr *)""; | 1137 | return (chr *)""; |
1138 | 1138 | ||
1139 | flatten(); | 1139 | flatten(); |
@@ -1219,7 +1219,7 @@ namespace Bu | |||
1219 | DEPRECATED | 1219 | DEPRECATED |
1220 | chr *c_str() | 1220 | chr *c_str() |
1221 | { | 1221 | { |
1222 | if( core->pFirst == NULL ) | 1222 | if( core->pFirst == NULL || core->nLength == 0 ) |
1223 | return NULL; | 1223 | return NULL; |
1224 | 1224 | ||
1225 | flatten(); | 1225 | flatten(); |
@@ -1235,7 +1235,7 @@ namespace Bu | |||
1235 | DEPRECATED | 1235 | DEPRECATED |
1236 | const chr *c_str() const | 1236 | const chr *c_str() const |
1237 | { | 1237 | { |
1238 | if( core->pFirst == NULL ) | 1238 | if( core->pFirst == NULL || core->nLength == 0 ) |
1239 | return NULL; | 1239 | return NULL; |
1240 | 1240 | ||
1241 | flatten(); | 1241 | flatten(); |
@@ -1460,7 +1460,7 @@ namespace Bu | |||
1460 | */ | 1460 | */ |
1461 | bool operator==( const chr *pData ) const | 1461 | bool operator==( const chr *pData ) const |
1462 | { | 1462 | { |
1463 | if( core->pFirst == NULL ) { | 1463 | if( core->pFirst == NULL || core->nLength == 0 ) { |
1464 | if( pData == NULL ) | 1464 | if( pData == NULL ) |
1465 | return true; | 1465 | return true; |
1466 | if( pData[0] == (chr)0 ) | 1466 | if( pData[0] == (chr)0 ) |
@@ -1646,9 +1646,11 @@ namespace Bu | |||
1646 | 1646 | ||
1647 | bool compareSub( const chr *pData, long nIndex, long nLen ) const | 1647 | bool compareSub( const chr *pData, long nIndex, long nLen ) const |
1648 | { | 1648 | { |
1649 | if( core->pFirst == NULL ) { | 1649 | if( core->pFirst == NULL || core->nLength == 0 ) { |
1650 | if( pData == NULL ) | 1650 | if( pData == NULL ) |
1651 | return true; | 1651 | return true; |
1652 | if( nLen == 0 ) | ||
1653 | return true; | ||
1652 | if( pData[0] == (chr)0 ) | 1654 | if( pData[0] == (chr)0 ) |
1653 | return true; | 1655 | return true; |
1654 | return false; | 1656 | return false; |
@@ -1673,7 +1675,7 @@ namespace Bu | |||
1673 | 1675 | ||
1674 | bool compareSub( const MyType &rData, long nIndex, long nLen ) const | 1676 | bool compareSub( const MyType &rData, long nIndex, long nLen ) const |
1675 | { | 1677 | { |
1676 | if( core->pFirst == NULL || rData.core->pFirst == NULL ) | 1678 | if( core->pFirst == NULL || core->nLength == 0 || rData.core->pFirst == NULL || rData.core->nLength == 0 ) |
1677 | return false; | 1679 | return false; |
1678 | if( nLen < 0 ) | 1680 | if( nLen < 0 ) |
1679 | nLen = rData.core->nLength; | 1681 | nLen = rData.core->nLength; |
@@ -1922,7 +1924,7 @@ namespace Bu | |||
1922 | 1924 | ||
1923 | void trimBack( chr c ) | 1925 | void trimBack( chr c ) |
1924 | { | 1926 | { |
1925 | if( core->pFirst == NULL ) | 1927 | if( core->pFirst == NULL || core->nLength == 0 ) |
1926 | return; | 1928 | return; |
1927 | flatten(); | 1929 | flatten(); |
1928 | for( ; core->pFirst->nLength > 0 && core->pFirst->pData[core->pFirst->nLength-1] == c; core->pFirst->nLength--, core->nLength-- ) { } | 1930 | for( ; core->pFirst->nLength > 0 && core->pFirst->pData[core->pFirst->nLength-1] == c; core->pFirst->nLength--, core->nLength-- ) { } |
@@ -2018,7 +2020,7 @@ namespace Bu | |||
2018 | if( isFlat() ) | 2020 | if( isFlat() ) |
2019 | return; | 2021 | return; |
2020 | 2022 | ||
2021 | if( core->pFirst == NULL ) | 2023 | if( core->pFirst == NULL || core->nLength == 0 ) |
2022 | return; | 2024 | return; |
2023 | 2025 | ||
2024 | Chunk *pNew = core->newChunk( core->nLength ); | 2026 | Chunk *pNew = core->newChunk( core->nLength ); |