diff options
author | Josh Stone <jistone@redhat.com> | 2010-03-11 19:19:33 -0800 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2010-03-11 19:19:33 -0800 |
commit | 60d985370e63cb3b4c68489fc54276d8ac2b921b (patch) | |
tree | 2731ffe47f8e619b6fabcacf451275d49a3486fd /parse.cxx | |
parent | 0da46fcdec144f944838350f08f59a36b8709e90 (diff) | |
download | systemtap-steved-60d985370e63cb3b4c68489fc54276d8ac2b921b.tar.gz systemtap-steved-60d985370e63cb3b4c68489fc54276d8ac2b921b.tar.xz systemtap-steved-60d985370e63cb3b4c68489fc54276d8ac2b921b.zip |
Add startswith/endswith helpers
Inspired by the Python equivalents, these new utility functions just
make it a little cleaner to match at the beginning or end of a string.
Diffstat (limited to 'parse.cxx')
-rw-r--r-- | parse.cxx | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -274,7 +274,7 @@ bool eval_pp_conditional (systemtap_session& s, return result; } - else if (l->type == tok_identifier && l->content.substr(0,7) == "CONFIG_") + else if (l->type == tok_identifier && startswith(l->content, "CONFIG_")) { if (r->type == tok_string) { @@ -306,7 +306,7 @@ bool eval_pp_conditional (systemtap_session& s, return eval_comparison (lhs, op, rhs); } else if (r->type == tok_identifier - && r->content.substr(0,7) == "CONFIG_") + && startswith(r->content, "CONFIG_")) { // First try to convert both to numbers, // otherwise threat both as strings. @@ -2679,9 +2679,9 @@ target_symbol* parser::parse_target_symbol (const token* t) expect_unknown(tok_string, cop->type); // types never start with "struct<space>" or "union<space>", // so gobble it up. - if (cop->type.compare(0, 7, "struct ") == 0) + if (startswith(cop->type, "struct ")) cop->type = cop->type.substr(7); - if (cop->type.compare(0, 6, "union ") == 0) + if (startswith(cop->type, "union ")) cop->type = cop->type.substr(6); if (peek_op (",")) { |