about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-24 19:55:48 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-24 19:55:48 -0700
commitae08e30e8d57a1f1bbc0ba8a346a0aa6bcb512e9 (patch)
tree42500debf1840bb90a729a6173a1a026ce3ebede
parent2821a0a3cb126d406840659dcfc8f53302353012 (diff)
downloadmu-ae08e30e8d57a1f1bbc0ba8a346a0aa6bcb512e9.tar.gz
3413
-rw-r--r--001help.cc5
-rw-r--r--071recipe.cc2
-rw-r--r--cleave/cleave.cc7
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)) {