diff --git a/ChangeLog b/ChangeLog index 202b5a1b9a..5f675221b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-05-30 Lars Gullik Bjønnes + + * acconfig.h: add entry for HAVE_DECL_ISTREAMBUF_ITERATOR + + * configure.in: check for istreambuf_iterator in + 2001-05-16 Ruurd Reitsma * Added README.Win32 diff --git a/acconfig.h b/acconfig.h index dd219f8bee..b7318d8d0e 100644 --- a/acconfig.h +++ b/acconfig.h @@ -53,6 +53,10 @@ /* Define if you have the function prototype for vsnprintf(). */ #undef HAVE_DECL_VSNPRINTF +/* Define if you have the function prototype istreambuf_iterator in + */ +#undef HAVE_DECL_ISTREAMBUF_ITERATOR + @BOTTOM@ /************************************************************ diff --git a/configure.in b/configure.in index efaee32653..126986da57 100644 --- a/configure.in +++ b/configure.in @@ -272,6 +272,7 @@ fi AC_CHECK_FUNCS(snprintf vsnprintf) LYX_CHECK_DECL(snprintf, stdio.h) LYX_CHECK_DECL(vsnprintf, stdio.h) +LYX_CHECK_DECL(istreambuf_iterator, iterator) AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo \ mkstemp mktemp) diff --git a/src/ChangeLog b/src/ChangeLog index 52075200b9..ef0f770df8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-05-30 Lars Gullik Bjønnes + + * text2.C (CutSelection): make the cursor valid before the call to + ClearSelection. + 2001-05-29 Jean-Marc Lasgouttes * kbsequence.C (parse): de-uglify a bit the parsing code, which diff --git a/src/support/ChangeLog b/src/support/ChangeLog index a94949fb44..10a495ef31 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2001-05-30 Lars Gullik Bjønnes + + * lyxsum.C (sum): use istreambuf_iterator when available. + 2001-05-29 Lars Gullik Bjønnes * lyxsum.C (sum): don't use sstream anymore, use istream_iterator diff --git a/src/support/lyxsum.C b/src/support/lyxsum.C index 0f8304d11d..ee8dbbbff9 100644 --- a/src/support/lyxsum.C +++ b/src/support/lyxsum.C @@ -20,10 +20,6 @@ #include "support/lyxlib.h" -using std::ifstream; -using std::ios; -using std::istream_iterator; - namespace { // DO _NOT_ CHANGE _ANYTHING_ IN THIS TABLE @@ -111,10 +107,18 @@ unsigned long do_crc(InputIterator first, InputIterator last) // And this would be the file interface. unsigned long lyx::sum(string const & file) { - ifstream ifs(file.c_str()); +#ifdef HAVE_DECL_ISTREAMBUF_ITERATOR + std::ifstream ifs(file.c_str()); if (!ifs) return 0; - ifs.unsetf(ios::skipws); - istream_iterator beg(ifs); - istream_iterator end; + std::istreambuf_iterator beg(ifs); + std::istreambuf_iterator end; return do_crc(beg, end); +#else + std::ifstream ifs(file.c_str()); + if (!ifs) return 0; + ifs.unsetf(std::ios::skipws); + std::istream_iterator beg(ifs); + std::istream_iterator end; + return do_crc(beg, end); +#endif } diff --git a/src/text2.C b/src/text2.C index 84157b6d92..8587e831cb 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1684,7 +1684,7 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) // more than one paragraph if (sel_start_cursor.par() == sel_end_cursor.par()) { // only within one paragraph - endpar = sel_start_cursor.par(); + endpar = sel_end_cursor.par(); int pos = sel_end_cursor.pos(); cap.cutSelection(sel_start_cursor.par(), &endpar, sel_start_cursor.pos(), pos, @@ -1692,7 +1692,6 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) sel_end_cursor.pos(pos); } else { endpar = sel_end_cursor.par(); - int pos = sel_end_cursor.pos(); cap.cutSelection(sel_start_cursor.par(), &endpar, sel_start_cursor.pos(), pos, @@ -1709,9 +1708,14 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) sel_start_cursor.par()->StripLeadingSpaces(bview->buffer()->params.textclass); RedoParagraphs(bview, sel_start_cursor, endpar); - - ClearSelection(bview); + + // cutSelection can invalidate the cursor so we need to set + // it anew. (Lgb) cursor = sel_start_cursor; + + // need a valid cursor. (Lgb) + ClearSelection(bview); + SetCursor(bview, cursor.par(), cursor.pos()); sel_cursor = cursor; UpdateCounters(bview, cursor.row()); @@ -2197,7 +2201,8 @@ void LyXText::SetCurrentFont(BufferView * bview) const if (pos > 0) { if (pos == cursor.par()->size()) --pos; - else if (cursor.par()->IsSeparator(pos)) { + else // potentional bug... BUG (Lgb) + if (cursor.par()->IsSeparator(pos)) { if (pos > cursor.row()->pos() && bidi_level(pos) % 2 == bidi_level(pos - 1) % 2)