Changeset 18700

Show
Ignore:
Timestamp:
17.03.2009 14:31:58 (10 years ago)
Author:
kjdon
Message:

findlastchar was dereferencing the last iterator (end()), so now it decrements that before dereferencing. parameter name changed to last_plus_one to hopefully inform user of this.

Location:
gsdl/trunk/common-src/src/lib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/common-src/src/lib/text_t.cpp

    r16066 r18700  
    358358} 
    359359 
    360 text_t::iterator findlastchar (text_t::iterator first, text_t::iterator last,  
     360text_t::iterator findlastchar (text_t::iterator first, text_t::iterator last_plus_one,  
    361361               unsigned short c) 
    362362{ 
    363   text_t::iterator current = last; 
     363  text_t::iterator current = last_plus_one - 1; 
    364364  while (current != first) { 
    365365    if (*current == c) break; 
     
    368368  if (current == first) { 
    369369    if (*current == c) return current; 
    370     return last; 
     370    return last_plus_one; 
    371371  } 
    372372 
  • gsdl/trunk/common-src/src/lib/text_t.h

    r16066 r18700  
    225225text_t::iterator findchar (text_t::iterator first, text_t::iterator last,  
    226226               unsigned short c); 
    227 text_t::iterator findlastchar (text_t::iterator first, text_t::iterator last,  
     227// Find the last occurrence of c between first and last_plus_one -1. Returns last_plus_one if not found. 
     228text_t::iterator findlastchar (text_t::iterator first, text_t::iterator last_plus_one,  
    228229                   unsigned short c); 
    229230text_t::iterator findword (text_t::iterator first, text_t::iterator last,