aboutsummaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/common.h b/src/common.h
index 7f2dfc9..10c01e2 100644
--- a/src/common.h
+++ b/src/common.h
@@ -5,6 +5,8 @@
#include <string.h>
#include <utility>
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
+
struct line_view {
const char* line;
size_t length;
@@ -32,15 +34,14 @@ struct line_view {
bool contains(const char* s) {
size_t len = strlen(s);
const char* p = line;
- while (p + len < line + length) {
+ while (p + len <= line + length) {
if (*p == *s) {
line_view x{p, len};
if (x == s) {
return true;
- } else {
- p++;
}
}
+ p++;
}
return false;
}