lzcheck.c (lzlib-1.12.tar.lz) | : | lzcheck.c (lzlib-1.13.tar.lz) | ||
---|---|---|---|---|
/* Lzcheck - Test program for the library lzlib | /* Lzcheck - Test program for the library lzlib | |||
Copyright (C) 2009-2021 Antonio Diaz Diaz. | Copyright (C) 2009-2022 Antonio Diaz Diaz. | |||
This program is free software: you have unlimited permission | This program is free software: you have unlimited permission | |||
to copy, distribute, and modify it. | to copy, distribute, and modify it. | |||
Usage: lzcheck [-m|-s] filename.txt... | Usage: lzcheck [-m|-s] filename.txt... | |||
This program reads each text file specified and then compresses it, | This program reads each text file specified and then compresses it, | |||
line by line, to test the flushing mechanism and the member | line by line, to test the flushing mechanism and the member | |||
restart/reset/sync functions. | restart/reset/sync functions. | |||
*/ | */ | |||
skipping to change at line 130 | skipping to change at line 130 | |||
} | } | |||
if( size > 0 ) | if( size > 0 ) | |||
{ | { | |||
fprintf( stderr, "lzcheck: %lld bytes remain in decoder.\n", size ); | fprintf( stderr, "lzcheck: %lld bytes remain in decoder.\n", size ); | |||
exit( 3 ); | exit( 3 ); | |||
} | } | |||
} | } | |||
if( LZ_decompress_close( decoder ) < 0 ) exit( 1 ); | if( LZ_decompress_close( decoder ) < 0 ) exit( 1 ); | |||
} | } | |||
/* Returns the next (usually newline-terminated) chunk of data from file. | /* Return the next (usually newline-terminated) chunk of data from file. | |||
The size returned in *sizep is always <= buffer_size. | The size returned in *sizep is always <= buffer_size. | |||
If sizep is a null pointer, rewinds the file, resets state, and returns. | If sizep is a null pointer, rewind the file, reset state, and return. | |||
If file is at EOF, returns an empty line. */ | If file is at EOF, return an empty line. | |||
*/ | ||||
static const uint8_t * next_line( FILE * const file, int * const sizep ) | static const uint8_t * next_line( FILE * const file, int * const sizep ) | |||
{ | { | |||
static int l = 0; | static int l = 0; | |||
static int read_size = 0; | static int read_size = 0; | |||
int r; | int r; | |||
if( !sizep ) { rewind( file ); l = read_size = 0; return in_buffer; } | if( !sizep ) { rewind( file ); l = read_size = 0; return in_buffer; } | |||
if( l >= read_size ) | if( l >= read_size ) | |||
{ | { | |||
l = 0; read_size = fread( in_buffer, 1, buffer_size, file ); | l = 0; read_size = fread( in_buffer, 1, buffer_size, file ); | |||
skipping to change at line 326 | skipping to change at line 327 | |||
int retval = 0, i; | int retval = 0, i; | |||
int open_failures = 0; | int open_failures = 0; | |||
const char opt = ( argc > 2 && | const char opt = ( argc > 2 && | |||
( strcmp( argv[1], "-m" ) == 0 || strcmp( argv[1], "-s" ) == 0 ) ) ? | ( strcmp( argv[1], "-m" ) == 0 || strcmp( argv[1], "-s" ) == 0 ) ) ? | |||
argv[1][1] : 0; | argv[1][1] : 0; | |||
const int first = opt ? 2 : 1; | const int first = opt ? 2 : 1; | |||
const bool verbose = ( opt != 0 || argc > first + 1 ); | const bool verbose = ( opt != 0 || argc > first + 1 ); | |||
if( argc < 2 ) | if( argc < 2 ) | |||
{ | { | |||
fputs( "Usage: lzcheck filename.txt...\n", stderr ); | fputs( "Usage: lzcheck [-m|-s] filename.txt...\n", stderr ); | |||
return 1; | return 1; | |||
} | } | |||
for( i = first; i < argc && retval == 0; ++i ) | for( i = first; i < argc && retval == 0; ++i ) | |||
{ | { | |||
struct stat st; | struct stat st; | |||
if( stat( argv[i], &st ) != 0 || !S_ISREG( st.st_mode ) ) continue; | if( stat( argv[i], &st ) != 0 || !S_ISREG( st.st_mode ) ) continue; | |||
FILE * file = fopen( argv[i], "rb" ); | FILE * file = fopen( argv[i], "rb" ); | |||
if( !file ) | if( !file ) | |||
{ | { | |||
End of changes. 4 change blocks. | ||||
5 lines changed or deleted | 6 lines changed or added |