Skip to content

Commit

Permalink
config: use utf8_bom[] from utf.[ch] in git_parse_source()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Apr 16, 2015
1 parent dde843e commit 599446d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "quote.h"
#include "hashmap.h"
#include "string-list.h"
#include "utf8.h"

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

/* U+FEFF Byte Order Mark in UTF8 */
static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
const unsigned char *bomptr = utf8_bom;
const char *bomptr = utf8_bom;

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

0 comments on commit 599446d

Please sign in to comment.