diff options
-rw-r--r-- | 014literal_string.cc | 2 | ||||
-rw-r--r-- | 016dilated_reagent.cc | 2 | ||||
-rw-r--r-- | 017parse_tree.cc | 3 | ||||
-rw-r--r-- | 035lookup.cc | 2 | ||||
-rw-r--r-- | 041jump_target.cc | 4 | ||||
-rw-r--r-- | 050scenario.cc | 2 | ||||
-rw-r--r-- | 055shape_shifting_container.cc | 4 |
7 files changed, 9 insertions, 10 deletions
diff --git a/014literal_string.cc b/014literal_string.cc index bd412ad4..768ccef3 100644 --- a/014literal_string.cc +++ b/014literal_string.cc @@ -105,7 +105,7 @@ void slurp_quoted_comment_aware(istream& in, ostream& out) { } :(after "Parsing reagent(string s)") -if (s.at(0) == '[') { +if (starts_with(s, "[")) { if (*s.rbegin() != ']') return; // unbalanced bracket; handled elsewhere name = s; // delete [] delimiters diff --git a/016dilated_reagent.cc b/016dilated_reagent.cc index fe990c6d..b7c8ecc4 100644 --- a/016dilated_reagent.cc +++ b/016dilated_reagent.cc @@ -92,7 +92,7 @@ string slurp_balanced_bracket(istream& in) { } :(after "Parsing reagent(string s)") -if (s.at(0) == '{') { +if (starts_with(s, "{")) { assert(properties.empty()); istringstream in(s); in >> std::noskipws; diff --git a/017parse_tree.cc b/017parse_tree.cc index 83a96d6b..c7e7473b 100644 --- a/017parse_tree.cc +++ b/017parse_tree.cc @@ -26,8 +26,7 @@ type_names = parse_string_tree(type_names); :(code) string_tree* parse_string_tree(string_tree* s) { assert(s->atom); - assert(!s->value.empty()); - if (s->value.at(0) != '(') return s; + if (!starts_with(s->value, "(")) return s; string_tree* result = parse_string_tree(s->value); delete s; return result; diff --git a/035lookup.cc b/035lookup.cc index 7dbf301b..fb5add8c 100644 --- a/035lookup.cc +++ b/035lookup.cc @@ -479,7 +479,7 @@ def main [ :(before "End Parsing reagent") { - while (!name.empty() && name.at(0) == '*') { + while (starts_with(name, "*")) { name.erase(0, 1); properties.push_back(pair<string, string_tree*>("lookup", NULL)); } diff --git a/041jump_target.cc b/041jump_target.cc index 8ccd5625..4d09d897 100644 --- a/041jump_target.cc +++ b/041jump_target.cc @@ -26,7 +26,7 @@ void transform_labels(const recipe_ordinal r) { map<string, int> offset; for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { const instruction& inst = get(Recipe, r).steps.at(i); - if (!inst.label.empty() && inst.label.at(0) == '+') { + if (starts_with(inst.label, "+")) { if (!contains_key(offset, inst.label)) { put(offset, inst.label, i); } @@ -88,7 +88,7 @@ void replace_offset(reagent& x, /*const*/ map<string, int>& offset, const int cu } bool is_jump_target(string label) { - return label.at(0) == '+'; + return starts_with(label, "+"); } :(scenario break_to_label) diff --git a/050scenario.cc b/050scenario.cc index 3c033c94..ac60af3e 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -84,7 +84,7 @@ scenario parse_scenario(istream& in) { // inside comments result.to_run = slurp_quoted(in); // delete [] delimiters - assert(result.to_run.at(0) == '['); + assert(starts_with(result.to_run, "[")); result.to_run.erase(0, 1); assert(result.to_run.at(SIZE(result.to_run)-1) == ']'); result.to_run.erase(SIZE(result.to_run)-1); diff --git a/055shape_shifting_container.cc b/055shape_shifting_container.cc index 596c691e..ef165c91 100644 --- a/055shape_shifting_container.cc +++ b/055shape_shifting_container.cc @@ -162,7 +162,7 @@ bool slurp_type_ingredients(istream& in, map<string, type_ordinal>& out, const s raise << container_name << ": empty type ingredients not permitted\n" << end(); return false; } - if (curr.at(0) != '_') { + if (!starts_with(curr, "_")) { raise << container_name << ": type ingredient '" << curr << "' must begin with an underscore\n" << end(); return false; } @@ -191,7 +191,7 @@ else if (is_type_ingredient_name(type->name)) { } :(code) bool is_type_ingredient_name(const string& type) { - return !type.empty() && type.at(0) == '_'; + return starts_with(type, "_"); } :(before "End Container Type Checks") |