aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--files.c9
-rw-r--r--files.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/files.c b/files.c
index 22eaed1..0231f21 100644
--- a/files.c
+++ b/files.c
@@ -198,6 +198,15 @@ size_t get_line_number(file_t *f, const char *p)
}
//
+// Given a pointer, determine which line column it points to.
+//
+size_t get_line_column(file_t *f, const char *p)
+{
+ size_t line_no = get_line_number(f, p);
+ return 1 + (size_t)(p - f->lines[line_no]);
+}
+
+//
// Return a pointer to the line with the specified line number.
//
const char *get_line(file_t *f, size_t line_number)
diff --git a/files.h b/files.h
index b32d5a4..358fcd8 100644
--- a/files.h
+++ b/files.h
@@ -28,6 +28,8 @@ void destroy_file(file_t **f);
__attribute__((pure, nonnull))
size_t get_line_number(file_t *f, const char *p);
__attribute__((pure, nonnull))
+size_t get_line_column(file_t *f, const char *p);
+__attribute__((pure, nonnull))
const char *get_line(file_t *f, size_t line_number);
#endif