/* This will return 1, with the first character in buf being the character following the next instance of c in the file. This will read the file as needed. If there's an error, -errno is returned; if the end of the file is reached, 0 is returned.  */
static int next(int fd, char *buf, size_t size, char c)
/* This will return 1, with the first character in buf being the character following the next instance of c in the file. This will read the file as needed. If there's an error, -errno is returned; if the end of the file is reached, 0 is returned.  */
static int next(int fd, char *buf, size_t size, char c)
{
	ssize_t n;
	size_t len;
	char *ptr;
	while ((ptr = strchr(buf, c)) == NULL) {
		n = read(fd, buf, size - 1);
		if (n == 0)
			return 0;
		else if (n < 0)
			return -errno;
		buf[n] = '\0';
	}
	ptr++;
	len = strlen(ptr);
	memmove(buf, ptr, len + 1);
	n = read(fd, &buf[len], size - len - 1);
	if (n < 0)
		return -errno;
	buf[len + n] = '\0';
	return 1;
}