git-2.22.0/trailer.c
/*
 * Return the position of the start of the last line. If len is 0, return -1.
 */
Return the position of the start of the last line. If len is 0, return -1.
Return the position of the start of the last line . If len is 0 return - 1 .
static ssize_t last_line(const char *buf, size_t len)
{
	ssize_t i;
	if (len == 0)
		return -1;
	if (len == 1)
		return 0;
	i = len - 2;
	for (; i >= 0; i--) {
		if (buf[i] == '\n')
			return i + 1;
	}
	return 0;
}
static ssize_t last_line ( const char * buf , size_t len ) { ssize_t i ; if ( len == 0 ) return -1 ; if ( len == 1 ) return 0 ; i = len - 2 ; for ( ; i >= 0 ; i -- ) { if ( buf [ i ] == ' \n ' ) return i + 1 ; } return 0 ; }
Return the position of the start of the last line.
Return the position of the start of the last line .
/*
	 * Skip the last character (in addition to the null terminator),
	 * because if the last character is a newline, it is considered as part
	 * of the last line anyway.
	 */