Skip to content

Commit 599446d

Browse files
committed
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 <[email protected]>
1 parent dde843e commit 599446d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "quote.h"
1313
#include "hashmap.h"
1414
#include "string-list.h"
15+
#include "utf8.h"
1516

1617
struct config_source {
1718
struct config_source *prev;
@@ -412,16 +413,15 @@ static int git_parse_source(config_fn_t fn, void *data)
412413
struct strbuf *var = &cf->var;
413414

414415
/* 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;
417417

418418
for (;;) {
419419
int c = get_next_char();
420420
if (bomptr && *bomptr) {
421421
/* We are at the file beginning; skip UTF8-encoded BOM
422422
* if present. Sane editors won't put this in on their
423423
* own, but e.g. Windows Notepad will do it happily. */
424-
if ((unsigned char) c == *bomptr) {
424+
if (c == (*bomptr & 0377)) {
425425
bomptr++;
426426
continue;
427427
} else {

0 commit comments

Comments
 (0)