Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
config: drop cf validity check in get_next_char()
author
Heiko Voigt
<hvoigt@hvoigt.net>
Sat, 11 May 2013 13:19:29 +0000
(15:19 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 12 Jul 2013 16:34:57 +0000
(09:34 -0700)
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>
config.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
ca4b5de
)
diff --git
a/config.c
b/config.c
index f0494f3af6f55bc3fc940963afd692f12bdf0f18..046642b69f1791373593403ad873b67ed764885f 100644
(file)
--- a/
config.c
+++ b/
config.c
@@
-169,26
+169,23
@@
int git_config_from_parameters(config_fn_t fn, void *data)
static int get_next_char(void)
{
int c;
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);
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;
}
return c;
}