From 1d3b36f89e716e28643154a319a489b4cdda23d4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 5 Nov 2016 18:33:47 +0100 Subject: [PATCH] factor out app_cr --- src/sync.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sync.c b/src/sync.c index d1b3816..0ed73a7 100644 --- a/src/sync.c +++ b/src/sync.c @@ -337,7 +337,7 @@ copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars ) char *in_buf = vars->data.data; int in_len = vars->data.len; int idx = 0, sbreak = 0, ebreak = 0; - int lines = 0, hdr_crs = 0, bdy_crs = 0, extra = 0; + int lines = 0, hdr_crs = 0, bdy_crs = 0, app_cr = 0, extra = 0; if (vars->srec) { nloop: ; int start = idx; @@ -364,7 +364,8 @@ copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars ) free( in_buf ); return 0; oke: - extra += 8 + TUIDL + 1 + (out_cr && (!in_cr || hdr_crs)); + app_cr = out_cr && (!in_cr || hdr_crs); + extra += 8 + TUIDL + app_cr + 1; } if (out_cr != in_cr) { for (; idx < in_len; idx++) { @@ -389,7 +390,7 @@ copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars ) out_buf += 8; memcpy( out_buf, vars->srec->tuid, TUIDL ); out_buf += TUIDL; - if (out_cr && (!in_cr || hdr_crs)) + if (app_cr) *out_buf++ = '\r'; *out_buf++ = '\n'; idx = ebreak;