Skip to content

Commit 1e4885e

Browse files
committedJun 12, 2017
Grmbl
1 parent 36f363b commit 1e4885e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎src/libutil/util.cc

+6
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,12 @@ bool statusOk(int status)
11711171
}
11721172

11731173

1174+
bool hasPrefix(const string & s, const string & suffix)
1175+
{
1176+
return s.compare(0, suffix.size(), suffix) == 0;
1177+
}
1178+
1179+
11741180
bool hasSuffix(const string & s, const string & suffix)
11751181
{
11761182
return s.size() >= suffix.size() && string(s, s.size() - suffix.size()) == suffix;

‎src/libutil/util.hh

+4
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ template<class N> bool string2Int(const string & s, N & n)
365365
}
366366

367367

368+
/* Return true iff `s' starts with `prefix'. */
369+
bool hasPrefix(const string & s, const string & prefix);
370+
371+
368372
/* Return true iff `s' ends in `suffix'. */
369373
bool hasSuffix(const string & s, const string & suffix);
370374

0 commit comments

Comments
 (0)
Please sign in to comment.