patch 9.1.1009: diff feature can be improved
Problem: diff feature can be improved
Solution: include the linematch diff alignment algorithm
(Jonathon)
closes: #9661
Signed-off-by: Jonathon <jonathonwhite@protonmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/strings.c b/src/strings.c
index cd75bc3..54ac178 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -674,6 +674,22 @@
return NULL;
}
+// Sized version of strchr that can handle embedded NULs.
+// Adjusts n to the new size.
+ char *
+vim_strnchr(const char *p, size_t *n, int c)
+{
+ while (*n > 0)
+ {
+ if (*p == c)
+ return (char *)p;
+ p++;
+ (*n)--;
+ }
+
+ return NULL;
+}
+
/*
* Version of strchr() that only works for bytes and handles unsigned char
* strings with characters above 128 correctly. It also doesn't return a