Add space directly
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 12 Nov 2016 06:09:17 +0000 (22:09 -0800)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 12 Nov 2016 06:09:17 +0000 (22:09 -0800)
markov.cpp

index 8d5929d..cc860f4 100644 (file)
@@ -39,9 +39,10 @@ extern "C" {
         auto it = kv.begin();
         while (it != kv.end() && chosen > 0) chosen -= (it++)->second;
 
-        if (it == kv.end() || it->first.length() >= maximum) return -1;
+        if (it == kv.end() || it->first.length() + 1 >= maximum) return -1;
 
-        strcpy(out, it->first.c_str());
-        return it->first.length();
+        out[0] = ' ';
+        strcpy(out + 1, it->first.c_str());
+        return it->first.length() + 1;
     }
 }
This page took 0.022939 seconds and 4 git commands to generate.