From 328f69b0c1870f4f4d38566d24dbbf0c2196de27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 25 Jan 2000 12:35:27 +0000 Subject: [PATCH] fix crossref label list, some debug messages + various git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@445 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 17 ++++++++++++++++ src/BufferView.C | 22 +++++++++++--------- src/DepTable.C | 16 ++++++++------- src/LaTeX.C | 38 +++++++++++++++++++---------------- src/buffer.C | 9 +++++---- src/credits.C | 2 +- src/debug.C | 3 ++- src/debug.h | 7 +++++-- src/insets/insetlatexaccent.C | 30 +++++++++++++-------------- src/kbmap.C | 2 +- src/kbmap.h | 11 +++++----- src/lyx_gui.C | 4 ++-- src/lyx_main.C | 4 ++-- src/lyxvc.C | 4 ++-- src/mathed/math_defs.h | 3 ++- src/mathed/math_inset.C | 2 +- src/mathed/math_iter.C | 4 ++-- src/mathed/math_symbols.C | 3 ++- src/paragraph.C | 21 +++++++++---------- src/spellchecker.C | 3 ++- src/support/DebugStream.C | 2 +- src/table.C | 4 ++-- 22 files changed, 121 insertions(+), 90 deletions(-) diff --git a/ChangeLog b/ChangeLog index 364164c586..b570a82629 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2000-01-25 Lars Gullik Bjønnes + + * several files: marked several lines with "DEL LINE", this is + lines that can be deleted without changing anything. + if () // DEL LINE /* this line is _never_ needed. Delete + checks this anyway */ + delete + + * src/insets/insetlatexaccent.C: Changed some debugs to Debug::KEY + + * src/DepTable.C (update): add a "+" at the end when the checksum + is different. (debugging string only) + + * src/paragraph.C (ReturnNextInsetPointer): fix bug that caused + the next inset to not be displayed. This should also fix the list + of labels in the "Insert Crossreference" dialog. + 2000-01-24 Lars Gullik Bjønnes * src/support/LSubstring.C (LSubstring): set pos to string::npos diff --git a/src/BufferView.C b/src/BufferView.C index 6540e3c29e..b89f9711c1 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -225,7 +225,7 @@ void BufferView::buffer(Buffer * b) // Nuke old image // screen is always deleted when the buffer is changed. - if (screen) + if (screen) // DEL LINE delete screen; screen = 0; @@ -273,7 +273,7 @@ void BufferView::buffer(Buffer * b) void BufferView::updateScreen() { // Regenerate the screen. - if (screen) + if (screen) // DEL LINE delete screen; screen = new LyXScreen(FL_ObjWin(work_area), work_area->w, @@ -1520,13 +1520,17 @@ void BufferView::CursorToggleCB(FL_OBJECT * ob, long) Window tmpwin; int tmp; XGetInputFocus(fl_display, &tmpwin, &tmp); - if (lyxerr.debugging(Debug::INFO)) { - lyxerr << "tmpwin: " << tmpwin - << "\nwindow: " << view->owner_->getForm()->window - << "\nwork_area_focus: " << view->work_area_focus - << "\nlyx_focus : " << view->lyx_focus - << endl; - } + // Commenting this out, we have not had problems with this + // for a long time. We will probably work on this code later + // and we can reenable this debug code then. Now it only + // anoying when debugging. (Lgb) + //if (lyxerr.debugging(Debug::INFO)) { + // lyxerr << "tmpwin: " << tmpwin + // << "\nwindow: " << view->owner_->getForm()->window + // << "\nwork_area_focus: " << view->work_area_focus + // << "\nlyx_focus : " << view->lyx_focus + // << endl; + //} if (tmpwin != view->owner_->getForm()->window) { view->lyx_focus = false; goto skip_timer; diff --git a/src/DepTable.C b/src/DepTable.C index 9597831351..16b5905e09 100644 --- a/src/DepTable.C +++ b/src/DepTable.C @@ -50,9 +50,12 @@ void DepTable::update() unsigned long one = (*itr).second.second; unsigned long two = lyx::sum((*itr).first.c_str()); (*itr).second = make_pair(one, two); - if (lyxerr.debugging()) { - lyxerr << "update: " << (*itr).first << " " - << one << " " << two << endl; + if (lyxerr.debugging(Debug::DEPEND)) { + lyxerr << "Update dep: " << (*itr).first << " " + << one << " " << two; + if (one != two) + lyxerr << " +"; + lyxerr << endl; } } } @@ -93,7 +96,6 @@ bool DepTable::extchanged(string const & ext) const return true; } } - return false; } @@ -125,7 +127,7 @@ void DepTable::write(string const & f) const for (DepList::const_iterator cit = deplist.begin(); cit != deplist.end(); ++cit) { - if (lyxerr.debugging()) { + if (lyxerr.debugging(Debug::DEPEND)) { lyxerr << "Write dep: " << (*cit).first << " " << (*cit).second.first << " " @@ -145,8 +147,8 @@ void DepTable::read(string const & f) unsigned long one = 0; unsigned long two = 0; while(ifs >> nome >> one >> two) { - if (lyxerr.debugging()) { - lyxerr << "read dep: " + if (lyxerr.debugging(Debug::DEPEND)) { + lyxerr << "Read dep: " << nome << " " << one << " " << two << endl; diff --git a/src/LaTeX.C b/src/LaTeX.C index 411519627e..73bf70c380 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -51,7 +51,7 @@ extern BufferList bufferlist; struct texfile_struct { LaTeX::TEX_FILES file; - char const *extension; + char const * extension; }; static @@ -139,11 +139,12 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) // Update the checksums head.update(); - lyxerr[Debug::LATEX] << "Dependency file exists" << endl; + lyxerr[Debug::DEPEND] << "Dependency file exists" << endl; if (head.sumchange()) { ++count; + lyxerr[Debug::DEPEND] + << "Dependency file has changed" << endl; lyxerr[Debug::LATEX] - << "Dependency file has changed\n" << "Run #" << count << endl; minib->Set(string(_("LaTeX run number ")) + tostr(count)); minib->Store(); @@ -152,15 +153,18 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) if (scanres & LaTeX::ERRORS) return scanres; // return on error run_bibtex = scanAux(head); if (run_bibtex) - lyxerr << "Bibtex demands rerun" << endl; + lyxerr[Debug::DEPEND] + << "Bibtex demands rerun" << endl; } else { - lyxerr[Debug::LATEX] << "return no_change" << endl; + lyxerr[Debug::DEPEND] << "return no_change" << endl; return LaTeX::NO_CHANGE; } } else { ++count; - lyxerr[Debug::LATEX] << "Dependency file does not exist\n" - << "Run #" << count << endl; + lyxerr[Debug::DEPEND] + << "Dependency file does not exist" << endl; + lyxerr[Debug::LATEX] + << "Run #" << count << endl; head.insert(file, true); minib->Set(string(_("LaTeX run number ")) + tostr(count)); minib->Store(); @@ -219,8 +223,9 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) if (rerun || head.sumchange()) { rerun = false; ++count; + lyxerr[Debug::DEPEND] + << "Dep. file has changed or rerun requested" << endl; lyxerr[Debug::LATEX] - << "Dep. file has changed or rerun requested\n" << "Run #" << count << endl; minib->Set(string(_("LaTeX run number ")) + tostr(count)); minib->Store(); @@ -231,7 +236,7 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) deplog(head); // reads the latex log head.update(); } else { - lyxerr[Debug::LATEX] << "Dep. file has NOT changed" << endl; + lyxerr[Debug::DEPEND] << "Dep. file has NOT changed" << endl; } // 1.5 @@ -570,7 +575,7 @@ void LaTeX::deplog(DepTable & head) break; foundfile += c; } - lyxerr[Debug::LATEX] << "Found file: " + lyxerr[Debug::DEPEND] << "Found file: " << foundfile << endl; // Ok now we found a file. @@ -582,7 +587,7 @@ void LaTeX::deplog(DepTable & head) // absolute path and should // be inserted. if (AbsolutePath(foundfile)) { - lyxerr[Debug::LATEX] << "AbsolutePath file: " + lyxerr[Debug::DEPEND] << "AbsolutePath file: " << foundfile << endl; // On inital insert we want to do the update at once // since this file can not be a file generated by @@ -595,7 +600,7 @@ void LaTeX::deplog(DepTable & head) // insert it into head if (FileInfo(OnlyFilename(foundfile)).exist()) { if (suffixIs(foundfile, ".aux")) { - lyxerr[Debug::LATEX] << "We don't want " + lyxerr[Debug::DEPEND] << "We don't want " << OnlyFilename(foundfile) << " in the dep file" << endl; @@ -603,19 +608,19 @@ void LaTeX::deplog(DepTable & head) // This is a tex file generated by LyX // and latex is not likely to change this // during its runs. - lyxerr[Debug::LATEX] << "Tmpdir TeX file: " + lyxerr[Debug::DEPEND] << "Tmpdir TeX file: " << OnlyFilename(foundfile) << endl; head.insert(foundfile, true); } else { - lyxerr[Debug::LATEX] << "In tmpdir file:" + lyxerr[Debug::DEPEND] << "In tmpdir file:" << OnlyFilename(foundfile) << endl; head.insert(OnlyFilename(foundfile)); } continue; } - lyxerr[Debug::LATEX] + lyxerr[Debug::DEPEND] << "Not a file or we are unable to find it." << endl; } @@ -632,10 +637,9 @@ void LaTeX::deptex(DepTable & head) tmp = ChangeExtension(file, all_files[i].extension, true); - lyxerr[Debug::LATEX] << "deptex: " << tmp << endl; + lyxerr[Debug::DEPEND] << "deptex: " << tmp << endl; if (fi.newFile(tmp).exist()) head.insert(tmp); } } } - diff --git a/src/buffer.C b/src/buffer.C index a19fffe266..ffdcc84081 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -3823,17 +3823,18 @@ string Buffer::getReferenceList(char delim) { /// if this is a child document and the parent is already loaded /// Use the parent's list instead [ale990407] - if (!params.parentname.empty() && bufferlist.exists(params.parentname)) { + if (!params.parentname.empty() + && bufferlist.exists(params.parentname)) { Buffer * tmp = bufferlist.getBuffer(params.parentname); if (tmp) - return tmp->getReferenceList(delim); + return tmp->getReferenceList(delim); } LyXParagraph * par = paragraph; LyXParagraph::size_type pos; Inset * inset; string lst; - while (par){ + while (par) { pos = -1; while ((inset = par->ReturnNextInsetPointer(pos))){ for (int i = 0; i < inset->GetNumberOfLabels(); ++i) { @@ -3842,7 +3843,7 @@ string Buffer::getReferenceList(char delim) lst += inset->getLabel(i); } ++pos; - } + } par = par->next; } lyxerr.debug() << "References(" << lst << ")" << endl; diff --git a/src/credits.C b/src/credits.C index 72e14b6e3d..78d8374117 100644 --- a/src/credits.C +++ b/src/credits.C @@ -4,7 +4,7 @@ * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich - * Copyright 1995-1999 The LyX Team. + * Copyright 1995-2000 The LyX Team. * * ====================================================== */ diff --git a/src/debug.C b/src/debug.C index abee30ac35..f30249405f 100644 --- a/src/debug.C +++ b/src/debug.C @@ -32,6 +32,7 @@ static error_item errorTags[] = { { Debug::LYXRC, "lyxrc", "Configuration files reading"}, { Debug::KBMAP, "kbmap", "Custom keyboard definition"}, { Debug::LATEX, "latex", "LaTeX generation/execution"}, + { Debug::DEPEND, "depend", "Dependency information"}, { Debug::MATHED, "mathed", "Math editor"}, { Debug::FONT, "font", "Font handling"}, { Debug::TCLASS, "tclass", "Textclass files reading"}, @@ -55,7 +56,7 @@ Debug::type Debug::value(string const & val) while (!v.empty()) { string::size_type st = v.find(','); string tmp(lowercase(v.substr(0, st))); - if (tmp.empty()) + if (tmp.empty()) break; // Is it a number? if (isStrInt(tmp)) diff --git a/src/debug.h b/src/debug.h index c7fcb43fa8..bc396bd543 100644 --- a/src/debug.h +++ b/src/debug.h @@ -47,13 +47,16 @@ struct Debug { /// ACTION = (1 << 14), // 16384 /// - LYXLEX = (1 << 15) + LYXLEX = (1 << 15), + /// + DEPEND = (1 << 16) }; /// static const type ANY = type(INFO | INIT | KEY | TOOLBAR | PARSER | LYXRC | KBMAP | LATEX | MATHED | FONT | TCLASS | LYXVC | - LYXSERVER | ROFF | ACTION | LYXLEX); + LYXSERVER | ROFF | ACTION | LYXLEX | + DEPEND); /// friend inline void operator|=(Debug::type & d1, Debug::type d2); diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 8df9c5746e..d3ca88d12e 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -4,7 +4,7 @@ * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich - * Copyright 1995-1999 The LyX Team. + * Copyright 1995-2000 The LyX Team. * * ====================================================== */ @@ -98,7 +98,7 @@ void InsetLatexAccent::checkContents() } if (contents[0] != '\\') return; // demand that first char is a '\\' - lyxerr.debug() << "Decode: " << contents << endl; + lyxerr[Debug::KEY] << "Decode: " << contents << endl; remdot = false; plusasc = false; plusdesc = false; @@ -213,12 +213,12 @@ void InsetLatexAccent::checkContents() break; } //ic = (modtype == DOT_LESS_J ? 'j' : 'i'); - lyxerr.debug() << "Contents: [" << contents << "]" - << ", ic: " << ic - << ", top: " << plusasc - << ", bot: " << plusdesc - << ", dot: " << remdot - << ", mod: " << modtype << endl; + lyxerr[Debug::KEY] << "Contents: [" << contents << "]" + << ", ic: " << ic + << ", top: " << plusasc + << ", bot: " << plusdesc + << ", dot: " << remdot + << ", mod: " << modtype << endl; // Special case for space } else if (contents[3] == '}') { ic = ' '; @@ -253,12 +253,12 @@ void InsetLatexAccent::checkContents() if (contents[++i] != '}' && contents[++i]) return; // fine, the char is properly decoded now (hopefully) - lyxerr.debug() << "Contents: [" << contents << "]" - << ", ic: " << ic - << ", top: " << plusasc - << ", bot: " << plusdesc - << ", dot: " << remdot - << ", mod: " << modtype << endl; + lyxerr[Debug::KEY] << "Contents: [" << contents << "]" + << ", ic: " << ic + << ", top: " << plusasc + << ", bot: " << plusdesc + << ", dot: " << remdot + << ", mod: " << modtype << endl; } candisp = true; } @@ -413,7 +413,7 @@ void InsetLatexAccent::Draw(LyXFont font, float tmpx = 0; if (font.shape() == LyXFont::ITALIC_SHAPE) tmpx += (8.0 * hg) / 10.0; // italic - lyxerr.debug() << "Removing dot." << endl; + lyxerr[Debug::KEY] << "Removing dot." << endl; // remove the dot first scr.fillRectangle(gc_clear, int(x + tmpx), tmpvar, wid, diff --git a/src/kbmap.C b/src/kbmap.C index 03cf38538f..6572f3df20 100644 --- a/src/kbmap.C +++ b/src/kbmap.C @@ -519,7 +519,7 @@ kb_keymap::~kb_keymap() { if(!table) return; for(kb_key * t = table; t->code != NoSymbol; ++t) - if(t->table) + if(t->table) // DEL LINE delete t->table; delete table; } diff --git a/src/kbmap.h b/src/kbmap.h index e2e15f2286..fd320bf979 100644 --- a/src/kbmap.h +++ b/src/kbmap.h @@ -89,13 +89,12 @@ public: /// - ~kb_sequence() - { - if (sequence != staticseq) { - delete sequence; - delete modifiers; - } + ~kb_sequence() { + if (sequence != staticseq) { + delete sequence; + delete modifiers; } + } /// Add a key to the key sequence and look it up in the curmap /** Add a key to the key sequence and look it up in the curmap diff --git a/src/lyx_gui.C b/src/lyx_gui.C index e0d5ce68d3..4a3e3a61e3 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -202,10 +202,10 @@ LyXGUI::~LyXGUI() { // Lyxserver was created in this class so should be destroyed // here. asierra-970604 - if (lyxserver) { + if (lyxserver) { // DEL LINE delete lyxserver; lyxserver = 0; - } + } // DEL LINE CloseLyXLookup(); } diff --git a/src/lyx_main.C b/src/lyx_main.C index d63e27532b..e8cc0548b1 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -133,10 +133,10 @@ LyX::LyX(int * argc, char * argv[]) // A destructor is always necessary (asierra-970604) LyX::~LyX() { - if (lastfiles) + if (lastfiles) // DEL LINE delete lastfiles; - if (lyxGUI) + if (lyxGUI) // DEL LINE delete lyxGUI; } diff --git a/src/lyxvc.C b/src/lyxvc.C index 3097069d66..e79b2ed072 100644 --- a/src/lyxvc.C +++ b/src/lyxvc.C @@ -33,9 +33,9 @@ LyXVC::~LyXVC() fl_hide_form(browser->LaTeXLog); fl_free_form(browser->LaTeXLog); } - if (vcs) { + if (vcs) { // DEL LINE delete vcs; - } + } // DEL LINE } diff --git a/src/mathed/math_defs.h b/src/mathed/math_defs.h index b7de91e845..83618c024f 100644 --- a/src/mathed/math_defs.h +++ b/src/mathed/math_defs.h @@ -437,7 +437,8 @@ struct MathedRowSt { /// ~MathedRowSt() { delete[] w; - if (label) delete[] label; + if (label) // DEL LINE + delete[] label; } /// Should be const but... MathedRowSt * getNext() const { return next; } diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index ff35b90fff..b4340ad317 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -517,7 +517,7 @@ MathAccentInset::MathAccentInset(MathedInset *ins, int cd, short st) MathAccentInset::~MathAccentInset() { - if (inset) + if (inset) // DEL LINE delete inset; } diff --git a/src/mathed/math_iter.C b/src/mathed/math_iter.C index 512965c316..f1f2f1c2ce 100644 --- a/src/mathed/math_iter.C +++ b/src/mathed/math_iter.C @@ -394,7 +394,7 @@ void MathedIter::Clear() Reset(); while (OK()) { if (IsInset()) { - MathedInset* inset = GetInset(); + MathedInset * inset = GetInset(); if (inset->GetType()!= LM_OT_MACRO_ARG) delete inset; Delete(); @@ -519,7 +519,7 @@ void MathedXIter::Merge(LyxArrayBase *a0) crow = r; } else { Delete(); - pos2--; + --pos2; } } Next(); diff --git a/src/mathed/math_symbols.C b/src/mathed/math_symbols.C index 77f47449fe..58b5c56300 100644 --- a/src/mathed/math_symbols.C +++ b/src/mathed/math_symbols.C @@ -157,7 +157,8 @@ BitmapMenu::BitmapMenu(int n, FL_OBJECT * bt, BitmapMenu * prevx): nb(n) BitmapMenu::~BitmapMenu() { - if (next) delete next; + if (next) // DEL LINE + delete next; if (form->visible) Hide(); fl_free_form(form); delete[] bitmap; diff --git a/src/paragraph.C b/src/paragraph.C index a0635fdd44..8207582b2e 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -142,8 +142,7 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params, os << "\n\\begin_float " << string_footnotekinds[footnotekind] << " "; - } - else { + } else { os << "\n\\end_float "; } } @@ -155,8 +154,7 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params, os << "\n\\begin_deeper "; ++dth; } - } - else { + } else { while (depth < dth) { os << "\n\\end_deeper "; --dth; @@ -233,8 +231,7 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params, } os << '\n'; } - } - else { + } else { // Dummy layout. This means that a footnote ended. os << "\n\\end_float "; footflag = LyXParagraph::NO_FOOTNOTE; @@ -553,14 +550,14 @@ LyXParagraph::~LyXParagraph() while (insettable) { tmpinset = insettable; insettable = insettable->next; - if (tmpinset->inset) + if (tmpinset->inset) // DEL LINE delete tmpinset->inset; delete tmpinset; if (insettable && insettable->next == insettable) { // somehow this recursion appears occasionally // but I can't find where. This bandaid // helps but isn't the best fix. (ARRae) - if (insettable->inset) { + if (insettable->inset) { // DEL LINE delete insettable->inset; } delete insettable; @@ -578,12 +575,12 @@ LyXParagraph::~LyXParagraph() #endif /* table stuff -- begin*/ - if (table) + if (table) // DEL LINE delete table; /* table stuff -- end*/ // ale970302 - if (bibkey) + if (bibkey) // DEL LINE delete bibkey; } @@ -621,7 +618,7 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos) tmpi = tmpi->next; } if (tmpi) { // this should always be true - if (tmpi->inset) // delete the inset if it exists + if (tmpi->inset) // delete the inset if it exists // DEL LINE delete tmpi->inset; if (tmpi == insettable) insettable = tmpi->next; @@ -2201,7 +2198,7 @@ Inset * LyXParagraph::ReturnNextInsetPointer(LyXParagraph::size_type & pos) for (InsetList::iterator it = insetlist.begin(); it != insetlist.end(); ++it) { if ((*it).pos >= pos) { - if (it2 != insetlist.end() || (*it).pos < (*it2).pos) + if (it2 == insetlist.end() || (*it).pos < (*it2).pos) it2 = it; } } diff --git a/src/spellchecker.C b/src/spellchecker.C index f24a0af885..b239790c92 100644 --- a/src/spellchecker.C +++ b/src/spellchecker.C @@ -94,7 +94,8 @@ struct isp_result { misses = static_cast(0); } ~isp_result() { - if (misses) delete[] misses; + if (misses) // DEL LINE + delete[] misses; } }; diff --git a/src/support/DebugStream.C b/src/support/DebugStream.C index ea6bbab231..286fbdc975 100644 --- a/src/support/DebugStream.C +++ b/src/support/DebugStream.C @@ -185,7 +185,7 @@ DebugStream::~DebugStream() { delete nullstream.rdbuf(0); // Without this we leak delete rdbuf(0); // Without this we leak - if (internal) + if (internal) // DEL LINE delete internal; } diff --git a/src/table.C b/src/table.C index b01cca4d3d..04a75b81ba 100644 --- a/src/table.C +++ b/src/table.C @@ -292,10 +292,10 @@ void LyXTable::set_row_column_number_info() row = 0; column = 0; - if (rowofcell) + if (rowofcell) // DEL LINE delete [] rowofcell; rowofcell = new int[numberofcells]; - if (columnofcell) + if (columnofcell) // DEL LINE delete [] columnofcell; columnofcell = new int[numberofcells]; -- 2.39.2