summaryrefslogtreecommitdiffstats
path: root/main.cxx
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2010-03-11 19:19:33 -0800
committerJosh Stone <jistone@redhat.com>2010-03-11 19:19:33 -0800
commit60d985370e63cb3b4c68489fc54276d8ac2b921b (patch)
tree2731ffe47f8e619b6fabcacf451275d49a3486fd /main.cxx
parent0da46fcdec144f944838350f08f59a36b8709e90 (diff)
downloadsystemtap-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 'main.cxx')
-rw-r--r--main.cxx11
1 files changed, 4 insertions, 7 deletions
diff --git a/main.cxx b/main.cxx
index 9cc0370d..93fd6bfe 100644
--- a/main.cxx
+++ b/main.cxx
@@ -436,7 +436,7 @@ int parse_kernel_config (systemtap_session &s)
string line;
while (getline (kcf, line))
{
- if (line.substr(0, 7) != "CONFIG_") continue;
+ if (!startswith(line, "CONFIG_")) continue;
size_t off = line.find('=');
if (off == string::npos) continue;
string key = line.substr(0, off);
@@ -750,20 +750,17 @@ main (int argc, char * const argv [])
save_module = true;
// XXX: convert to assert_regexp_match()
{
- string::size_type len = s.module_name.length();
-
// If the module name ends with '.ko', chop it off since
// modutils doesn't like modules named 'foo.ko.ko'.
- if (len > 3 && s.module_name.substr(len - 3, 3) == ".ko")
+ if (endswith(s.module_name, ".ko"))
{
- s.module_name.erase(len - 3);
- len -= 3;
+ s.module_name.erase(s.module_name.size() - 3);
cerr << "Truncating module name to '" << s.module_name
<< "'" << endl;
}
// Make sure an empty module name wasn't specified (-m "")
- if (len == 0)
+ if (s.module_name.empty())
{
cerr << "Module name cannot be empty." << endl;
exit(1);