summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-03-12 16:24:46 +0000
committerCarl Hetherington <cth@carlh.net>2019-03-12 16:24:46 +0000
commit5038e68ad9eb66e007211c8f1b707612a0c01e29 (patch)
tree70d5aa5d3f414defc3d3cd0b34de0725bf8760a9 /src/util.cc
parenta8b629085c404d7a947ed242fbf64d8e0e91edcd (diff)
Remove sstream dependency.
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/util.cc b/src/util.cc
index 57f5e1c..70cbf10 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -18,7 +18,6 @@
*/
#include "util.h"
-#include <locked_sstream.h>
#include <string>
#include <iostream>
#include <cstdio>
@@ -43,15 +42,22 @@ sub::empty_or_white_space (string s)
}
optional<string>
-sub::get_line_stringstream (locked_stringstream* str)
+sub::get_line_string (string* s)
{
- if (!str->good ()) {
- return optional<string> ();
+ if (s->length() == 0) {
+ return optional<string>();
+ }
+
+ size_t pos = s->find ("\n");
+ if (pos == string::npos) {
+ string const c = *s;
+ *s = "";
+ return c;
}
- string s;
- getline (*str, s);
- return s;
+ string const c = s->substr (0, pos);
+ s->erase (0, pos + 1);
+ return c;
}
optional<string>