Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
config: use utf8_bom[] from utf.[ch] in git_parse_source()
author
Junio C Hamano
<gitster@pobox.com>
Thu, 16 Apr 2015 17:47:45 +0000
(10:47 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 16 Apr 2015 18:35:27 +0000
(11:35 -0700)
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>
config.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
dde843e
)
diff --git
a/config.c
b/config.c
index 752e2e227f56edfb7b2ad168798c110c14a2c5e8..9618aa443dee975c639a31a4ae2b3d55eed06d6e 100644
(file)
--- a/
config.c
+++ b/
config.c
@@
-12,6
+12,7
@@
#include "quote.h"
#include "hashmap.h"
#include "string-list.h"
#include "quote.h"
#include "hashmap.h"
#include "string-list.h"
+#include "utf8.h"
struct config_source {
struct config_source *prev;
struct config_source {
struct config_source *prev;
@@
-412,8
+413,7
@@
static int git_parse_source(config_fn_t fn, void *data)
struct strbuf *var = &cf->var;
/* U+FEFF Byte Order Mark in UTF8 */
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();
for (;;) {
int c = get_next_char();
@@
-421,7
+421,7
@@
static int git_parse_source(config_fn_t fn, void *data)
/* 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. */
/* 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 {
bomptr++;
continue;
} else {