Skip to content

Commit

Permalink
attr: skip UTF8 BOM at the beginning of the input file
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Apr 16, 2015
1 parent 599446d commit 27547e5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "exec_cmd.h"
#include "attr.h"
#include "dir.h"
#include "utf8.h"

const char git_attr__true[] = "(builtin)true";
const char git_attr__false[] = "\0(builtin)false";
Expand Down Expand Up @@ -369,8 +370,12 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
return NULL;
}
res = xcalloc(1, sizeof(*res));
while (fgets(buf, sizeof(buf), fp))
handle_attr_line(res, buf, path, ++lineno, macro_ok);
while (fgets(buf, sizeof(buf), fp)) {
char *bufp = buf;
if (!lineno)
skip_utf8_bom(&bufp, strlen(bufp));
handle_attr_line(res, bufp, path, ++lineno, macro_ok);
}
fclose(fp);
return res;
}
Expand Down

0 comments on commit 27547e5

Please sign in to comment.