summaryrefslogtreecommitdiffstats
path: root/unzcrash.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:50:02 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:50:02 +0000
commit018cead199f4ee24f0286cbd033355eae7f8fdae (patch)
treef0a935bac9c716aa3eed352755efa62e1b2b8206 /unzcrash.cc
parentAdding debian version 1.16-2. (diff)
downloadlziprecover-018cead199f4ee24f0286cbd033355eae7f8fdae.tar.xz
lziprecover-018cead199f4ee24f0286cbd033355eae7f8fdae.zip
Merging upstream version 1.17~pre1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--unzcrash.cc (renamed from testsuite/unzcrash.cc)21
1 files changed, 12 insertions, 9 deletions
diff --git a/testsuite/unzcrash.cc b/unzcrash.cc
index 470727d..0b44997 100644
--- a/testsuite/unzcrash.cc
+++ b/unzcrash.cc
@@ -33,7 +33,7 @@
#include <stdint.h>
#include <unistd.h>
-#include "../arg_parser.h"
+#include "arg_parser.h"
#if CHAR_BIT != 8
#error "Environments where CHAR_BIT != 8 are not supported."
@@ -209,18 +209,18 @@ public:
std::fflush( stderr );
int c = 0;
for( int i = 0; i < 8; ++i ) if( data[i] ) ++c;
- if( c == 8 ) std::printf( "Testing full byte.\n" );
- else if( c == 0 ) std::printf( "Nothing to test.\n" );
+ if( c == 8 ) std::fputs( "Testing full byte.\n", stdout );
+ else if( c == 0 ) std::fputs( "Nothing to test.\n", stdout );
else
{
- std::printf( "Testing " );
+ std::fputs( "Testing ", stdout );
for( int i = 0; i < 8; ++i )
if( data[i] )
{
std::printf( "%d", i + 1 );
- if( --c ) std::printf( "," );
+ if( --c ) std::fputs( ",", stdout );
}
- std::printf( " bit errors.\n" );
+ std::fputs( " bit errors.\n", stdout );
}
std::fflush( stdout );
}
@@ -241,7 +241,7 @@ int differing_bits( const uint8_t byte1, const uint8_t byte2 )
int main( const int argc, const char * const argv[] )
{
- enum { buffer_size = 3 << 20 };
+ enum { buffer_size = 75 << 20 };
Bitset8 bits; // if Bitset8::parse not called test full byte
int pos = 0;
int max_size = buffer_size;
@@ -330,18 +330,21 @@ int main( const int argc, const char * const argv[] )
if( verbosity >= 0 )
std::fprintf( stderr, "byte %d\n", i );
const uint8_t byte = buffer[i];
- for( int j = 0; j < 255; ++j )
+ for( int j = 1; j < 256; ++j )
{
++buffer[i];
if( bits.includes( differing_bits( byte, buffer[i] ) ) )
{
+ if( verbosity >= 2 )
+ std::fprintf( stderr, "0x%02X (0x%02X+0x%02X) ",
+ buffer[i], byte, j );
f = popen( parser.argument( argind ).c_str(), "w" );
if( !f )
{ show_error( "Can't open pipe", errno ); return 1; }
std::fwrite( buffer, 1, size, f );
if( pclose( f ) == 0 && verbosity >= 0 )
std::fprintf( stderr, "0x%02X (0x%02X+0x%02X) passed the test\n",
- buffer[i], byte, j + 1 );
+ buffer[i], byte, j );
}
}
buffer[i] = byte;