mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Do not use lyxerr in from_ascii(char const *)
This function is used a lot to initialize static docstrings. This is an issue in theory because lyxerr may not have been initialized in time. In practice of course, lyxerr will only be used when there is a non-ascii character in the parameter, which is really not supposed to happen. This gets rid of 75 coverity reports.
This commit is contained in:
parent
f725abea05
commit
ed291f0d4f
@ -40,7 +40,7 @@ docstring const from_ascii(char const * ascii)
|
|||||||
char_type *d = &s[0];
|
char_type *d = &s[0];
|
||||||
while (--n >= 0) {
|
while (--n >= 0) {
|
||||||
d[n] = ascii[n];
|
d[n] = ascii[n];
|
||||||
LATTEST(static_cast<unsigned char>(ascii[n]) < 0x80);
|
LATTEST_STATIC(static_cast<unsigned char>(ascii[n]) < 0x80);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef LYX_CALLSTACK_PRINTING
|
#ifdef LYX_CALLSTACK_PRINTING
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@ -55,6 +56,13 @@ void doAssert(char const * expr, char const * file, long line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void doAssertStatic(char const * expr, char const * file, long line)
|
||||||
|
{
|
||||||
|
cerr << "ASSERTION " << expr << " VIOLATED IN " << file << ":" << line << endl;
|
||||||
|
BOOST_ASSERT(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
docstring formatHelper(docstring const & msg,
|
docstring formatHelper(docstring const & msg,
|
||||||
char const * expr, char const * file, long line)
|
char const * expr, char const * file, long line)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,11 @@ LATTEST(expr)
|
|||||||
continue with the usual program flow, but failure of expr still means that
|
continue with the usual program flow, but failure of expr still means that
|
||||||
there is something that needs to be fixed.
|
there is something that needs to be fixed.
|
||||||
|
|
||||||
|
LATTEST_STATIC(expr)
|
||||||
|
This is the same as macro LATTEST above, except
|
||||||
|
that it does not use lyxerr, so that it is suitable in static
|
||||||
|
variables initialization.
|
||||||
|
|
||||||
LASSERT(expr, escape)
|
LASSERT(expr, escape)
|
||||||
This macro should be used when a failure of expr is not compatible with
|
This macro should be used when a failure of expr is not compatible with
|
||||||
continuing the ordinary program flow, but is something from which we can
|
continuing the ordinary program flow, but is something from which we can
|
||||||
@ -61,6 +66,7 @@ LAPPERR(expr)
|
|||||||
|
|
||||||
|
|
||||||
void doAssert(char const * expr, char const * file, long line);
|
void doAssert(char const * expr, char const * file, long line);
|
||||||
|
void doAssertStatic(char const * expr, char const * file, long line);
|
||||||
void doWarnIf(char const * expr, char const * file, long line);
|
void doWarnIf(char const * expr, char const * file, long line);
|
||||||
void doBufErr(char const * expr, char const * file, long line);
|
void doBufErr(char const * expr, char const * file, long line);
|
||||||
void doAppErr(char const * expr, char const * file, long line);
|
void doAppErr(char const * expr, char const * file, long line);
|
||||||
@ -76,6 +82,9 @@ docstring printCallStack();
|
|||||||
#define LATTEST(expr) \
|
#define LATTEST(expr) \
|
||||||
if (expr) {} else { lyx::doAssert(#expr, __FILE__, __LINE__); }
|
if (expr) {} else { lyx::doAssert(#expr, __FILE__, __LINE__); }
|
||||||
|
|
||||||
|
#define LATTEST_STATIC(expr) \
|
||||||
|
if (expr) {} else { lyx::doAssertStatic(#expr, __FILE__, __LINE__); }
|
||||||
|
|
||||||
#define LASSERT(expr, escape) \
|
#define LASSERT(expr, escape) \
|
||||||
if (expr) {} else { lyx::doAssert(#expr, __FILE__, __LINE__); escape; }
|
if (expr) {} else { lyx::doAssert(#expr, __FILE__, __LINE__); escape; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user