aboutsummaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/common.cpp b/src/common.cpp
index be45494..d608a22 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -19,6 +19,13 @@ line_view load_file(const char* path) {
return lv;
}
-line_view next_line(line_view file) {
- return {nullptr, 0};
+line_view next_line(line_view file, size_t* offset) {
+ const char* p1 = file.line + *offset;
+ const char* p2 = p1;
+ const char* end = file.line + file.length;
+ while (p2 < end && *p2 != '\n') {
+ p2++;
+ }
+ *offset = p2 - file.line + 1;
+ return {p1, static_cast<size_t>(p2 - p1 + 1)};
}