summaryrefslogtreecommitdiff
path: root/shared/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared/util.c')
-rw-r--r--shared/util.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/shared/util.c b/shared/util.c
index 68503e8..6c5bb1a 100644
--- a/shared/util.c
+++ b/shared/util.c
@@ -6,3 +6,10 @@ unsigned long w2_util_exp_mov_avg(unsigned long current_avg, unsigned long new_m
}
int w2_sign(int n) { return (n > 0) - (n < 0); }
+
+unsigned int w2_newline_count(char *str, unsigned int len) {
+ unsigned int newlines = 0;
+ for (unsigned int i = 0; i < len; i++)
+ if (str[i] == '\n') newlines++;
+ return newlines;
+}