]> git.lyx.org Git - features.git/commitdiff
Use new isAlphaASCII and isDigitASCII functions instead of isalpha and
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 2 Apr 2007 15:21:36 +0000 (15:21 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 2 Apr 2007 15:21:36 +0000 (15:21 +0000)
isdigit from ctype.h, because the latter are locale dependant and do not
work with char_type.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17698 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMath.C
src/mathed/InsetMathNest.C
src/mathed/InsetMathSymbol.C
src/mathed/MathStream.C
src/sgml.C
src/support/textutils.C
src/support/textutils.h

index e44c3841013697348154aff4cfd812de54369778..b1b46f2d47a7692b1baa949628d8d248b22b19fd 100644 (file)
@@ -18,6 +18,7 @@
 #include "debug.h"
 
 #include "support/lstrings.h"
+#include "support/textutils.h"
 
 #include <boost/current_function.hpp>
 
@@ -77,7 +78,7 @@ void InsetMath::write(WriteStream & os) const
        os << "\\" << s;
        // We need an extra ' ' unless this is a single-char-non-ASCII name
        // or anything non-ASCII follows
-       if (s.size() != 1 || isalpha(s[0]))
+       if (s.size() != 1 || isAlphaASCII(s[0]))
                os.pendingSpace(true);
 }
 
index 84883636161e650fb5e3f0bc8df5c288af326fd9..335bf232b0ebbb806738115209c4ac77a9b32d46 100644 (file)
@@ -49,6 +49,7 @@
 #include "undo.h"
 
 #include "support/lstrings.h"
+#include "support/textutils.h"
 
 #include "frontends/Clipboard.h"
 #include "frontends/Painter.h"
@@ -1228,7 +1229,7 @@ bool InsetMathNest::interpretChar(LCursor & cur, char_type c)
                        return true;
                }
 
-               if (isalpha(c)) {
+               if (isAlphaASCII(c)) {
                        cur.activeMacro()->setName(name + docstring(1, c));
                        return true;
                }
index 4066dba4ef9b98350fa17e5130fd348dd9751335..e8a6dfb49b791b7881cf79291f323b973db59ca5 100644 (file)
@@ -20,7 +20,7 @@
 #include "LaTeXFeatures.h"
 #include "debug.h"
 
-#include <cctype>
+#include "support/textutils.h"
 
 namespace lyx {
 
@@ -220,7 +220,7 @@ void InsetMathSymbol::write(WriteStream & os) const
        // $,#, etc. In theory the restriction based on catcodes, but then
        // we do not handle catcodes very well, let alone cat code changes,
        // so being outside the alpha range is good enough.
-       if (name().size() == 1 && !std::isalpha(name()[0]))
+       if (name().size() == 1 && !isAlphaASCII(name()[0]))
                return;
 
        os.pendingSpace(true);
index e51819dc713b42dba90c0b5808f44d26942d49ef..820aeeab54e6d4239c0c6efdcc05274a6047d48c 100644 (file)
 #include "MathStream.h"
 
 #include "support/lyxalgo.h"
-
-
-namespace {
-
-bool isAlpha(char c)
-{
-       return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
-}
-
-
-bool isAlpha(lyx::char_type c)
-{
-       return c < 0x80 && isAlpha(static_cast<char>(c));
-}
-
-}
+#include "support/textutils.h"
 
 
 namespace lyx {
@@ -100,7 +85,7 @@ NormalStream & operator<<(NormalStream & ns, int i)
 WriteStream & operator<<(WriteStream & ws, docstring const & s)
 {
        if (ws.pendingSpace() && s.length() > 0) {
-               if (isAlpha(s[0]))
+               if (isAlphaASCII(s[0]))
                        ws.os() << ' ';
                ws.pendingSpace(false);
        }
@@ -164,7 +149,7 @@ WriteStream & operator<<(WriteStream & ws, MathArray const & ar)
 WriteStream & operator<<(WriteStream & ws, char const * s)
 {
        if (ws.pendingSpace() && strlen(s) > 0) {
-               if (isAlpha(s[0]))
+               if (isAlphaASCII(s[0]))
                        ws.os() << ' ';
                ws.pendingSpace(false);
        }
@@ -177,7 +162,7 @@ WriteStream & operator<<(WriteStream & ws, char const * s)
 WriteStream & operator<<(WriteStream & ws, char c)
 {
        if (ws.pendingSpace()) {
-               if (isAlpha(c))
+               if (isAlphaASCII(c))
                        ws.os() << ' ';
                ws.pendingSpace(false);
        }
index a5aa601c8f208c59207ea96d09368692598672b9..e5fb7fc2aff1b67eef6b8fe4eba43bd17a78f664 100644 (file)
@@ -24,6 +24,7 @@
 #include "support/lstrings.h"
 #include "support/std_ostream.h"
 #include "support/convert.h"
+#include "support/textutils.h"
 
 #include <map>
 #include <sstream>
@@ -144,13 +145,13 @@ docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams,
                return (*known).second;
 
        // make sure it starts with a letter
-       if (!isalpha(*it) && allowed.find(*it) >= allowed.size())
+       if (!isAlphaASCII(*it) && allowed.find(*it) >= allowed.size())
                content += "x";
 
        bool mangle = false;
        for (; it != end; ++it) {
                char c = *it;
-               if (isalpha(c) || isdigit(c) || c == '-' || c == '.'
+               if (isAlphaASCII(c) || isDigitASCII(c) || c == '-' || c == '.'
                      || allowed.find(c) < allowed.size())
                        content += c;
                else if (c == '_' || c == ' ') {
@@ -168,7 +169,7 @@ docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams,
        if (mangle) {
                content += "-" + convert<docstring>(mangleID++);
        }
-       else if (isdigit(content[content.size() - 1])) {
+       else if (isDigitASCII(content[content.size() - 1])) {
                content += ".";
        }
 
index cfcc7dfa57d9a30e11abde4039c620b253712afa..c5074cb45c7ca14c19ab5375de757ea3e41ac5b7 100644 (file)
@@ -37,6 +37,12 @@ bool isLetterChar(char_type c)
 }
 
 
+bool isAlphaASCII(char_type c)
+{
+       return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
+}
+
+
 bool isPrintable(char_type c)
 {
        if (!is_utf16(c)) {
@@ -74,4 +80,10 @@ bool isDigit(char_type c)
        return ucs4_to_qchar(c).isDigit();
 }
 
+
+bool isDigitASCII(char_type c)
+{
+       return '0' <= c && c <= '9';
+}
+
 } // namespace lyx
index 283db0316bc3011134f5b90c08f195a0894a16a6..50d9acb7f7a3fb076eea7856252ec4e8ebe69c3a 100644 (file)
@@ -30,6 +30,9 @@ bool isLineSeparatorChar(char_type c)
 /// return true if a char is alphabetical (including accented chars)
 bool isLetterChar(char_type c);
 
+/// return whether \p c is an alphabetic character in the ASCII range
+bool isAlphaASCII(char_type c);
+
 /// return true if the char is printable
 bool isPrintable(char_type c);
 
@@ -39,6 +42,9 @@ bool isPrintableNonspace(char_type c);
 /// return true if a unicode char is a digit.
 bool isDigit(char_type c);
 
+/// return whether \p c is a digit in the ASCII range
+bool isDigitASCII(char_type c);
+
 } // namespace lyx
 
 #endif // TEXTUTILS_H