common NEW function for counting newlines
diff --git a/src/common.c b/src/common.c
index 0f55e32..5cd0a90 100644
--- a/src/common.c
+++ b/src/common.c
@@ -77,3 +77,17 @@
     LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_INVAL, date_len, date, stmt);
     return -1;
 }
+
+int
+lysp_get_data_line(const char *data, int fail_char)
+{
+    int i, line = 1;
+
+    for (i = 0; i < fail_char; ++i) {
+        if (data[i] == '\n') {
+            ++line;
+        }
+    }
+
+    return line;
+}