diff options
author | Heiko Voigt <hvoigt@hvoigt.net> | 2013-05-11 15:19:29 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-12 09:34:57 -0700 |
commit | dbb9a8125542be4d57bc71b6d5baf81c7409a68b (patch) | |
tree | 0a53564f29b0b80063f104e7de92e0c6d2baab9e /config.c | |
parent | ca4b5de28bad7d50b882794124ca4e57044a1cba (diff) | |
download | git-dbb9a8125542be4d57bc71b6d5baf81c7409a68b.tar.gz |
config: drop cf validity check in get_next_char()
The global variable cf is set with an initialized value in all codepaths before
calling this function.
The complete call graph looks like this:
git_config_from_file
-> do_config_from
-> git_parse_file
-> get_next_char
-> get_value
-> get_next_char
-> parse_value
-> get_next_char
-> get_base_var
-> get_next_char
-> get_extended_base_var
-> get_next_char
The variable is initialized in do_config_from.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 29 |
1 files changed, 13 insertions, 16 deletions
@@ -169,26 +169,23 @@ int git_config_from_parameters(config_fn_t fn, void *data) static int get_next_char(void) { int c; - FILE *f; + FILE *f = cf->f; - c = '\n'; - if (cf && ((f = cf->f) != NULL)) { + c = fgetc(f); + if (c == '\r') { + /* DOS like systems */ c = fgetc(f); - if (c == '\r') { - /* DOS like systems */ - c = fgetc(f); - if (c != '\n') { - ungetc(c, f); - c = '\r'; - } - } - if (c == '\n') - cf->linenr++; - if (c == EOF) { - cf->eof = 1; - c = '\n'; + if (c != '\n') { + ungetc(c, f); + c = '\r'; } } + if (c == '\n') + cf->linenr++; + if (c == EOF) { + cf->eof = 1; + c = '\n'; + } return c; } |