From: Georg Baum Date: Fri, 2 Mar 2007 16:52:49 +0000 (+0000) Subject: * src/support/lstrings.C X-Git-Tag: 1.6.10~10639 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4f4c5d495460be6ef52f7cbd9b0f15d14dc326df;p=lyx.git * src/support/lstrings.C (lowercase): assert that input is pure ASCII (uppercase): ditto * src/support/lstrings.h (lowercase): document that only ASCII input is allowed (uppercase): ditto * src/lyxfind.C (stringSelected): Use compare_no_case (more efficient) * src/MenuBackend.C: remove unused using directive git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17393 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 7470912605..50384a0f94 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -54,7 +54,6 @@ using support::compare_ascii_no_case; using support::contains; using support::makeDisplayPath; using support::token; -using support::uppercase; using boost::bind; diff --git a/src/lyxfind.C b/src/lyxfind.C index 932cbec30e..6de1690977 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -35,7 +35,7 @@ namespace lyx { -using support::lowercase; +using support::compare_no_case; using support::uppercase; using support::split; @@ -206,7 +206,7 @@ bool stringSelected(BufferView * bv, docstring const & searchstr, // string search and select next occurance and return docstring const & str1 = searchstr; docstring const str2 = bv->cursor().selectionAsString(false); - if ((cs && str1 != str2) || lowercase(str1) != lowercase(str2)) { + if ((cs && str1 != str2) || compare_no_case(str1, str2) != 0) { find(bv, searchstr, cs, mw, fw); return false; } diff --git a/src/support/lstrings.C b/src/support/lstrings.C index 42b76a5a16..fe161be991 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -256,12 +256,14 @@ bool isAscii(docstring const & str) char lowercase(char c) { + BOOST_ASSERT(static_cast(c) < 0x80); return char(tolower(c)); } char uppercase(char c) { + BOOST_ASSERT(static_cast(c) < 0x80); return char(toupper(c)); } diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 9c9dbf4d73..7a0cbd5b5f 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -72,12 +72,22 @@ int hexToInt(lyx::docstring const & str); /// is \p str pure ascii? bool isAscii(docstring const & str); -/// Changes the case of \p c to lowercase. -/// Caution: Depends on the locale +/** + * Changes the case of \p c to lowercase. + * Don't use this for non-ASCII characters, since it depends on the locale. + * This overloaded function is only implemented because the char_type variant + * would be used otherwise, and we assert in this function that \p c is in + * the ASCII range. + */ char lowercase(char c); -/// Changes the case of \p c to uppercase. -/// Caution: Depends on the locale +/** + * Changes the case of \p c to uppercase. + * Don't use this for non-ASCII characters, since it depends on the locale. + * This overloaded function is only implemented because the char_type variant + * would be used otherwise, and we assert in this function that \p c is in + * the ASCII range. + */ char uppercase(char c); /// Changes the case of \p c to lowercase.