2001-01-15 Dekel Tsur <dekelts@tau.ac.il>
+ * text.C (InsertChar): Use contains instead of strchr.
+
* lyx_cb.C (MenuInsertLabel): Enable default value code.
2001-01-13 Dekel Tsur <dekelts@tau.ac.il>
}
+bool contains(string const & a, char b)
+{
+ if (a.empty())
+ return false;
+ return a.find(b) != string::npos;
+}
+
+
bool contains(char const * a, char const * b)
{
Assert(a && b);
///
bool contains(string const & a, string const & b);
+///
+bool contains(string const & a, char b);
+
///
bool contains(char const * a, char const * b);
if (lyxrc.auto_number) {
+ static string const number_operators = "+-/*";
+ static string const number_unary_operators = "+-";
+ static string const number_seperators = ".,:";
+
if (current_font.number() == LyXFont::ON) {
- if (!isdigit(c) && !strchr("+-/*", c) &&
- !(strchr(".,:",c) &&
+ if (!isdigit(c) && !contains(number_operators, c) &&
+ !(contains(number_seperators, c) &&
cursor.pos() >= 1 &&
cursor.pos() < cursor.par()->size() &&
GetFont(bview->buffer(),
if (cursor.pos() > 0) {
char const c = cursor.par()->GetChar(cursor.pos() - 1);
- if (strchr("+-",c) &&
+ if (contains(number_unary_operators, c) &&
(cursor.pos() == 1 ||
cursor.par()->IsSeparator(cursor.pos() - 2) ||
cursor.par()->IsNewline(cursor.pos() - 2) )
cursor.par(),
cursor.pos() - 1,
current_font);
- } else if (strchr(".,:", c) &&
+ } else if (contains(number_seperators, c) &&
cursor.pos() >= 2 &&
GetFont(bview->buffer(),
cursor.par(),