mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Use new isAlphaASCII and isDigitASCII functions instead of isalpha and
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
This commit is contained in:
parent
3213757e9a
commit
329d50d90d
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -16,22 +16,7 @@
|
||||
#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);
|
||||
}
|
||||
|
@ -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 += ".";
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user