[LyX/master] Revert last three commits.
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Fri May 1 09:52:16 UTC 2020
Le 26/04/2020 à 08:49, Richard Kimberly Heck a écrit :
> commit 7b9dc7bc9e26b26d15ca4c3e5b2d0383ea97733f
> Author: Richard Kimberly Heck <rikiheck at lyx.org>
> Date: Sun Apr 26 03:08:35 2020 -0400
>
> Revert last three commits.
>
> There are other issues here. The big one is in TextMetrics::getPitNearY,
> where -1 is used as a 'special' return value for pit.
This special value of -1 is nothing else than the "npos" that we get in
STL for things like strings. We could define a value lyx::npos which is
this special value for pit_type and pos_type and get rid of the signedness.
What were the other issues?
JMarc
> ---
> src/BufferView.cpp | 5 +----
> src/Compare.cpp | 6 +++---
> src/RowPainter.cpp | 3 ++-
> src/support/lstrings.cpp | 8 --------
> src/support/lstrings.h | 2 --
> src/support/types.h | 2 +-
> 6 files changed, 7 insertions(+), 19 deletions(-)
>
> diff --git a/src/BufferView.cpp b/src/BufferView.cpp
> index ca59fcb..621b58e 100644
> --- a/src/BufferView.cpp
> +++ b/src/BufferView.cpp
> @@ -2860,7 +2860,7 @@ void BufferView::updateMetrics(Update::flags & update_flags)
> int y1 = d->anchor_ypos_ - anchor_pm.ascent();
> // We are now just above the anchor paragraph.
> pit_type pit1 = d->anchor_pit_ - 1;
> - while (y1 >= 0) {
> + for (; pit1 >= 0 && y1 >= 0; --pit1) {
> tm.redoParagraph(pit1);
> ParagraphMetrics & pm = tm.par_metrics_[pit1];
> y1 -= pm.descent();
> @@ -2868,9 +2868,6 @@ void BufferView::updateMetrics(Update::flags & update_flags)
> pm.setPosition(y1);
> tm.updatePosCache(pit1);
> y1 -= pm.ascent();
> - if (pit1 == 0)
> - break;
> - --pit1;
> }
>
> // Redo paragraphs below the anchor if necessary.
> diff --git a/src/Compare.cpp b/src/Compare.cpp
> index 931fe76..60a0b65 100644
> --- a/src/Compare.cpp
> +++ b/src/Compare.cpp
> @@ -881,10 +881,10 @@ void Compare::Impl::writeToDestBuffer(DocRange const & range,
>
> void Compare::Impl::writeToDestBuffer(ParagraphList const & pars) const
> {
> + pit_type const pit = dest_pars_->size() - 1;
> dest_pars_->insert(dest_pars_->end(), pars.begin(), pars.end());
> - pit_type pit = dest_pars_->size();
> - if (pit > 0)
> - mergeParagraph(dest_buf_->params(), *dest_pars_, pit - 1);
> + if (pit >= 0)
> + mergeParagraph(dest_buf_->params(), *dest_pars_, pit);
> }
>
>
> diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
> index a392c02..6e4cf31 100644
> --- a/src/RowPainter.cpp
> +++ b/src/RowPainter.cpp
> @@ -60,7 +60,8 @@ RowPainter::RowPainter(PainterInfo & pi,
> //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
> //row_.dump();
>
> - LBUFERR(row.pit() < text.paragraphs().size());
> + LBUFERR(row.pit() >= 0);
> + LBUFERR(row.pit() < int(text.paragraphs().size()));
> }
>
>
> diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp
> index 8c15d9b..55e66ce 100644
> --- a/src/support/lstrings.cpp
> +++ b/src/support/lstrings.cpp
> @@ -1507,14 +1507,6 @@ docstring bformat(docstring const & fmt, unsigned int arg1)
> }
>
>
> -docstring bformat(docstring const & fmt, pit_type arg1)
> -{
> - LATTEST(contains(fmt, from_ascii("%1$d")));
> - docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
> - return subst(str, from_ascii("%%"), from_ascii("%"));
> -}
> -
> -
> docstring bformat(docstring const & fmt, docstring const & arg1)
> {
> LATTEST(contains(fmt, from_ascii("%1$s")));
> diff --git a/src/support/lstrings.h b/src/support/lstrings.h
> index 0662769..f661fc5 100644
> --- a/src/support/lstrings.h
> +++ b/src/support/lstrings.h
> @@ -17,7 +17,6 @@
> #define LSTRINGS_H
>
> #include "support/docstring.h"
> -#include "support/types.h"
>
> #include <vector>
>
> @@ -370,7 +369,6 @@ docstring bformat(docstring const & fmt, long arg1);
> docstring bformat(docstring const & fmt, long long arg1);
> #endif
> docstring bformat(docstring const & fmt, unsigned int arg1);
> -docstring bformat(docstring const & fmt, pit_type arg1);
> docstring bformat(docstring const & fmt, docstring const & arg1);
> docstring bformat(docstring const & fmt, char * arg1);
> docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2);
> diff --git a/src/support/types.h b/src/support/types.h
> index 75ccec0..c9cf349 100644
> --- a/src/support/types.h
> +++ b/src/support/types.h
> @@ -40,7 +40,7 @@ namespace lyx {
> */
> // FIXME: should be unsigned as well.
> // however, simply changing it breaks a downward loop somewhere...
> - typedef size_t pit_type;
> + typedef ptrdiff_t pit_type;
>
> /// a type for the nesting depth of a paragraph
> typedef size_t depth_type;
>
More information about the lyx-cvs
mailing list