diff options
author | Mattias Andrée <maandree@kth.se> | 2024-01-09 22:04:24 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2024-01-09 22:04:24 +0100 |
commit | ae850b1ac755f471beac4dbfef4654fe3fbaaae9 (patch) | |
tree | 319e7f7f1b99cd1ee75e100f0a29b0f7c827ccea /libpatch_next_line__.c | |
download | libpatch-ae850b1ac755f471beac4dbfef4654fe3fbaaae9.tar.gz libpatch-ae850b1ac755f471beac4dbfef4654fe3fbaaae9.tar.bz2 libpatch-ae850b1ac755f471beac4dbfef4654fe3fbaaae9.tar.xz |
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libpatch_next_line__.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libpatch_next_line__.c b/libpatch_next_line__.c new file mode 100644 index 0000000..0762262 --- /dev/null +++ b/libpatch_next_line__.c @@ -0,0 +1,19 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +size_t +libpatch_next_line__(const char **text, size_t *textlen, size_t lastlen) +{ + size_t len; + + while (lastlen < *textlen && (*text)[lastlen] == '\n') + lastlen += 1; + *text = &(*text)[lastlen]; + *textlen -= lastlen; + + len = 0; + while (len < *textlen && (*text)[len] != '\n') + len += 1; + return len; +} |