mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Cleanup debug level handling, and a few other tweaks.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@374 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
457e414feb
commit
af1ecc336d
21
ChangeLog
21
ChangeLog
@ -1,3 +1,24 @@
|
||||
1999-12-13 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* po/de.po: fix the Export menu
|
||||
|
||||
* lyx.man: update the description of -dbg
|
||||
|
||||
* src/lyx_main.C (setDebuggingLevel): call Debug::showLevel()
|
||||
(commandLineHelp): updated
|
||||
(easyParse): show list of available debug levels if -dbg is passed
|
||||
without argument.
|
||||
|
||||
* src/Makefile.am: add debug.C
|
||||
|
||||
* src/debug.h: moved some code to debug.C
|
||||
|
||||
* src/debug.C: new file. Contains code to set and show debug
|
||||
level.
|
||||
|
||||
* src/layout.C: remove 'break' after 'continue' in switch
|
||||
statements, since these cannot be reached.
|
||||
|
||||
1999-12-13 Allan Rae <rae@lyx.org>
|
||||
|
||||
* src/mathed/math_hash.C (math_hash): renamed from hash(), name clash.
|
||||
|
6
lyx.man
6
lyx.man
@ -67,9 +67,9 @@ to obtain the
|
||||
desired effect. Negative positions are ignored. If no valid position
|
||||
is given, the main window is centered.
|
||||
.TP
|
||||
.BI \-dbg " debug-level"
|
||||
where debug-level is a sum of debugging options.
|
||||
Use "\fBlyx -dbg 65535 -help\fR" to see the different flags.
|
||||
.BI \-dbg " feature[,feature...]"
|
||||
where feature is a name or number.
|
||||
Use "\fBlyx -dbg\fR" to see the list of available debug features.
|
||||
.TP
|
||||
.BI \-Reverse
|
||||
swaps foreground and background colors.
|
||||
|
4
po/de.po
4
po/de.po
@ -3600,9 +3600,7 @@ msgstr "FIM|Nn#n#N"
|
||||
msgid ""
|
||||
"Export%t|as LaTeX...%x40|as DVI...%x41|as PostScript...%x42|as Ascii "
|
||||
"Text...%x43|as HTML...%x44|Custom...%x45"
|
||||
msgstr ""
|
||||
"Exportieren%t|als LaTeX...%x40|als DVI...%x41|als PostScript...%x42|als "
|
||||
"Ascii Text...%x43|Benutzerdefiniert...%x44"
|
||||
msgstr "Exportieren%t|als LaTeX...%x40|als DVI...%x41|als PostScript...%x42|als Ascii Text...%x43|als HTML...%x44|Benutzerdefiniert...%x45"
|
||||
|
||||
#: src/menus.C:498
|
||||
msgid ""
|
||||
|
@ -71,6 +71,7 @@ lyx_SOURCES = \
|
||||
credits.h \
|
||||
credits_form.C \
|
||||
credits_form.h \
|
||||
debug.C \
|
||||
debug.h \
|
||||
figure.h \
|
||||
filedlg.C \
|
||||
|
92
src/debug.C
Normal file
92
src/debug.C
Normal file
@ -0,0 +1,92 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright (C) 1999 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
#include "debug.h"
|
||||
|
||||
struct error_item {
|
||||
Debug::type level;
|
||||
char const * name;
|
||||
char const * desc;
|
||||
};
|
||||
|
||||
static error_item errorTags[] = {
|
||||
{ Debug::INFO, "info", "General information"},
|
||||
{ Debug::INIT, "init", "Program initialisation"},
|
||||
{ Debug::KEY, "key", "Keyboard events handling"},
|
||||
{ Debug::TOOLBAR, "toolbar", "Toolbar handling"},
|
||||
{ Debug::PARSER, "parser", "Lyxlex grammer parser"},
|
||||
{ Debug::LYXRC, "lyxrc", "Configuration files reading"},
|
||||
{ Debug::KBMAP, "kbmap", "Custom keyboard definition"},
|
||||
{ Debug::LATEX, "latex", "LaTeX generation/execution"},
|
||||
{ Debug::MATHED, "mathed", "Math editor"},
|
||||
{ Debug::FONT, "font", "Font handling"},
|
||||
{ Debug::TCLASS, "tclass", "Textclass files reading"},
|
||||
{ Debug::LYXVC, "lyxvc", "Version control"},
|
||||
{ Debug::LYXSERVER, "lyxserver", "External control interface"},
|
||||
{ Debug::ROFF, "roff", "Keep *roff temporary files"},
|
||||
{ Debug::ACTION, "action", "User commands"},
|
||||
{ Debug::NONE, "none", "No debugging message"},
|
||||
{ Debug::ANY, "any", "All debugging messages"}
|
||||
};
|
||||
|
||||
static const int numErrorTags = sizeof(errorTags)/sizeof(error_item);
|
||||
|
||||
Debug::type Debug::value(string const & val)
|
||||
{
|
||||
type l = Debug::NONE;
|
||||
string v(val);
|
||||
while (!v.empty()) {
|
||||
string::size_type st = v.find(',');
|
||||
string tmp(lowercase(v.substr(0, st)));
|
||||
if (tmp.empty())
|
||||
break;
|
||||
// Is it a number?
|
||||
if (isStrInt(tmp))
|
||||
l |= static_cast<type>(strToInt(tmp));
|
||||
else
|
||||
// Search for an explicit name
|
||||
for (int i = 0 ; i<numErrorTags ; ++i)
|
||||
if (tmp == errorTags[i].name) {
|
||||
l |= errorTags[i].level;
|
||||
break;
|
||||
}
|
||||
if (st == string::npos) break;
|
||||
v.erase(0, st + 1);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
void Debug::showLevel(ostream &o, Debug::type level)
|
||||
{
|
||||
// Show what features are traced
|
||||
for (int i = 0 ; i < numErrorTags ; ++i)
|
||||
if (errorTags[i].level != Debug::ANY
|
||||
&& errorTags[i].level != Debug::NONE
|
||||
&& errorTags[i].level & level)
|
||||
o << "Debugging `" << errorTags[i].name
|
||||
<< "' (" << errorTags[i].desc << ')' << endl;
|
||||
}
|
||||
|
||||
|
||||
void Debug::showTags(ostream &)
|
||||
{
|
||||
for (int i = 0 ; i < numErrorTags ; ++i)
|
||||
fprintf(stdout, " %5d %-10s%-35s\n",
|
||||
errorTags[i].level,
|
||||
errorTags[i].name,
|
||||
errorTags[i].desc);
|
||||
}
|
||||
|
||||
|
||||
|
60
src/debug.h
60
src/debug.h
@ -57,56 +57,18 @@ struct Debug {
|
||||
/** A function to convert symbolic string names on debug levels
|
||||
to their numerical value.
|
||||
*/
|
||||
static Debug::type value(string const & val) {
|
||||
type l = Debug::NONE;
|
||||
string v(val);
|
||||
while (!v.empty()) {
|
||||
string::size_type st = v.find(',');
|
||||
string tmp(v.substr(0, st));
|
||||
if (tmp.empty()) break;
|
||||
if (isStrInt(tmp)) {
|
||||
l |= static_cast<type>(strToInt(tmp));
|
||||
break;
|
||||
}
|
||||
if (!compare_no_case(tmp,"NONE"))
|
||||
l |= Debug::NONE;
|
||||
else if (!compare_no_case(tmp,"INFO"))
|
||||
l |= Debug::INFO;
|
||||
else if (!compare_no_case(tmp,"INIT"))
|
||||
l |= Debug::INIT;
|
||||
else if (!compare_no_case(tmp,"KEY"))
|
||||
l |= Debug::KEY;
|
||||
else if (!compare_no_case(tmp,"TOOLBAR"))
|
||||
l |= Debug::TOOLBAR;
|
||||
else if (!compare_no_case(tmp,"PARSER"))
|
||||
l |= Debug::PARSER;
|
||||
else if (!compare_no_case(tmp,"LYXRC"))
|
||||
l |= Debug::LYXRC;
|
||||
else if (!compare_no_case(tmp,"KBMAP"))
|
||||
l |= Debug::KBMAP;
|
||||
else if (!compare_no_case(tmp,"LATEX"))
|
||||
l |= Debug::LATEX;
|
||||
else if (!compare_no_case(tmp,"MATHED"))
|
||||
l |= Debug::MATHED;
|
||||
else if (!compare_no_case(tmp,"FONT"))
|
||||
l |= Debug::FONT;
|
||||
else if (!compare_no_case(tmp,"TCLASS"))
|
||||
l |= Debug::TCLASS;
|
||||
else if (!compare_no_case(tmp,"LYXVC"))
|
||||
l |= Debug::LYXVC;
|
||||
else if (!compare_no_case(tmp,"LYXSERVER"))
|
||||
l |= Debug::LYXSERVER;
|
||||
else if (!compare_no_case(tmp,"ROFF"))
|
||||
l |= Debug::ROFF;
|
||||
else if (!compare_no_case(tmp,"ACTION"))
|
||||
l |= Debug::ACTION;
|
||||
else break; // unknown string
|
||||
if (st == string::npos) break;
|
||||
v.erase(0, st + 1);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
static Debug::type value(string const & val);
|
||||
|
||||
/** Display the tags and descriptions of the current debug level
|
||||
of ds
|
||||
*/
|
||||
static void showLevel(ostream &o, type level);
|
||||
|
||||
/** show all the possible tags that can be used for debugging */
|
||||
static void showTags(ostream &o);
|
||||
|
||||
};
|
||||
|
||||
///
|
||||
inline void operator|= (Debug::type & d1, Debug::type d2)
|
||||
{
|
||||
|
12
src/layout.C
12
src/layout.C
@ -178,12 +178,12 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
|
||||
// See comment in lyxrc.C.
|
||||
switch(le) {
|
||||
case LyXLex::LEX_FEOF:
|
||||
continue; break;
|
||||
continue;
|
||||
|
||||
case LyXLex::LEX_UNDEF: // parse error
|
||||
lexrc.printError("Unknown layout tag `$$Token'");
|
||||
error = true;
|
||||
continue; break;
|
||||
continue;
|
||||
default: break;
|
||||
}
|
||||
switch(static_cast<LayoutTags>(le)) {
|
||||
@ -437,7 +437,7 @@ void LyXLayout::readAlignPossible(LyXLex & lexrc)
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown alignment `$$Token'");
|
||||
continue; break;
|
||||
continue;
|
||||
default: break;
|
||||
};
|
||||
switch (static_cast<AlignTags>(le)) {
|
||||
@ -799,12 +799,12 @@ bool LyXTextClass::Read(string const & filename, bool merge)
|
||||
int le = lexrc.lex();
|
||||
switch(le) {
|
||||
case LyXLex::LEX_FEOF:
|
||||
continue; break;
|
||||
continue;
|
||||
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown TextClass tag `$$Token'");
|
||||
error = true;
|
||||
continue; break;
|
||||
continue;
|
||||
default: break;
|
||||
}
|
||||
switch(static_cast<TextClassTags>(le)) {
|
||||
@ -1085,7 +1085,7 @@ void LyXTextClass::readClassOptions(LyXLex & lexrc)
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown ClassOption tag `$$Token'");
|
||||
continue; break;
|
||||
continue;
|
||||
default: break;
|
||||
}
|
||||
switch (static_cast<ClassOptionsTags>(le)) {
|
||||
|
@ -438,19 +438,7 @@ void setDebuggingLevel(string const & dbgLevel)
|
||||
{
|
||||
lyxerr << _("Setting debug level to ") << dbgLevel << endl;
|
||||
lyxerr.level(Debug::value(dbgLevel));
|
||||
lyxerr[Debug::INFO] << "Debugging INFO #" << Debug::INFO << endl;
|
||||
lyxerr[Debug::INIT] << "Debugging INIT #" << Debug::INIT << endl;
|
||||
lyxerr[Debug::KEY] << "Debugging KEY #" << Debug::KEY << endl;
|
||||
lyxerr[Debug::TOOLBAR] << "Debugging TOOLBAR #" << Debug::TOOLBAR << endl;
|
||||
lyxerr[Debug::PARSER] << "Debugging LEX and PARSER #" << Debug::PARSER << endl;
|
||||
lyxerr[Debug::LYXRC] << "Debugging LYXRC #" << Debug::LYXRC << endl;
|
||||
lyxerr[Debug::KBMAP] << "Debugging KBMAP #" << Debug::KBMAP << endl;
|
||||
lyxerr[Debug::LATEX] << "Debugging LATEX #" << Debug::LATEX << endl;
|
||||
lyxerr[Debug::MATHED] << "Debugging MATHED #" << Debug::MATHED << endl;
|
||||
lyxerr[Debug::FONT] << "Debugging FONT #" << Debug::FONT << endl;
|
||||
lyxerr[Debug::TCLASS] << "Debugging TCLASS #" << Debug::TCLASS << endl;
|
||||
lyxerr[Debug::LYXVC] << "Debugging LYXVC #" << Debug::LYXVC << endl;
|
||||
lyxerr[Debug::LYXSERVER] << "Debugging LYXSERVER #" << Debug::LYXSERVER << endl;
|
||||
Debug::showLevel(lyxerr, lyxerr.level());
|
||||
}
|
||||
|
||||
|
||||
@ -467,7 +455,9 @@ void commandLineHelp()
|
||||
"\t-height y set the height of the main window\n"
|
||||
"\t-xpos x set the x position of the main window\n"
|
||||
"\t-ypos y set the y position of the main window\n"
|
||||
"\t-dbg n where n is a sum of debugging options. Try -dbg 65535 -help\n"
|
||||
"\t-dbg feature[,feature]...\n"
|
||||
" select the features to debug.\n"
|
||||
" Type `lyx -dbg' to see the list of features\n"
|
||||
"\t-Reverse swaps foreground & background colors\n"
|
||||
"\t-Mono runs LyX in black and white mode\n"
|
||||
"\t-FastSelection use a fast routine for drawing selections\n\n"
|
||||
@ -491,9 +481,13 @@ bool LyX::easyParse(int * argc, char * argv[])
|
||||
for (int j = i; j < (*argc); ++j)
|
||||
argv[j] = argv[j + 2];
|
||||
--i; // After shift, check this number again.
|
||||
} else
|
||||
lyxerr << _("Missing number for -dbg switch!")
|
||||
} else {
|
||||
lyxerr << _("List of supported debug flags:")
|
||||
<< endl;
|
||||
Debug::showTags(lyxerr);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
// Check for "-sysdir"
|
||||
else if (arg == "-sysdir") {
|
||||
|
Loading…
Reference in New Issue
Block a user