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

Function read_one_header_line

mailinfo.c:898–939  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

896}
897
898static int read_one_header_line(struct strbuf *line, FILE *in)
899{
900 struct strbuf continuation = STRBUF_INIT;
901
902 /* Get the first part of the line. */
903 if (strbuf_getline_lf(line, in))
904 return 0;
905
906 /*
907 * Is it an empty line or not a valid rfc2822 header?
908 * If so, stop here, and return false ("not a header")
909 */
910 strbuf_rtrim(line);
911 if (!line->len || !is_rfc2822_header(line)) {
912 /* Re-add the newline */
913 strbuf_addch(line, '\n');
914 return 0;
915 }
916
917 /*
918 * Now we need to eat all the continuation lines..
919 * Yuck, 2822 header "folding"
920 */
921 for (;;) {
922 int peek;
923
924 peek = fgetc(in);
925 if (peek == EOF)
926 break;
927 ungetc(peek, in);
928 if (peek != ' ' && peek != '\t')
929 break;
930 if (strbuf_getline_lf(&continuation, in))
931 break;
932 continuation.buf[0] = ' ';
933 strbuf_rtrim(&continuation);
934 strbuf_addbuf(line, &continuation);
935 }
936 strbuf_release(&continuation);
937
938 return 1;
939}
940
941static int find_boundary(struct mailinfo *mi, struct strbuf *line)
942{

Callers 2

handle_boundaryFunction · 0.70
mailinfoFunction · 0.70

Calls 6

strbuf_getline_lfFunction · 0.85
strbuf_rtrimFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_addbufFunction · 0.85
strbuf_releaseFunction · 0.85
is_rfc2822_headerFunction · 0.70

Tested by

no test coverage detected