This also contains the manual->std::count change.
Index: src/LyXAction.cpp =================================================================== --- src/LyXAction.cpp (revision 21106) +++ src/LyXAction.cpp (working copy) @@ -423,7 +423,7 @@ } -LyXAction::func_type const LyXAction::getActionType(kb_action action) const +LyXAction::func_type LyXAction::getActionType(kb_action action) const { info_map::const_iterator const it = lyx_info_map.find(action); return it != lyx_info_map.end() ? it->second.type : Hidden; Index: src/insets/InsetBibtex.cpp =================================================================== --- src/insets/InsetBibtex.cpp (revision 21106) +++ src/insets/InsetBibtex.cpp (working copy) @@ -36,6 +36,7 @@ #include <boost/tokenizer.hpp> +#include <limits> namespace lyx { @@ -91,7 +92,7 @@ case LFUN_INSET_MODIFY: { InsetCommandParams p(BIBTEX_CODE); try { - if (!InsetCommandMailer::string2params("bibtex", + if (!InsetCommandMailer::string2params("bibtex", to_utf8(cmd.argument()), p)) { cur.noUpdate(); break; @@ -100,7 +101,7 @@ if (message.type_ == support::WarningException) { Alert::warning(message.title_, message.details_); cur.noUpdate(); - } else + } else throw message; break; } @@ -203,7 +204,7 @@ } else if (!runparams.inComment && runparams.nice && not_from_texmf && !isValidLaTeXFilename(database)) { frontend::Alert::warning(_("Invalid filename"), - _("The following filename is likely to cause trouble " + _("The following filename is likely to cause trouble " "when running the exported file through LaTeX: ") + from_utf8(database)); } @@ -401,7 +402,7 @@ /// @return true if a string of length > 0 could be read. /// bool readTypeOrKey(docstring & val, idocfstream & ifs, - docstring const & delimChars, docstring const &illegalChars, + docstring const & delimChars, docstring const &illegalChars, charCase chCase) { char_type ch; @@ -421,10 +422,10 @@ // read value bool legalChar = true; - while (ifs && !isSpace(ch) && + while (ifs && !isSpace(ch) && delimChars.find(ch) == docstring::npos && (legalChar = (illegalChars.find(ch) == docstring::npos)) - ) + ) { if (chCase == makeLowerCase) val += lowercase(ch); @@ -432,7 +433,7 @@ val += ch; ifs.get(ch); } - + if (!legalChar) { ifs.putback(ch); return false; @@ -493,33 +494,33 @@ do { ifs.get(ch); } while (ifs && isSpace(ch)); - + if (!ifs) return false; - + //We now have the first non-whitespace character //We'll collapse adjacent whitespace. bool lastWasWhiteSpace = false; - - // inside this delimited text braces must match. - // Thus we can have a closing delimiter only - // when nestLevel == 0 + + // inside this delimited text braces must match. + // Thus we can have a closing delimiter only + // when nestLevel == 0 int nestLevel = 0; - + while (ifs && (nestLevel > 0 || ch != delim)) { if (isSpace(ch)) { lastWasWhiteSpace = true; ifs.get(ch); continue; } - //We output the space only after we stop getting + //We output the space only after we stop getting //whitespace so as not to output any whitespace //at the end of the value. if (lastWasWhiteSpace) { lastWasWhiteSpace = false; val += ' '; } - + val += ch; // update nesting level @@ -610,7 +611,7 @@ // We don't restrict keys to ASCII in LyX, since our own // InsetBibitem can generate non-ASCII keys, and nonstandard // 8bit clean bibtex forks exist. - + idocfstream ifs(it->toFilesystemEncoding().c_str(), std::ios_base::in, buffer.params().encoding().iconvName()); @@ -629,8 +630,8 @@ docstring entryType; - if (!readTypeOrKey(entryType, ifs, from_ascii("{("), - docstring(), makeLowerCase) || !ifs) + if (!readTypeOrKey(entryType, ifs, from_ascii("{("), + docstring(), makeLowerCase) || !ifs) continue; if (entryType == from_ascii("comment")) { @@ -657,8 +658,8 @@ docstring name; docstring value; - if (!readTypeOrKey(name, ifs, from_ascii("="), - from_ascii("#{}(),"), makeLowerCase) || !ifs) + if (!readTypeOrKey(name, ifs, from_ascii("="), + from_ascii("#{}(),"), makeLowerCase) || !ifs) continue; // next char must be an equal sign @@ -685,18 +686,18 @@ // Citation entry. Try to read the key. docstring key; - if (!readTypeOrKey(key, ifs, from_ascii(","), - from_ascii("}"), keepCase) || !ifs) + if (!readTypeOrKey(key, ifs, from_ascii(","), + from_ascii("}"), keepCase) || !ifs) continue; ///////////////////////////////////////////// - // now we have a key, so we will add an entry - // (even if it's empty, as bibtex does) + // now we have a key, so we will add an entry + // (even if it's empty, as bibtex does) // // we now read the field = value pairs. - // all items must be separated by a comma. If - // it is missing the scanning of this entry is - // stopped and the next is searched. + // all items must be separated by a comma. If + // it is missing the scanning of this entry is + // stopped and the next is searched. docstring fields; docstring name; docstring value; @@ -704,14 +705,14 @@ docstring data; BibTeXInfo keyvalmap; keyvalmap.entryType = entryType; - + bool readNext = removeWSAndComma(ifs); - + while (ifs && readNext) { // read field name - if (!readTypeOrKey(name, ifs, from_ascii("="), - from_ascii("{}(),"), makeLowerCase) || !ifs) + if (!readTypeOrKey(name, ifs, from_ascii("="), + from_ascii("{}(),"), makeLowerCase) || !ifs) break; // next char must be an equal sign Index: src/BufferView.cpp =================================================================== --- src/BufferView.cpp (revision 21106) +++ src/BufferView.cpp (working copy) @@ -138,7 +138,7 @@ while (tmpdit) { Inset const * inset = tmpdit.nextInset(); if (inset - && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() + && std::find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() && (contents.empty() || static_cast<InsetCommand const *>(inset)->getContents() == contents)) { dit = tmpdit; @@ -164,7 +164,7 @@ if (same_content) { Inset const * inset = tmpdit.nextInset(); if (inset - && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()) { + && std::find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()) { contents = static_cast<InsetCommand const *>(inset)->getContents(); } } @@ -1814,7 +1814,7 @@ // (if this paragraph contains insets etc., rebreaking will // recursively descend) tm.redoParagraph(bottom_pit); - ParagraphMetrics const & pm = tm.parMetrics(bottom_pit); + ParagraphMetrics const & pm = tm.parMetrics(bottom_pit); if (pm.height() != old_height) // Paragraph height has changed so we cannot proceed to // the singlePar optimisation. @@ -2003,19 +2003,19 @@ int lastw = 0; // Addup contribution of nested insets, from inside to outside, - // keeping the outer paragraph for a special handling below + // keeping the outer paragraph for a special handling below for (size_t i = dit.depth() - 1; i >= 1; --i) { CursorSlice const & sl = dit[i]; int xx = 0; int yy = 0; - + // get relative position inside sl.inset() sl.inset().cursorPos(*this, sl, boundary && (i + 1 == dit.depth()), xx, yy); - + // Make relative position inside of the edited inset relative to sl.inset() x += xx; y += yy; - + // In case of an RTL inset, the edited inset will be positioned to the left // of xx:yy if (sl.text()) { @@ -2040,7 +2040,7 @@ Dimension const dim = sl.inset().dimension(*this); lastw = dim.wid; } - + //lyxerr << "Cursor::getPos, i: " // << i << " x: " << xx << " y: " << y << endl; } @@ -2068,20 +2068,20 @@ for (size_t rit = 0; rit != rend; ++rit) y += pm.rows()[rit].height(); y += pm.rows()[rend].ascent(); - + TextMetrics const & bottom_tm = textMetrics(dit.bottom().text()); - + // Make relative position from the nested inset now bufferview absolute. int xx = bottom_tm.cursorX(dit.bottom(), boundary && dit.depth() == 1); x += xx; - - // In the RTL case place the nested inset at the left of the cursor in + + // In the RTL case place the nested inset at the left of the cursor in // the outer paragraph bool boundary_1 = boundary && 1 == dit.depth(); bool rtl = bottom_tm.isRTL(dit.bottom(), boundary_1); if (rtl) x -= lastw; - + return Point(x, y); } @@ -2191,7 +2191,7 @@ if (fname.empty()) { FileDialog fileDlg(_("Select file to insert"), ( asParagraph - ? LFUN_FILE_INSERT_PLAINTEXT_PARA + ? LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT) ); FileDialog::Result result = Index: src/MenuBackend.cpp =================================================================== --- src/MenuBackend.cpp (revision 21106) +++ src/MenuBackend.cpp (working copy) @@ -131,7 +131,7 @@ } -docstring const MenuItem::binding(bool forgui) const +docstring const MenuItem::binding(bool /*forgui*/) const { if (kind_ != Command) return docstring(); @@ -492,7 +492,7 @@ if (first) { Buffer * b = first; int ii = 1; - + // We cannot use a for loop as the buffer list cycles. do { docstring label = makeDisplayPath(b->absFileName(), 20); @@ -501,13 +501,13 @@ label = convert<docstring>(ii) + ". " + label + '|' + convert<docstring>(ii); tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, b->absFileName()))); - + b = theBufferList().next(b); ++ii; - } while (b != first); + } while (b != first); } else { tomenu.add(MenuItem(MenuItem::Command, _("No Documents Open!"), - FuncRequest(LFUN_NOACTION))); + FuncRequest(LFUN_NOACTION))); return; } } @@ -661,7 +661,7 @@ for (; cit != end; ++cit) { docstring const label = cit->first; if (cit->second.lyxtype == s) - tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, + tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FLEX_INSERT, label))); } Index: src/LaTeX.cpp =================================================================== --- src/LaTeX.cpp (revision 21106) +++ src/LaTeX.cpp (working copy) @@ -674,7 +674,7 @@ retval |= RERUN; } } else if (prefixIs(token, "! ") || - fle_style && regex_match(token, sub, file_line_error)) { + (fle_style && regex_match(token, sub, file_line_error))) { // Ok, we have something that looks like a TeX Error // but what do we really have. Index: src/LyXAction.h =================================================================== --- src/LyXAction.h (revision 21106) +++ src/LyXAction.h (working copy) @@ -83,7 +83,7 @@ /// Return the name (and argument) associated with the given (pseudo) action std::string const getActionName(kb_action action) const; - func_type const getActionType(kb_action action) const; + func_type getActionType(kb_action action) const; /// True if the command has `flag' set bool funcHasFlag(kb_action action, func_attrib flag) const; Index: src/mathed/InsetMathGrid.cpp =================================================================== --- src/mathed/InsetMathGrid.cpp (revision 21106) +++ src/mathed/InsetMathGrid.cpp (working copy) @@ -189,8 +189,8 @@ if (c == '|') { colinfo_[col].lines_++; } else if ((c == 'p' || c == 'm' || c == 'b'|| - c == '!' || c == '@' || c == '>' || c == '<') && - it + 1 != hh.end() && *(it + 1) == '{') { + c == '!' || c == '@' || c == '>' || c == '<') && + it + 1 != hh.end() && *(it + 1) == '{') { // @{decl.} and p{width} are standard LaTeX, the // others are extensions by array.sty bool const newcolumn = c == 'p' || c == 'm' || c == 'b'; @@ -503,7 +503,7 @@ } */ metricsMarkers2(dim); - // Cache the inset dimension. + // Cache the inset dimension. setDimCache(mi, dim); } @@ -638,7 +638,7 @@ } -void InsetMathGrid::drawT(TextPainter & pain, int x, int y) const +void InsetMathGrid::drawT(TextPainter & /*pain*/, int /*x*/, int /*y*/) const { // for (idx_type idx = 0; idx < nargs(); ++idx) // cell(idx).drawT(pain, x + cellXOffset(idx), y + cellYOffset(idx)); Index: src/mathed/MathStream.cpp =================================================================== --- src/mathed/MathStream.cpp (revision 21106) +++ src/mathed/MathStream.cpp (working copy) @@ -18,10 +18,12 @@ #include "support/textutils.h" #include <algorithm> +#include <cstring> + +using std::strlen; namespace lyx { -using std::strlen; ////////////////////////////////////////////////////////////////////// @@ -88,12 +90,16 @@ ws.pendingSpace(false); } ws.os() << s; +#if 0 int lf = 0; docstring::const_iterator dit = s.begin(); docstring::const_iterator end = s.end(); for (; dit != end; ++dit) if ((*dit) == '\n') ++lf; +#else + int lf = std::count(s.begin(), s.end(), char_type('\n')); +#endif ws.addlines(lf); return ws; } Index: src/mathed/InsetMathFrac.cpp =================================================================== --- src/mathed/InsetMathFrac.cpp (revision 21106) +++ src/mathed/InsetMathFrac.cpp (working copy) @@ -133,7 +133,7 @@ } } metricsMarkers(dim); - // Cache the inset dimension. + // Cache the inset dimension. setDimCache(mi, dim); } @@ -159,9 +159,9 @@ Dimension const dim1 = cell(1).dimension(*pi.base.bv); Dimension const dim2 = cell(2).dimension(*pi.base.bv); int xx = x + dim2.wid + 5; - cell(0).draw(pi, xx + 2, + cell(0).draw(pi, xx + 2, y - dim0.des - 5); - cell(1).draw(pi, xx + dim0.width() + 5, + cell(1).draw(pi, xx + dim0.width() + 5, y + dim1.asc / 2); } } else { @@ -215,7 +215,7 @@ } -void InsetMathFrac::drawT(TextPainter & pain, int x, int y) const +void InsetMathFrac::drawT(TextPainter & /*pain*/, int /*x*/, int /*y*/) const { // FIXME: BROKEN! /* Index: src/support/docstream.cpp =================================================================== --- src/support/docstream.cpp (revision 21106) +++ src/support/docstream.cpp (working copy) @@ -15,6 +15,7 @@ #include <cerrno> #include <cstdio> +#include <cstring> #include <iconv.h> #include <locale> @@ -214,8 +215,8 @@ // The CJK encodings use (different) multibyte representation as well. // All other encodings encode one UCS4 code point in one byte // (and can therefore only encode a subset of UCS4) - // Note that BIG5 and SJIS do not work with LaTeX (see lib/encodings). - // Furthermore, all encodings that use shifting (like SJIS) do not work with + // Note that BIG5 and SJIS do not work with LaTeX (see lib/encodings). + // Furthermore, all encodings that use shifting (like SJIS) do not work with // iconv_codecvt_facet. if (encoding_ == "UTF-8" || encoding_ == "GB" || Index: src/support/mkdir.cpp =================================================================== --- src/support/mkdir.cpp (revision 21106) +++ src/support/mkdir.cpp (working copy) @@ -29,6 +29,9 @@ #ifdef _WIN32 # include <windows.h> #endif +#include <cstdlib> +#include <cstring> + namespace lyx { namespace support { Index: src/support/abort.cpp =================================================================== --- src/support/abort.cpp (revision 21106) +++ src/support/abort.cpp (working copy) @@ -13,8 +13,6 @@ #include "support/lyxlib.h" -namespace lyx { - #ifdef HAVE_STDLIB_H # include <stdlib.h> #endif @@ -24,6 +22,3 @@ { ::abort(); } - - -} // namespace lyx Index: src/support/minizip/zipunzip.cpp =================================================================== --- src/support/minizip/zipunzip.cpp (revision 21106) +++ src/support/minizip/zipunzip.cpp (working copy) @@ -45,10 +45,10 @@ // The original minizip.c and miniunz.c distributed with minizip provide -// two command line tools minizip and miniunz. This file combines these two -// files and modifies the interface to provide two functions zipFiles and +// two command line tools minizip and miniunz. This file combines these two +// files and modifies the interface to provide two functions zipFiles and // unzipToDir. This file is covered by the original minizip license. -// +// #include <config.h> @@ -82,6 +82,8 @@ # include <utime.h> #endif #include <fcntl.h> +#include <cstring> +#include <cstdlib> #include "zip.h" #include "unzip.h" @@ -243,7 +245,7 @@ err = zipWriteInFileInZip (zf, buf, size_read); if (err<0) { printf("error in writing %s in the zipfile\n", - filenameinzip); + filenameinzip); return false; } } @@ -255,7 +257,7 @@ err = zipCloseFileInZip(zf); if (err != ZIP_OK) { printf("error in closing %s in the zipfile\n", - filenameinzip); + filenameinzip); return false; } } @@ -541,4 +543,3 @@ unzCloseCurrentFile(uf); return true; } - Index: src/support/socktools.cpp =================================================================== --- src/support/socktools.cpp (revision 21106) +++ src/support/socktools.cpp (working copy) @@ -49,6 +49,7 @@ #endif #include <cerrno> +#include <cstring> using std::endl; using std::string; Index: src/Text3.cpp =================================================================== --- src/Text3.cpp (revision 21106) +++ src/Text3.cpp (working copy) @@ -211,7 +211,7 @@ if (gotsel && pastesel) { lyx::dispatch(FuncRequest(LFUN_PASTE, "0")); InsetText * insetText = dynamic_cast<InsetText *>(inset); - if (insetText && !insetText->allowMultiPar() + if ((insetText && !insetText->allowMultiPar()) || cur.lastpit() == 0) { // reset first par to default LayoutPtr const layout = @@ -226,7 +226,7 @@ } } else { // reset surrounding par to default - docstring const layoutname = + docstring const layoutname = cur.buffer().params().getTextClass().defaultLayoutName(); cur.leaveInset(*inset); text->setLayout(cur, layoutname); @@ -417,20 +417,20 @@ bool select = cmd.action == LFUN_DOWN_SELECT || cmd.action == LFUN_UP_SELECT; cur.selHandle(select); - + // move cursor up/down bool up = cmd.action == LFUN_UP_SELECT || cmd.action == LFUN_UP; bool const successful = cur.upDownInText(up, needsUpdate); if (successful) { - // notify insets which were left and get their update flags + // notify insets which were left and get their update flags notifyCursorLeaves(cur.beforeDispatchCursor(), cur); cur.fixIfBroken(); - + // redraw if you leave mathed (for the decorations) needsUpdate |= cur.beforeDispatchCursor().inMathed(); } else cur.undispatched(); - + break; } @@ -942,7 +942,7 @@ // "Edit->Paste recent" menu. cap::copySelectionToStack(); - cap::pasteSelection(bv->cursor(), + cap::pasteSelection(bv->cursor(), bv->buffer().errorList("Paste")); bv->buffer().errors("Paste"); bv->buffer().markDirty(); @@ -1487,17 +1487,17 @@ // Given data, an encoding of the ParagraphParameters // generated in the Paragraph dialog, this function sets // the current paragraph, or currently selected paragraphs, - // appropriately. + // appropriately. // NOTE: This function overrides all existing settings. setParagraphs(cur, cmd.argument()); cur.message(_("Paragraph layout set")); break; } - + case LFUN_PARAGRAPH_PARAMS: { // Given data, an encoding of the ParagraphParameters as we'd - // find them in a LyX file, this function modifies the current paragraph, - // or currently selected paragraphs. + // find them in a LyX file, this function modifies the current paragraph, + // or currently selected paragraphs. // NOTE: This function only modifies, and does not override, existing // settings. setParagraphs(cur, cmd.argument(), true); @@ -1824,10 +1824,10 @@ if (!cmd.argument().empty()) { InsetLayout il = cur.inset().getLayout(cur.buffer().params()); enable = cur.inset().lyxCode() == FLEX_CODE - && il.lyxtype == to_utf8(cmd.argument()); + && il.lyxtype == to_utf8(cmd.argument()); } else { - enable = !isMainText(cur.bv().buffer()) - && cur.inset().nargs() == 1; + enable = !isMainText(cur.bv().buffer()) + && cur.inset().nargs() == 1; } break; Index: src/Buffer.cpp =================================================================== --- src/Buffer.cpp (revision 21106) +++ src/Buffer.cpp (working copy) @@ -108,6 +108,7 @@ #include <fstream> using std::endl; +using std::find; using std::for_each; using std::make_pair; @@ -167,7 +168,7 @@ { public: Impl(Buffer & parent, FileName const & file, bool readonly); - + BufferParams params; LyXVC lyxvc; string temppath; @@ -468,7 +469,7 @@ params().listings_params.clear(); params().clearLayoutModules(); params().pdfoptions().clear(); - + for (int i = 0; i < 4; ++i) { params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i]; params().temp_bullet(i) = ITEMIZE_DEFAULTS[i]; @@ -903,7 +904,7 @@ content = FileName(addName(temppath(), "content.lyx")); else content = fname; - + if (params().compressed) { gz::ogzstream ofs(content.toFilesystemEncoding().c_str(), ios::out|ios::trunc); if (!ofs) @@ -1107,7 +1108,7 @@ } // output_preamble texrow().start(paragraphs().begin()->id(), 0); - + LYXERR(Debug::INFO) << "preamble finished, now the body." << endl; if (!lyxrc.language_auto_begin && @@ -1628,7 +1629,7 @@ { BOOST_ASSERT(pimpl_->filename.exists()); // if method == timestamp, check timestamp before checksum - return (method == checksum_method + return (method == checksum_method || pimpl_->timestamp_ != pimpl_->filename.lastModified()) && pimpl_->checksum_ != sum(pimpl_->filename); } @@ -1964,7 +1965,7 @@ /// int start() { - command_ = to_utf8(bformat(_("Auto-saving %1$s"), + command_ = to_utf8(bformat(_("Auto-saving %1$s"), from_utf8(fname_.absFilename()))); return run(DontWait); } @@ -2079,9 +2080,9 @@ // FIXME UNICODE FileDialog fileDlg(_("Choose a filename to save document as"), LFUN_BUFFER_WRITE_AS, - make_pair(_("Documents|#o#O"), + make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)), - make_pair(_("Templates|#T#t"), + make_pair(_("Templates|#T#t"), from_utf8(lyxrc.template_path))); if (!support::isLyXFilename(fname)) @@ -2107,14 +2108,14 @@ if (!support::isLyXFilename(fname)) fname += ".lyx"; - } else + } else fname = makeAbsPath(newname, onlyPath(oldname)).absFilename(); if (FileName(fname).exists()) { docstring const file = makeDisplayPath(fname, 30); docstring text = bformat(_("The document %1$s already " "exists.\n\nDo you want to " - "overwrite that document?"), + "overwrite that document?"), file); int const ret = Alert::prompt(_("Overwrite document?"), text, 0, 1, _("&Overwrite"), _("&Cancel")); @@ -2169,7 +2170,7 @@ void Buffer::loadChildDocuments() const { bool parse_error = false; - + for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) { if (it->lyxCode() != INCLUDE_CODE) continue;
-- Lgb