On 25.01.16 09:07, Johannes Schindelin wrote:
[]
> diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
> index 625198e..c852acc 100644
> --- a/xdiff/xmerge.c
> +++ b/xdiff/xmerge.c
> @@ -143,6 +143,35 @@ static int xdl_orig_copy(xdfenv_t *xe, int i, int count, 
> int add_nl, char *dest)
>       return xdl_recs_copy_0(1, xe, i, count, add_nl, dest);
>  }
>  
> +/*
> + * Returns 1 if the i'th line ends in CR/LF (if it is the last line and
> + * has no eol, the preceding line, if any), 0 if it ends in LF-only, and
> + * -1 if the line ending cannot be determined.
> + */
> +static int is_eol_crlf(xdfile_t *file, int i)
Minot nit: Could that be 
is_eol_crlf(xdfile_t *file, int lineno)
(or may be)
is_eol_crlf(const xdfile_t *file, int lineno)
(or may be)
has_eol_crlf(const xdfile_t *file, int lineno)

> +{
> +     long size;
> +
> +     if (i < file->nrec - 1)
> +             /* All lines before the last *must* end in LF */
> +             return (size = file->recs[i]->size) > 1 &&
> +                     file->recs[i]->ptr[size - 2] == '\r';
> +     if (!file->nrec)
> +             /* Cannot determine eol style from empty file */
> +             return -1;
> +     if ((size = file->recs[i]->size) &&
> +                     file->recs[i]->ptr[size - 1] == '\n')
> +             /* Last line; ends in LF; Is it CR/LF? */
> +             return size > 1 &&
> +                     file->recs[i]->ptr[size - 2] == '\r';
> +     if (!i)
> +             /* The only line has no eol */
> +             return -1;
> +     /* Determine eol from second-to-last line */
> +     return (size = file->recs[i - 1]->size) > 1 &&
> +             file->recs[i - 1]->ptr[size - 2] == '\r';
> +}
> +

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to