Hi Charvi, On Fri, Jan 15, 2021 at 9:35 AM Charvi Mendiratta <charvi077@xxxxxxxxx> wrote: > On Thu, 14 Jan 2021 at 15:59, Phillip Wood <phillip.wood123@xxxxxxxxx> wrote: > > On 14/01/2021 08:27, Charvi Mendiratta wrote: > > > On Thu, 14 Jan 2021 at 00:31, Taylor Blau <me@xxxxxxxxxxxx> wrote: > > >> > > >> On Fri, Jan 08, 2021 at 02:53:41PM +0530, Charvi Mendiratta wrote: > > >>> From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx> > > >>> +static size_t subject_length(const char *body) > > >>> +{ > > >>> + size_t i, len = 0; > > >>> + char c; > > >>> + int blank_line = 1; > > >>> + for (i = 0, c = body[i]; c; c = body[++i]) { > > >>> + if (c == '\n') { > > >>> + if (blank_line) > > >>> + return len; > > >>> + len = i + 1; > > >>> + blank_line = 1; > > >>> + } else if (!isspace(c)) { > > >>> + blank_line = 0; > > >>> + } > > >>> + } > > >>> + return blank_line ? len : i; > > >>> +} > > >> > > >> OK, so this gets the length of the subject in "body", which is defined > > >> as the run of characters before a newline and then a space character. > > > > The length of the subject is the run of characters before a line > > containing only whitespace, "hello\n there" would return 13 "hello\n > > \nthere" would return 5. Looking again at my code there must be a way of > > writing that function that is easier to follow. > > Okay. I will look into it once, thanks for explaining. You may want to look at other places in the code where we deal with the subject. For example there is find_commit_subject() in commit.c and find_trailer_start() in trailer.c that might have interesting code for our purpose. Best, Christian.