commit 82af8778f1b7f73e6f33a9c6d57da061f567457f
Author: Kornel Benko <[email protected]>
Date:   Sun May 29 12:06:18 2022 +0200

    Introduce isNumberChar(char_type) function
    
    In FindAdv we use Qt to interpret regular expressions.
    Regex uses for instance '\w', '\d' etc.
    '\d' finds not just '0-9' but also e.g. '߂' (Nko Digit Two: U+07c2)
    '\w' includes also such numbers.
    
    ATM, only FindAdv uses this function.
---
 src/lyxfind.cpp          |   12 +++---------
 src/support/lstrings.cpp |    4 ++++
 src/support/textutils.h  |    3 +++
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 025b2bc..594e2aa 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -4833,7 +4833,7 @@ static int findAdvReplace(BufferView * bv, 
FindAndReplaceOptions const & opt, Ma
 
 static bool isWordChar(char_type c)
 {
-       return isLetterChar(c) || isDigitASCII(c);
+       return isLetterChar(c) || isNumberChar(c);
 }
 
 /// Perform a FindAdv operation.
@@ -4888,15 +4888,9 @@ bool findAdv(BufferView * bv, FindAndReplaceOptions & 
opt)
                                                    it != it_end; ++it)
                                                        md2.push_back(*it);
                                                docstring inp = asString(md2);
-                                               LYXERR0("Got \"" << inp << 
"\"");
-                                               char_type prev = inp[0];
                                                for (len = 0; (unsigned) len < 
inp.size() && len + cur.pos() <= cur.lastpos(); len++) {
-                                                       char_type c = inp[len];
-                                                       if (isLetterChar(c))
-                                                               continue;
-                                                       if (isDigitASCII(c))
-                                                               continue;
-                                                       break;
+                                                       if 
(!isWordChar(inp[len]))
+                                                               break;
                                                }
                                                // len == 0 means previous char 
was a word separator
                                                // len == 1       search starts 
with a word separator
diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp
index b9c23f5..6a8e90e 100644
--- a/src/support/lstrings.cpp
+++ b/src/support/lstrings.cpp
@@ -189,6 +189,10 @@ bool isDigitASCII(char_type c)
        return '0' <= c && c <= '9';
 }
 
+bool isNumberChar(char_type c)
+{
+       return ucs4_to_qchar(c).isNumber();
+}
 
 bool isAlnumASCII(char_type c)
 {
diff --git a/src/support/textutils.h b/src/support/textutils.h
index 3c29c92..64498fa 100644
--- a/src/support/textutils.h
+++ b/src/support/textutils.h
@@ -55,6 +55,9 @@ bool isEuropeanNumberTerminator(char_type c);
 /// return whether \p c is a digit in the ASCII range
 bool isDigitASCII(char_type c);
 
+/// return whether \p c is a digit (not just 0-9)
+bool isNumberChar(char_type c);
+
 /// return whether \p c is alpha or a digit in the ASCII range
 bool isAlnumASCII(char_type c);
 
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to