diff options
author | Marcus Brinkmann <[email protected]> | 2001-12-14 01:22:00 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2001-12-14 01:22:00 +0000 |
commit | c6cf950f9e05d3b37faf8606ea6105ddb17486a7 (patch) | |
tree | 6ef422e2bacaca0c00bd6d2fda021f26c7ce36c2 /assuan/assuan-buffer.c | |
parent | gpgme/ (diff) | |
download | gpgme-c6cf950f9e05d3b37faf8606ea6105ddb17486a7.tar.gz gpgme-c6cf950f9e05d3b37faf8606ea6105ddb17486a7.zip |
2001-12-14 Marcus Brinkmann <[email protected]>
* 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.
Diffstat (limited to 'assuan/assuan-buffer.c')
-rw-r--r-- | assuan/assuan-buffer.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/assuan/assuan-buffer.c b/assuan/assuan-buffer.c index ee085d0c..399d11db 100644 --- a/assuan/assuan-buffer.c +++ b/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') |