DEADSOFTWARE

Dump TextModel ShortChar contents to std::cout (appear a little out of order)
authorGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Wed, 17 Aug 2011 18:00:42 +0000 (20:00 +0200)
committerGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Wed, 17 Aug 2011 18:00:42 +0000 (20:00 +0200)
convert.c [new file with mode: 0644]
odcread.cc
reader.cc
textmodel.cc

diff --git a/convert.c b/convert.c
new file mode 100644 (file)
index 0000000..5c00661
--- /dev/null
+++ b/convert.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+       int c;
+       while ((c = getchar()) != EOF) {
+               if (c == '\r') {
+                       putchar('\n');
+               } else {
+                       putchar(c);
+               }
+       }
+}
index c843713451fae3916191777dd283528713841fa7..27117ddeab85d2240d89bd82ce6a3c82d6ae7577 100644 (file)
@@ -30,11 +30,11 @@ int main(int argc, char *argv[]) {
        }
        std::ifstream in(argv[1], std::ios::in | std::ios::binary);
        odc::Store* s = odc::importDocument(in);
-       std::cout << s->toString() << std::endl;
-       std::cout << in.tellg() << " " << in.eof() << std::endl;
+       //std::cout << s->toString() << std::endl;
+       //std::cout << in.tellg() << " " << in.eof() << std::endl;
 
        odc::TypePath path;
        odc::ContainerModel(0).getTypePath(&path);
-       std::cout << path.toString() << std::endl;
+       //std::cout << path.toString() << std::endl;
        return 0;
 }
index f53e30a8e896035d8a769d2de4cf10b27c9e8d33..587c391857cfb84416a953199cf6a0945c311c6e 100644 (file)
--- a/reader.cc
+++ b/reader.cc
@@ -95,22 +95,22 @@ INTEGER Reader::readVersion(INTEGER min, INTEGER max) {
 Store* Reader::readStore() {
        SHORTCHAR kind = readSChar();
        if (kind == Store::NIL) {
-               std::cout << "NIL STORE" << std::endl;
+               //std::cout << "NIL STORE" << std::endl;
                return readNilStore();
        } else if (kind == Store::LINK) {
-               std::cout << "LINK STORE" << std::endl;
+               //std::cout << "LINK STORE" << std::endl;
                return readLinkStore();
        } else if (kind == Store::NEWLINK) {
-               std::cout << "NEWLINK STORE" << std::endl;
+               //std::cout << "NEWLINK STORE" << std::endl;
                return readNewLinkStore();
        } else if (kind == Store::STORE) {
-               std::cout << "STORE STORE" << std::endl;
+               //std::cout << "STORE STORE" << std::endl;
                return readStoreOrElemStore(false);
        } else if (kind == Store::ELEM) {
-               std::cout << "ELEM STORE" << std::endl;
+               //std::cout << "ELEM STORE" << std::endl;
                return readStoreOrElemStore(true);
        } else {
-               std::cout << std::hex << (unsigned int)kind << std::endl;
+               //std::cout << std::hex << (unsigned int)kind << std::endl;
                throw 20;
        }
 }
@@ -155,7 +155,7 @@ Store *Reader::readNewLinkStore() {
 Store *Reader::readStoreOrElemStore(bool isElem) {
        INTEGER id = isElem ? d_elemList.size() : d_storeList.size();
        TypePath path = readPath();
-       std::cout << path.toString() << std::endl;
+       //std::cout << path.toString() << std::endl;
        const std::string &type = path[0];
        INTEGER comment = readInt();
        std::streampos pos1 = d_rider.tellg();
@@ -218,7 +218,7 @@ Store *Reader::readStoreOrElemStore(bool isElem) {
                        d_store = x;
                } else {
                        // join(d_store, x)
-                       std::cout << "Man, should have written join(.,.)" << std::endl;
+                       //std::cout << "Man, should have written join(.,.)" << std::endl;
                }
                if (isElem) {
                        d_elemList.push_back(x);
@@ -233,7 +233,7 @@ Store *Reader::readStoreOrElemStore(bool isElem) {
                        d_store = alien;
                } else {
                        // join(d_store, alien)
-                       std::cout << "Man, should have written join(.,.)" << std::endl;
+                       //std::cout << "Man, should have written join(.,.)" << std::endl;
                }
                if (isElem) {
                        d_elemList.push_back(alien);
@@ -262,14 +262,14 @@ void Reader::internalizeAlien(Alien *alien, std::streampos down, std::streampos
        std::streampos next = down != 0 ? down : end;
        while (d_rider.tellg() < end) {
                if (d_rider.tellg() < next) { // for some reason, this means its a piece (unstructured)
-                       std::cout << "Alien Piece" << std::endl;
+                       //std::cout << "Alien Piece" << std::endl;
                        size_t len = next - d_rider.tellg();
                        char *buf = new char[len];
                        d_rider.read(buf, len);
                        AlienComponent *comp = new AlienPiece(buf, len);
                        alien->getComponents().push_back(comp);
                } else { // that means we've got a store
-                       std::cout << "Alien Store" << std::endl;
+                       //std::cout << "Alien Store" << std::endl;
                        d_rider.seekg(next);
                        AlienComponent *comp = new AlienPart(readStore());
                        alien->getComponents().push_back(comp);
index 2028c2e5621c2c733f0254728740272d0b896f36..281042002423e99527fa8677237c2f6034d93ff0 100644 (file)
@@ -65,7 +65,7 @@ void StdTextModel::internalize(Reader &reader) {
        std::vector<Store *> dict;
        INTEGER len = reader.readInt();
        BYTE ano = reader.readByte();
-       std::cout << "len " << len << " ano " << (int)ano << std::endl;
+       //std::cout << "len " << len << " ano " << (int)ano << std::endl;
        int skip = 0;
        while (ano != -1) {
                if (ano == dict.size()) {
@@ -74,13 +74,13 @@ void StdTextModel::internalize(Reader &reader) {
                }
                INTEGER pieceLen = reader.readInt();
                if (pieceLen > 0) { // shortchar piece
-                       std::cout << "Found SChar piece" << std::endl;
+                       //std::cout << "Found SChar piece" << std::endl;
                        d_pieces.push_back(new ShortPiece(pieceLen));
 //                             NEW(sp); sp.len := len; sp.attr := attr;
 //                             sp.file := rd.rider.Base(); sp.org := org; un := sp;
 //                             INC(org, len) -- increment org by len ?
                } else if (pieceLen < 0) { // longchar piece
-                       std::cout << "Found LChar piece" << std::endl;
+                       //std::cout << "Found LChar piece" << std::endl;
                        assert(pieceLen % 2 == 0);
                        d_pieces.push_back(new LongPiece(pieceLen / 2));
 //                             len := -len; ASSERT(~ODD(len), 100);
@@ -88,7 +88,7 @@ void StdTextModel::internalize(Reader &reader) {
 //                             lp.file := rd.rider.Base(); lp.org := org; un := lp;
 //                             INC(org, len) -- increment org by len ?
                } else { // embedded view
-                       std::cout << "Found View piece" << std::endl;
+                       //std::cout << "Found View piece" << std::endl;
                        reader.readInt(); reader.readInt();
                        Store *view = reader.readStore(); // fixme: save somewhere
 //                             NEW(v); v.len := 1; v.attr := attr;
@@ -178,6 +178,7 @@ void ShortPiece::read(Reader &reader) {
        SHORTCHAR *buf = new SHORTCHAR[d_len + 1];
        reader.readSChar(buf, d_len);
        buf[d_len] = 0;
+       std::cout.write(buf, d_len);
 //     std::ofstream ofs(piece, std::ios::out);
 //     ofs.write(buf, d_len);
 //     ofs.close();