From af1ecc336d7334b47897724a30090d234ac6e6be Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 13 Dec 1999 15:31:52 +0000 Subject: [PATCH] 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 --- ChangeLog | 21 +++++++++++ lyx.man | 6 ++-- po/de.po | 4 +-- src/Makefile.am | 1 + src/debug.C | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ src/debug.h | 60 ++++++-------------------------- src/layout.C | 12 +++---- src/lyx_main.C | 26 ++++++-------- 8 files changed, 145 insertions(+), 77 deletions(-) create mode 100644 src/debug.C diff --git a/ChangeLog b/ChangeLog index 8039198808..8de3819b99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +1999-12-13 Jean-Marc Lasgouttes + + * 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 * src/mathed/math_hash.C (math_hash): renamed from hash(), name clash. diff --git a/lyx.man b/lyx.man index 31b6dbe691..e44e063065 100644 --- a/lyx.man +++ b/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. diff --git a/po/de.po b/po/de.po index 1822ed524b..f8aafe71b3 100644 --- a/po/de.po +++ b/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 "" diff --git a/src/Makefile.am b/src/Makefile.am index 386c441766..59f9727827 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -71,6 +71,7 @@ lyx_SOURCES = \ credits.h \ credits_form.C \ credits_form.h \ + debug.C \ debug.h \ figure.h \ filedlg.C \ diff --git a/src/debug.C b/src/debug.C new file mode 100644 index 0000000000..3d4d54d382 --- /dev/null +++ b/src/debug.C @@ -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 +#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(strToInt(tmp)); + else + // Search for an explicit name + for (int i = 0 ; i(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) { diff --git a/src/layout.C b/src/layout.C index 899f10baa0..3952d4bb4c 100644 --- a/src/layout.C +++ b/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(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(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(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(le)) { diff --git a/src/lyx_main.C b/src/lyx_main.C index 7a9a615df5..dc26313a7b 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -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") { -- 2.39.2