DEADSOFTWARE

Solve oldType path lookup, found SEGFAULT
authorGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Tue, 9 Aug 2011 07:48:25 +0000 (08:48 +0100)
committerGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Tue, 9 Aug 2011 07:48:25 +0000 (08:48 +0100)
odcread.cc
reader.cc

index 32fcd6b25471d2b368f16e05c10cf00105f0a77c..a6765e913ab97614b3ceb0d877ca21e0b6a1d1fd 100644 (file)
@@ -25,6 +25,9 @@ namespace odc {
 }
 
 int main(int argc, char *argv[]) {
+       if (argc < 2) {
+               return 1;
+       }
        std::ifstream in(argv[1], std::ios::in | std::ios::binary);
        odc::Store* s = odc::importDocument(in);
        std::cout << s->toString() << std::endl;
index 46a0b812e7334485a6d22b1add42c62b4eca787a..581917197f2c9bdbcbcbd3e6dc130193784e1263 100644 (file)
--- a/reader.cc
+++ b/reader.cc
@@ -35,14 +35,19 @@ void Reader::readSString(SHORTCHAR *out) {
 Store* Reader::readStore() {
        SHORTCHAR kind = readSChar();
        if (kind == Store::NIL) {
+               std::cout << "NIL STORE" << std::endl;
                return readNilStore();
        } else if (kind == Store::LINK) {
+               std::cout << "LINK STORE" << std::endl;
                return readLinkStore();
        } else if (kind == Store::NEWLINK) {
+               std::cout << "NEWLINK STORE" << std::endl;
                return readNewLinkStore();
        } else if (kind == Store::STORE) {
+               std::cout << "STORE STORE" << std::endl;
                return readStoreOrElemStore(false);
        } else if (kind == Store::ELEM) {
+               std::cout << "ELEM STORE" << std::endl;
                return readStoreOrElemStore(true);
        } else {
                throw 20;
@@ -236,6 +241,7 @@ void Reader::readPath(SHORTCHAR **path) {
        SHORTCHAR kind = readSChar();
        int i;
        for (i = 0; kind == Store::NEWEXT; ++i) {
+               std::cout << i << std::endl;
                readSString(path[i]);
                addPathComponent(i == 0, path[i]);
 //                     IF path[i] # elemTName THEN INC(i) END;
@@ -243,12 +249,19 @@ void Reader::readPath(SHORTCHAR **path) {
        }
 
        if (kind == Store::NEWBASE) {
+               std::cout << i << std::endl;
                readSString(path[i]);
                addPathComponent(i == 0, path[i]);
                ++i;
        } else if (kind == Store::OLDTYPE) {
                int id = readInt();
                d_typeList[d_typeList.size() - 1]->baseId = id;
+               while (id != -1) {
+                       std::cout << "old " << i << "id " << id << d_typeList[id]->name << std::endl;
+                       path[i] = d_typeList[id]->name;
+                       id = d_typeList[id]->baseId;
+                       ++i;
+               }
 //                     REPEAT
 //                             GetThisType(rd.tDict, id, path[i]); id := ThisBaseId(rd.tDict, id);
 //                             IF path[i] # elemTName THEN INC(i) END
@@ -256,6 +269,7 @@ void Reader::readPath(SHORTCHAR **path) {
        } else {
                throw 100;
        }
+       std::cout << "term " << i << std::endl;
        path[i] = 0;
 }
 //     PROCEDURE ReadPath (VAR rd: Reader; VAR path: TypePath);