diff -Nur wesnoth-1.0.2-orig/src/help.cpp wesnoth-1.0.2/src/help.cpp
--- wesnoth-1.0.2-orig/src/help.cpp 2005-09-21 02:35:50.000000000 +0200
+++ wesnoth-1.0.2/src/help.cpp 2006-07-18 15:57:34.000000000 +0200
@@ -2581,20 +2581,23 @@
std::string get_first_word(const std::string &s)
{
- if (s == "") {
+ if ( s.empty() ) {
return s;
}
size_t first_word_start = s.find_first_not_of(" ");
if (first_word_start == std::string::npos) {
- first_word_start = 0;
+ return s; // String consists of only spaces.
}
size_t first_word_end = s.find_first_of(" \n", first_word_start);
- if (first_word_end == std::string::npos || first_word_end == first_word_start) {
- // Either this word contains no spaces/newlines, or it consists
- // of only spaces and newlines. In either case, use the whole
- // chunk as a word.
+ if (first_word_end == std::string::npos) {
+ // This words ends with no spaces/newlines,
+ // Use the whole chunk as a word.
first_word_end = s.size();
}
+ else if ( first_word_end == first_word_start) {
+ // This word is '\n'.
+ first_word_end = first_word_start+1;
+ }
const std::string first_word = s.substr(0, first_word_end);
return first_word;
}