imap-send.c: simplify logic in lf_to_crlf()
commit3691031cb33922ce49448518aa06e33eded3368e
authorMichael Haggerty <mhagger@alum.mit.edu>
Tue, 15 Jan 2013 08:06:32 +0000 (15 09:06 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 15 Jan 2013 22:50:23 +0000 (15 14:50 -0800)
treed121fd0f000eddec28091fd7a9b0878a0e74b68b
parent636fd66bc18d7563b9260485a9974da67a805514
imap-send.c: simplify logic in lf_to_crlf()

* The first character in the string used to be special-cased to get
  around the fact that msg->buf[i - 1] is not defined for i == 0.
  Instead, keep track of the previous character in a separate
  variable, "lastc", initialized in such a way to let the loop handle
  i == 0 correctly.

* Make the two loops over the string look as similar as possible to
  make it more obvious that the count computed in the first pass
  agrees with the true length of the new string written in the second
  pass.  As a side effect, this makes it possible to use the "j"
  counter in place of lfnum and new_len.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
imap-send.c