config: use utf8_bom[] from utf.[ch] in git_parse_source()

Because the function reads one character at the time, unfortunately we cannot use the easier skip_utf8_bom() helper, but at least we do not have to duplicate the constant string this way. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Apr 16, 2015 at 10:47 UTC 599446dc323d15bab7f2a54f57ae8c5c4d7d6103
1 file changed +3 -3
config.c
+3 -3
@@ -12,6 +12,7 @@
12 #include "quote.h"
13 #include "hashmap.h"
14 #include "string-list.h"
15 +#include "utf8.h"
16
17 struct config_source {
18 struct config_source *prev;
@@ -412,8 +413,7 @@ static int git_parse_source(config_fn_t fn, void *data)
413 struct strbuf *var = &cf->var;
414
415 /* U+FEFF Byte Order Mark in UTF8 */
415 - static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
416 - const unsigned char *bomptr = utf8_bom;
416 + const char *bomptr = utf8_bom;
417
418 for (;;) {
419 int c = get_next_char();
@@ -421,7 +421,7 @@ static int git_parse_source(config_fn_t fn, void *data)
421 /* We are at the file beginning; skip UTF8-encoded BOM
422 * if present. Sane editors won't put this in on their
423 * own, but e.g. Windows Notepad will do it happily. */
424 - if ((unsigned char) c == *bomptr) {
424 + if (c == (*bomptr & 0377)) {
425 bomptr++;
426 continue;
427 } else {