On 2015-04-16 16.05, Carlos Martín Nieto wrote:
[]
May be it is easier to move this into an own function, like remove_utf8_bom() ?
> dir.c | 8 +++++++-
> t/t7061-wtstatus-ignore.sh | 2 ++
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/dir.c b/dir.c
> index 0943a81..6368247 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -581,6 +581,7 @@ int add_excludes_from_file_to_list(const char *fname,
> struct stat st;
> int fd, i, lineno = 1;
> size_t size = 0;
> + static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
Do we really need to cast here (and if, is the cast dropping the "const" ?)
Another suggestion, see below:
either:
static const size_t bom_len = 3;
or
static const size_t bom_len = strlen(utf8_bom);
> char *buf, *entry;
>
> fd = open(fname, O_RDONLY);
> @@ -617,7 +618,12 @@ int add_excludes_from_file_to_list(const char *fname,
> }
>
> el->filebuf = buf;
> - entry = buf;
> +
And now we can avoid magic numbers:
if (size >= bom_len && !memcmp(buf, utf8_bom, bom_len))
entry = buf + bom_len;
else
entry = buf;
[]
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html