MCPcopy Create free account
hub / github.com/git/git / get_next_char

Function get_next_char

config.c:799–833  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

797}
798
799static int get_next_char(struct config_source *cs)
800{
801 int c = cs->do_fgetc(cs);
802
803 if (c == '\r') {
804 /* DOS like systems */
805 c = cs->do_fgetc(cs);
806 if (c != '\n') {
807 if (c != EOF)
808 cs->do_ungetc(c, cs);
809 c = '\r';
810 }
811 }
812
813 if (c != EOF && ++cs->total_len > INT_MAX) {
814 /*
815 * This is an absurdly long config file; refuse to parse
816 * further in order to protect downstream code from integer
817 * overflows. Note that we can't return an error specifically,
818 * but we can mark EOF and put trash in the return value,
819 * which will trigger a parse error.
820 */
821 cs->eof = 1;
822 return 0;
823 }
824
825 if (c == '\n')
826 cs->linenr++;
827 if (c == EOF) {
828 cs->eof = 1;
829 cs->linenr++;
830 c = '\n';
831 }
832 return c;
833}
834
835static char *parse_value(struct config_source *cs)
836{

Callers 5

parse_valueFunction · 0.85
get_valueFunction · 0.85
get_extended_base_varFunction · 0.85
get_base_varFunction · 0.85
git_parse_sourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected