The unified diff between revisions [26a8efec..] and [ce0814c2..] is displayed below. It can also be downloaded as a raw diff.

#
#
# patch "fritz_client.cc"
#  from [32f5a861967389df5fd44e1b873ded5c91444ea9]
#    to [5a19388592a6fefece9663737ce32aa46f1acaff]
#
# patch "markov.cc"
#  from [2647ebc76e7792aed12fe85222b1bfcd9c79f9c2]
#    to [e7dfbe6680e668c1a4cc69fd79c3297d54b92f21]
#
# patch "markov.hh"
#  from [2e96c24eebd5a1986a15786fe0a9a32662a7db94]
#    to [02d5398997e1afc2d1546f8a9ab1485ac1287a51]
#
# patch "tokens_test.cc"
#  from [23b40a5e896510592ccca8d829fa8203845c73d2]
#    to [751e06194da82617853d13dac3839bfcb365eff1]
#
============================================================
--- fritz_client.cc	32f5a861967389df5fd44e1b873ded5c91444ea9
+++ fritz_client.cc	5a19388592a6fefece9663737ce32aa46f1acaff
@@ -22,6 +22,21 @@

 #include "fritz.hh"

+class ErrnoGuard {
+
+public:
+    int __errno;
+
+    ErrnoGuard() {
+        __errno = errno;
+    };
+
+    ~ErrnoGuard() {
+        errno = __errno;
+    };
+
+};
+
 static FritzClient client;

 typedef ssize_t ((*read_syscall)(int, void*, size_t));
@@ -42,6 +57,7 @@ read (int d, void *buf, size_t nbytes)
         real_read = reinterpret_cast<read_syscall> (client.grab_symbol_from ("FRITZ_LIBC", "read"));
     }
     rlen = (real_read) (d, buf, nbytes);
+    ErrnoGuard e;
     client.copy_data (rlen, buf);
     client.pass_to_server ();
     rlen = client.copy_back (nbytes, buf);
============================================================
--- markov.cc	2647ebc76e7792aed12fe85222b1bfcd9c79f9c2
+++ markov.cc	e7dfbe6680e668c1a4cc69fd79c3297d54b92f21
@@ -14,6 +14,7 @@ MarkovState::MarkovState (const deque<to
 MarkovState::MarkovState (const deque<token_t> &q)
 {
     state = q;
+    valid = true;
 }

 MarkovState::~MarkovState ()
@@ -21,6 +22,19 @@ MarkovState::~MarkovState ()

 }

+void
+MarkovState::vdump () const
+{
+    if (!valid)
+        cout << " <invalid> ";
+
+    cout << "[ ";
+    for (deque<token_t>::const_iterator i=state.begin();i!=state.end();i++) {
+        cout << *i << " ";
+    }
+    cout << "]";
+}
+
 bool
 MarkovState::operator==(const MarkovState &s)
 {
@@ -61,6 +75,20 @@ MarkovModel::MarkovModel (const Stash &s
     }
 }

+void
+MarkovModel::Dump ()
+{
+    for (map<markov_pair, int>::const_iterator i=edges.begin(); i!=edges.end(); i++) {
+//        cout << (*i).first.vdump() << " -> " << (*i).second.vdump() << endl;
+        const markov_pair &p=(*i).first;
+        token_t score=(*i).second;
+        p.first.vdump();
+        cout << " :: ";
+        p.second.vdump();
+        cout << " == " << score << endl;
+    }
+}
+
 MarkovModel::~MarkovModel ()
 {

============================================================
--- markov.hh	2e96c24eebd5a1986a15786fe0a9a32662a7db94
+++ markov.hh	02d5398997e1afc2d1546f8a9ab1485ac1287a51
@@ -14,6 +14,7 @@ public:
     MarkovState ();
     MarkovState (const std::deque<token_t> &);
     ~MarkovState ();
+    void vdump () const;
     bool operator==(const MarkovState &);
     bool operator!=(const MarkovState &);
     bool operator<(const MarkovState &);
@@ -89,6 +90,7 @@ public:
 public:
     MarkovModel (const Stash&, int);
     ~MarkovModel ();
+    void Dump();
 };

 #endif
============================================================
--- tokens_test.cc	23b40a5e896510592ccca8d829fa8203845c73d2
+++ tokens_test.cc	751e06194da82617853d13dac3839bfcb365eff1
@@ -38,6 +38,7 @@ test (void)
     t.playback ();

     MarkovModel m(t, 2);
+    m.Dump();
 }

 int