From: David Steele Date: Tue, 8 Apr 2014 10:54:22 +0000 (+0100) Subject: Fixed issue with filename parser for 9 patch images X-Git-Tag: dali-2014-wk16-release~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F35%2F19435%2F1;p=platform%2Fcore%2Fuifw%2Fdali-core.git Fixed issue with filename parser for 9 patch images [Issue#] N/A [Problem] .filename9.jpg or .filename#.jpg matched incorrectly. [Cause] matcher not stopping if not detected . before 9 or hash. [Solution] Ensured matcher stops after character before 9.suffix or #.suffix. Note, the filename ".9.jpg" still matches - is this desired? [Verification] Build Repo Change-Id: I32cc2e8db4d35e5237c614a0617ddf8dff198518 Signed-off-by: David Steele --- diff --git a/dali/internal/event/images/image-impl.cpp b/dali/internal/event/images/image-impl.cpp index 8186ac225..2e9a3b61a 100644 --- a/dali/internal/event/images/image-impl.cpp +++ b/dali/internal/event/images/image-impl.cpp @@ -303,10 +303,10 @@ bool Image::IsNinePatchFileName( std::string filename ) { bool match = false; - std::string::const_iterator iter = filename.end(); + std::string::const_reverse_iterator iter = filename.rbegin(); iter--; enum { SUFFIX, HASH, HASH_DOT, DONE } state = SUFFIX; - while(iter >= filename.begin() && state != DONE) + while(iter < filename.rend() && state != DONE) { switch(state) { @@ -338,9 +338,9 @@ bool Image::IsNinePatchFileName( std::string filename ) { if(*iter == '.') { - state = DONE; match = true; } + state = DONE; // Stop testing characters } break; case DONE: @@ -348,7 +348,7 @@ bool Image::IsNinePatchFileName( std::string filename ) } break; } - iter--; + iter++; } return match; }