diff options
-rw-r--r-- | 001help.cc | 5 | ||||
-rw-r--r-- | 071recipe.cc | 2 | ||||
-rw-r--r-- | cleave/cleave.cc | 7 |
3 files changed, 10 insertions, 4 deletions
diff --git a/001help.cc b/001help.cc index 8a092ffa..0f5147e8 100644 --- a/001help.cc +++ b/001help.cc @@ -66,7 +66,10 @@ bool is_equal(char* s, const char* lit) { } 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(); } //: I'll throw some style conventions here for want of a better place for them. diff --git a/071recipe.cc b/071recipe.cc index f79b9461..6be95c4b 100644 --- a/071recipe.cc +++ b/071recipe.cc @@ -199,7 +199,7 @@ recipe from_reagent(const reagent& r) { return result_header; // no products } read_products: - for (/*nada*/; curr && !curr->atom; curr=curr->right) + for (/*nada*/; curr && !curr->atom; curr = curr->right) result_header.products.push_back(next_recipe_reagent(curr->left)); if (curr) { assert(curr->atom); 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)) { |