From: Marcus Brinkmann Date: Fri, 14 Dec 2001 01:22:00 +0000 (+0000) Subject: 2001-12-14 Marcus Brinkmann X-Git-Tag: gpgme-1.2.0@1385~1202 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=579d7e0b897e16f0aca51f1640b05b5148d8ee5c;p=gpgme.git 2001-12-14 Marcus Brinkmann * assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use it to save the number of bytes left over after the complete line. Rediddle the code a bit to make it more clear what happens. --- diff --git a/trunk/assuan/ChangeLog b/trunk/assuan/ChangeLog index 61563b0..57e503f 100644 --- a/trunk/assuan/ChangeLog +++ b/trunk/assuan/ChangeLog @@ -1,3 +1,9 @@ +2001-12-14 Marcus Brinkmann + + * assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use + it to save the number of bytes left over after the complete line. + Rediddle the code a bit to make it more clear what happens. + 2001-12-14 Marcus Brinkmann * assuan-defs.h (LINELENGTH): Define as ASSUAN_LINELENGTH. diff --git a/trunk/assuan/assuan-buffer.c b/trunk/assuan/assuan-buffer.c index ee085d0..399d11d 100644 --- a/trunk/assuan/assuan-buffer.c +++ b/trunk/assuan/assuan-buffer.c @@ -89,27 +89,30 @@ int _assuan_read_line (ASSUAN_CONTEXT ctx) { char *line = ctx->inbound.line; - int n, nread; + int n, nread, atticlen; int rc; - + if (ctx->inbound.eof) return -1; - if (ctx->inbound.attic.linelen) + atticlen = ctx->inbound.attic.linelen; + if (atticlen) { - memcpy (line, ctx->inbound.attic.line, ctx->inbound.attic.linelen); - nread = ctx->inbound.attic.linelen; + memcpy (line, ctx->inbound.attic.line, atticlen); ctx->inbound.attic.linelen = 0; - for (n=0; n < nread && line[n] != '\n'; n++) + for (n=0; n < atticlen && line[n] != '\n'; n++) ; - if (n < nread) - rc = 0; /* found another line in the attic */ + if (n < atticlen) + { + rc = 0; /* found another line in the attic */ + nread = atticlen; + atticlen = 0; + } else { /* read the rest */ - n = nread; - assert (n < LINELENGTH); - rc = readline (ctx->inbound.fd, line + n, LINELENGTH - n, - &nread, &ctx->inbound.eof); + assert (atticlen < LINELENGTH); + rc = readline (ctx->inbound.fd, line + atticlen, + LINELENGTH - atticlen, &nread, &ctx->inbound.eof); } } else @@ -124,6 +127,7 @@ _assuan_read_line (ASSUAN_CONTEXT ctx) } ctx->inbound.attic.pending = 0; + nread += atticlen; for (n=0; n < nread; n++) { if (line[n] == '\n')