Changeset 5140


Ignore:
Timestamp:
2003-08-15T16:53:41+12:00 (21 years ago)
Author:
sjboddie
Message:

Fix for search term highlighting code so it no longer becomes confused
if the query string contains leading or trailing space.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/highlighttext.cpp

    r3323 r5140  
    3737
    3838static void get_phrase_terms (const text_t &querystring, text_tarray &phrase_terms);
     39
     40static void remove_space (text_t &qstring);
    3941
    4042// highlights text string by adding _starthighlight_ and _endhightlight_
     
    6567    disp.expandstring("Global", "_endhighlight_", ehl);
    6668  }
     69
     70  // remove leading and trailing whitespace
     71  remove_space(querystring);
    6772
    6873  if ((args["hl"] == 2) || ((*(querystring.begin()) == '"') && (*(querystring.end()-1) == '"'))) {
     
    255260  }
    256261}
     262
     263void remove_space (text_t &qstring) {
     264
     265  text_t altered_string;
     266  text_t space;
     267
     268  text_t::const_iterator here = qstring.begin();
     269  text_t::const_iterator end = qstring.end();
     270  while (here != end) {
     271    if (is_unicode_space(*here)) {
     272      space.push_back(*here);
     273    } else {
     274      if (!altered_string.empty()) {
     275    altered_string += space;
     276      }
     277      space.clear();
     278      altered_string.push_back(*here);
     279    }
     280    here++;
     281  }
     282
     283  qstring = altered_string;
     284}
Note: See TracChangeset for help on using the changeset viewer.