From ae08e30e8d57a1f1bbc0ba8a346a0aa6bcb512e9 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 24 Sep 2016 19:55:48 -0700 Subject: 3413 --- cleave/cleave.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cleave') diff --git a/cleave/cleave.cc b/cleave/cleave.cc index 442b5fe6..a3637e81 100644 --- a/cleave/cleave.cc +++ b/cleave/cleave.cc @@ -88,14 +88,17 @@ string trim(const string& s) { } bool starts_with(const string& s, const string& pat) { - return s.substr(0, pat.size()) == pat; + string::const_iterator a=s.begin(), b=pat.begin(); + for (/*nada*/; a!=s.end() && b!=pat.end(); ++a, ++b) + if (*a != *b) return false; + return b == pat.end(); } bool has_data(istream& in) { return in && !in.eof(); } -void slurp(const string/*copy*/ filename, vector& lines) { +void slurp(const string& filename, vector& lines) { lines.clear(); ifstream in(filename.c_str()); while (has_data(in)) { -- cgit 1.4.1-2-gfad0