* if this is a new context diff the character just * before
* If this is a new context diff the character just * before the newline is a '*'.
intuit_diff_type(void){	long	this_line = 0, previous_line;	long	first_command_line = -1;	LINENUM	fcl_line = -1;	bool	last_line_was_command = false, this_is_a_command = false;	bool	stars_last_line = false, stars_this_line = false;	char	*s, *t;	char	*indtmp = NULL;	char	*oldtmp = NULL;	char	*newtmp = NULL;	char	*indname = NULL;	char	*oldname = NULL;	char	*newname = NULL;	int	indent, retval;	bool	no_filearg = (filearg[0] == NULL);	ok_to_create_file = false;	fseek(pfp, p_base, SEEK_SET);	p_input_line = p_bline - 1;	for (;;) {		previous_line = this_line;		last_line_was_command = this_is_a_command;		stars_last_line = stars_this_line;		this_line = ftell(pfp);		indent = 0;		p_input_line++;		if (fgets(buf, sizeof buf, pfp) == NULL) {			if (first_command_line >= 0L) {				/* nothing but deletes!? */				p_start = first_command_line;				p_sline = fcl_line;				retval = ED_DIFF;				goto scan_exit;			} else {				p_start = this_line;				p_sline = p_input_line;				retval = 0;				goto scan_exit;			}		}		for (s = buf; *s == ' ' || *s == '\t' || *s == 'X'; s++) {			if (*s == '\t')				indent += 8 - (indent % 8);			else				indent++;		}		for (t = s; isdigit(*t) || *t == ','; t++)			;		this_is_a_command = (isdigit(*s) &&		    (*t == 'd' || *t == 'c' || *t == 'a'));		if (first_command_line < 0L && this_is_a_command) {			first_command_line = this_line;			fcl_line = p_input_line;			p_indent = indent;	/* assume this for now */		}		if (!stars_last_line && strnEQ(s, "*** ", 4))			oldtmp = savestr(s + 4);		else if (strnEQ(s, "--- ", 4))			newtmp = savestr(s + 4);		else if (strnEQ(s, "+++ ", 4))			oldtmp = savestr(s + 4); /* pretend it is the old name */		else if (strnEQ(s, "Index:", 6))			indtmp = savestr(s + 6);		else if (strnEQ(s, "Prereq:", 7)) {			for (t = s + 7; isspace(*t); t++)				;			revision = savestr(t);			for (t = revision; *t && !isspace(*t); t++)				;			*t = '\0';			if (*revision == '\0') {				free(revision);				revision = NULL;			}		}		if ((!diff_type || diff_type == ED_DIFF) &&		    first_command_line >= 0L &&		    strEQ(s, ".\n")) {			p_indent = indent;			p_start = first_command_line;			p_sline = fcl_line;			retval = ED_DIFF;			goto scan_exit;		}		if ((!diff_type || diff_type == UNI_DIFF) && strnEQ(s, "@@ -", 4)) {			if (!atol(s + 3))				ok_to_create_file = true;			p_indent = indent;			p_start = this_line;			p_sline = p_input_line;			retval = UNI_DIFF;			goto scan_exit;		}		stars_this_line = strnEQ(s, "********", 8);		if ((!diff_type || diff_type == CONTEXT_DIFF) && stars_last_line &&		    strnEQ(s, "*** ", 4)) {			if (!atol(s + 4))				ok_to_create_file = true;			/*			 * if this is a new context diff the character just			 * before			 */			/* the newline is a '*'. */			while (*s != '\n')				s++;			p_indent = indent;			p_start = previous_line;			p_sline = p_input_line - 1;			retval = (*(s - 1) == '*' ? NEW_CONTEXT_DIFF : CONTEXT_DIFF);			goto scan_exit;		}		if ((!diff_type || diff_type == NORMAL_DIFF) &&		    last_line_was_command &&		    (strnEQ(s, "< ", 2) || strnEQ(s, "> ", 2))) {			p_start = previous_line;			p_sline = p_input_line - 1;			p_indent = indent;			retval = NORMAL_DIFF;			goto scan_exit;		}	}scan_exit:	if (no_filearg) {		if (indtmp != NULL)			indname = fetchname(indtmp, strippath, ok_to_create_file);		if (oldtmp != NULL)			oldname = fetchname(oldtmp, strippath, ok_to_create_file);		if (newtmp != NULL)			newname = fetchname(newtmp, strippath, ok_to_create_file);		if (indname)			filearg[0] = savestr(indname);		else if (oldname && newname) {			if (strlen(oldname) < strlen(newname))				filearg[0] = savestr(oldname);			else				filearg[0] = savestr(newname);		} else if (oldname)			filearg[0] = savestr(oldname);		else if (newname)			filearg[0] = savestr(newname);	}	free(bestguess);	bestguess = NULL;	if (filearg[0] != NULL)		bestguess = savestr(filearg[0]);	else if (indtmp != NULL)		bestguess = fetchname(indtmp, strippath, true);	else {		if (oldtmp != NULL)			oldname = fetchname(oldtmp, strippath, true);		if (newtmp != NULL)			newname = fetchname(newtmp, strippath, true);		if (oldname && newname) {			if (strlen(oldname) < strlen(newname))				bestguess = savestr(oldname);			else				bestguess = savestr(newname);		} else if (oldname)			bestguess = savestr(oldname);		else if (newname)			bestguess = savestr(newname);	}	free(indtmp);	free(oldtmp);	free(newtmp);	free(indname);	free(oldname);	free(newname);	return retval;}