]> git.lyx.org Git - features.git/commitdiff
prevent tex2lyx segfault
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 27 Nov 2004 13:42:14 +0000 (13:42 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 27 Nov 2004 13:42:14 +0000 (13:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9318 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/ChangeLog
src/tex2lyx/table.C

index a064eed91d52363b46a40ca155816f5f35ad345f..0c8c2b3f60267dfc212d179df15a1889e89697a4 100644 (file)
@@ -1,3 +1,9 @@
+2004-11-27  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * table.C (handle_colalign): handle comments
+       * table.C (handle_tabular): don't crash on clines with out of range
+       columns
+
 2004-11-09  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * tex2lyx.C: remove format hack
index 2e51d50fb8031960ff66f56f151ac30057179967..6f607f257b0ad5613c76dfd391ecac9948c95da7 100644 (file)
@@ -100,6 +100,16 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo)
                cerr << "t: " << t << "  c: '" << t.character() << "'\n";
 #endif
 
+               // We cannot handle comments here
+               if (t.cat() == catComment) {
+                       if (t.cs().empty()) {
+                               // "%\n" combination
+                               p.skip_spaces();
+                       } else
+                               cerr << "Ignoring comment: " << t.asInput();
+                       continue;
+               }
+
                switch (t.character()) {
                        case 'c':
                        case 'l':
@@ -379,7 +389,19 @@ void handle_tabular(Parser & p, ostream & os,
                                        split(arg, t, '-');
                                        t.resize(2);
                                        size_t from = string2int(t[0]) - 1;
+                                       if (from >= colinfo.size()) {
+                                               cerr << "cline starts at non "
+                                                       "existing column "
+                                                    << from << endl;
+                                               from = colinfo.size() - 1;
+                                       }
                                        size_t to = string2int(t[1]);
+                                       if (to >= colinfo.size()) {
+                                               cerr << "cline ends at non "
+                                                       "existing column "
+                                                    << to << endl;
+                                               to = colinfo.size() - 1;
+                                       }
                                        for (size_t col = from; col < to; ++col) {
                                                //cerr << "row: " << row << " col: " << col << " i: " << i << endl;
                                                if (i == 0) {