提交 dbb9a812 编写于 作者: H Heiko Voigt 提交者: Junio C Hamano

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: NHeiko Voigt <hvoigt@hvoigt.net>
Acked-by: NJeff King <peff@peff.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 ca4b5de2
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册