git-openssl/git-2.7.4/rerere.c
/*
 * ... and its getline() method implementation
 */
and its getline() method implementation
and its getline () method implementation
static int rerere_mem_getline(struct strbuf *sb, struct rerere_io *io_)
{
	struct rerere_io_mem *io = (struct rerere_io_mem *)io_;
	char *ep;
	size_t len;
	strbuf_release(sb);
	if (!io->input.len)
		return -1;
	ep = memchr(io->input.buf, '\n', io->input.len);
	if (!ep)
		ep = io->input.buf + io->input.len;
	else if (*ep == '\n')
		ep++;
	len = ep - io->input.buf;
	strbuf_add(sb, io->input.buf, len);
	strbuf_remove(&io->input, 0, len);
	return 0;
}
static int rerere_mem_getline ( struct strbuf * sb , struct rerere_io * io_ ) { struct rerere_io_mem * io = ( struct rerere_io_mem * ) io_ ; char * ep ; size_t len ; strbuf_release ( sb ) ; if ( ! io -> input . len ) return -1 ; ep = memchr ( io -> input . buf , ' \n ' , io -> input . len ) ; if ( ! ep ) ep = io -> input . buf + io -> input . len ; else if ( * ep == ' \n ' ) ep ++ ; len = ep - io -> input . buf ; strbuf_add ( sb , io -> input . buf , len ) ; strbuf_remove ( & io -> input , 0 , len ) ; return 0 ; }
... and its getline() method implementation
... and its getline () method implementation