summaryrefslogtreecommitdiffstats
path: root/decoder.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:04:50 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:04:50 +0000
commit71b2bb2953dc5c5722710d53802bdcfb67a219de (patch)
tree0cc5eccfbf983c8624a29ab4b96aeeb214d1c9b3 /decoder.cc
parentAdding debian version 1.16~pre2-1. (diff)
downloadlzip-71b2bb2953dc5c5722710d53802bdcfb67a219de.tar.xz
lzip-71b2bb2953dc5c5722710d53802bdcfb67a219de.zip
Merging upstream version 1.16~rc1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.cc')
-rw-r--r--decoder.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/decoder.cc b/decoder.cc
index f7676e5..fba62c2 100644
--- a/decoder.cc
+++ b/decoder.cc
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -57,17 +57,17 @@ void Pretty_print::operator()( const char * const msg ) const
*/
int readblock( const int fd, uint8_t * const buf, const int size )
{
- int rest = size;
+ int sz = 0;
errno = 0;
- while( rest > 0 )
+ while( sz < size )
{
- const int n = read( fd, buf + size - rest, rest );
- if( n > 0 ) rest -= n;
+ const int n = read( fd, buf + sz, size - sz );
+ if( n > 0 ) sz += n;
else if( n == 0 ) break; // EOF
else if( errno != EINTR ) break;
errno = 0;
}
- return size - rest;
+ return sz;
}
@@ -76,16 +76,16 @@ int readblock( const int fd, uint8_t * const buf, const int size )
*/
int writeblock( const int fd, const uint8_t * const buf, const int size )
{
- int rest = size;
+ int sz = 0;
errno = 0;
- while( rest > 0 )
+ while( sz < size )
{
- const int n = write( fd, buf + size - rest, rest );
- if( n > 0 ) rest -= n;
+ const int n = write( fd, buf + sz, size - sz );
+ if( n > 0 ) sz += n;
else if( n < 0 && errno != EINTR ) break;
errno = 0;
}
- return size - rest;
+ return sz;
}