diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-24 19:55:48 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-24 19:55:48 -0700 |
commit | ae08e30e8d57a1f1bbc0ba8a346a0aa6bcb512e9 (patch) | |
tree | 42500debf1840bb90a729a6173a1a026ce3ebede /cleave | |
parent | 2821a0a3cb126d406840659dcfc8f53302353012 (diff) | |
download | mu-ae08e30e8d57a1f1bbc0ba8a346a0aa6bcb512e9.tar.gz |
3413
Diffstat (limited to 'cleave')
-rw-r--r-- | cleave/cleave.cc | 7 |
1 files changed, 5 insertions, 2 deletions
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<string>& lines) { +void slurp(const string& filename, vector<string>& lines) { lines.clear(); ifstream in(filename.c_str()); while (has_data(in)) { |