]> git.lyx.org Git - lyx.git/commitdiff
Fix assertion when inserting text strings via clipboard or ascii file; small
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 19 Nov 1999 14:50:33 +0000 (14:50 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 19 Nov 1999 14:50:33 +0000 (14:50 +0000)
dependency tweak in src/Makefile.am

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@327 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/Makefile.am
src/text2.C

index c1d0d27df498d21875c2821ac4e6103a94ae8157..c7e7d744ac1b9c337d5c91327b64a739327d4f68 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+1999-11-19  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * 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  <Jean-Marc.Lasgouttes@inria.fr>
 
        * lib/doc/LaTeXConfig.lyx.in, 
index 38b95732f6d255706b1d3202c7e16941b7895d7b..b44c9a7f09456c29f69bc0295f2d5f1c9c338c19 100644 (file)
@@ -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)
index f284ddabe0c620817f4664b70cb4fcec494c8c21..e58089b7b90944796b34f76cd28fca96c7bfb2f8 100644 (file)
@@ -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+1<str.length() && str[i+1]!= ' '
                            && pos && par->GetChar(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;
                        }