From d9c0aa81954969f65c72b0b229d08a3548d4e5b1 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 19 Nov 1999 14:50:33 +0000 Subject: [PATCH] Fix assertion when inserting text strings via clipboard or ascii file; small dependency tweak in src/Makefile.am git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@327 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 9 +++++++++ src/Makefile.am | 5 ++--- src/text2.C | 31 +++++++++++++++++-------------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1d0d27df4..c7e7d744ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +1999-11-19 Jean-Marc Lasgouttes + + * src/Makefile.am (lyx_DEPENDENCIES): give the explicit object + file name in insets and mathed directories (otherwise the + dependency is not taken in account under cygwin). + + * src/text2.C (InsertString[AB]): make sure that we do not try to + read characters past the string length. + 1999-11-18 Jean-Marc Lasgouttes * lib/doc/LaTeXConfig.lyx.in, diff --git a/src/Makefile.am b/src/Makefile.am index 38b95732f6..b44c9a7f09 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,9 +3,8 @@ SUBDIRS = mathed insets support DISTCLEANFILES = libintl.h config.h MAINTAINERCLEANFILES = Makefile.in config.h.in bin_PROGRAMS = lyx -lyx_LDADD = mathed/mathed.o insets/insets.o support/libsupport.a \ - @INTLLIBS@ $(LYX_LIBS) -lyx_DEPENDENCIES = mathed insets support/libsupport.a +lyx_DEPENDENCIES = mathed/mathed.o insets/insets.o support/libsupport.a +lyx_LDADD = $(lyx_DEPENDENCIES) @INTLLIBS@ $(LYX_LIBS) EXTRA_DIST = config.h.in stamp-h.in cheaders ETAGS_ARGS = --c++ LYX_DIR = $(datadir)/$(PACKAGE) diff --git a/src/text2.C b/src/text2.C index f284ddabe0..e58089b7b9 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2433,8 +2433,9 @@ void LyXText::InsertStringA(LyXParagraph::TextContainer const & text) /* needed to insert the selection */ -void LyXText::InsertStringA(char const * str) +void LyXText::InsertStringA(char const * s) { + string str(s); LyXParagraph * par = cursor.par; LyXParagraph::size_type pos = cursor.pos; LyXParagraph::size_type a = 0; @@ -2449,10 +2450,11 @@ void LyXText::InsertStringA(char const * str) ClearSelection(); /* insert the string, don't insert doublespace */ - int i = 0; - while (str[i]) { - if (str[i]!= '\n') { - if (str[i] == ' ' && (str[i+1]!= ' ') + string::size_type i = 0; + while (i < str.length()) { + if (str[i] != '\n') { + if (str[i] == ' ' + && i+1GetChar(pos-1)!= ' ') { par->InsertChar(pos,' '); pos++; @@ -2490,7 +2492,7 @@ void LyXText::InsertStringA(char const * str) } } else { if (par->table) { - if (!str[i+1]) { + if (i+1>=str.length()) { pos++; break; } @@ -2550,23 +2552,24 @@ void LyXText::InsertStringB(char const * s) { string str(s); LyXParagraph * par = cursor.par; - int i = 1; - while (str[i]) { + string::size_type i = 1; + while (i < str.length()) { if (str[i] == '\t' && !par->table) str[i] = ' '; - if (str[i] == ' ' && str[i + 1] == ' ') + if (str[i] == ' ' && i+1 < str.length() && str[i + 1] == ' ') str[i] = 13; - if (str[i] == '\n' && str[i + 1] && !par->table){ + if (str[i] == '\n' && i+1 < str.length() && !par->table){ if (str[i + 1] != '\n') { if (str[i - 1] != ' ') str[i] = ' '; else str[i] = 13; } - while (str[i + 1] && (str[i + 1] == ' ' - || str[i + 1] == '\t' - || str[i + 1] == '\n' - || str[i + 1] == 13)) { + while (i+1 < str.length() + && (str[i + 1] == ' ' + || str[i + 1] == '\t' + || str[i + 1] == '\n' + || str[i + 1] == 13)) { str[i + 1] = 13; ++i; } -- 2.39.5