attr: skip UTF8 BOM at the beginning of the input file
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
599446dc32
commit
27547e5fcc
9
attr.c
9
attr.c
@ -12,6 +12,7 @@
|
|||||||
#include "exec_cmd.h"
|
#include "exec_cmd.h"
|
||||||
#include "attr.h"
|
#include "attr.h"
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
|
#include "utf8.h"
|
||||||
|
|
||||||
const char git_attr__true[] = "(builtin)true";
|
const char git_attr__true[] = "(builtin)true";
|
||||||
const char git_attr__false[] = "\0(builtin)false";
|
const char git_attr__false[] = "\0(builtin)false";
|
||||||
@ -369,8 +370,12 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
res = xcalloc(1, sizeof(*res));
|
res = xcalloc(1, sizeof(*res));
|
||||||
while (fgets(buf, sizeof(buf), fp))
|
while (fgets(buf, sizeof(buf), fp)) {
|
||||||
handle_attr_line(res, buf, path, ++lineno, macro_ok);
|
char *bufp = buf;
|
||||||
|
if (!lineno)
|
||||||
|
skip_utf8_bom(&bufp, strlen(bufp));
|
||||||
|
handle_attr_line(res, bufp, path, ++lineno, macro_ok);
|
||||||
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user