[Pkg-gnupg-commit] [libassuan] 26/437: 2001-12-14 Marcus Brinkmann <marcus at g10code.de>

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:33:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libassuan.

commit b55899ba47db83a410a588d2d7f4aa89db658202
Author: Marcus Brinkmann <mb at g10code.com>
Date:   Fri Dec 14 01:23:07 2001 +0000

    2001-12-14  Marcus Brinkmann  <marcus at g10code.de>
    
    	* 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.
---
 src/ChangeLog       |  6 ++++++
 src/assuan-buffer.c | 28 ++++++++++++++++------------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index b7d32a6..383ed88 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
 2001-12-14  Marcus Brinkmann  <marcus at g10code.de>
 
+	* 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  <marcus at g10code.de>
+
 	* assuan-defs.h (LINELENGTH): Define as ASSUAN_LINELENGTH.
 	assuan.h: Define ASSUAN_LINELENGTH.
 
diff --git a/src/assuan-buffer.c b/src/assuan-buffer.c
index ee085d0..399d11d 100644
--- a/src/assuan-buffer.c
+++ b/src/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')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git



More information about the Pkg-gnupg-commit mailing list