aboutsummaryrefslogtreecommitdiffstats
path: root/libpatch_next_line__.c
blob: 0762262b68bc4db1604f68c746cf448137415cff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
}