Merging upstream version 1.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
ddae1b46ac
commit
a1a449adcc
9 changed files with 55 additions and 58 deletions
21
lzd.cc
21
lzd.cc
|
@ -1,5 +1,5 @@
|
|||
/* Lzd - Educational decompressor for the lzip format
|
||||
Copyright (C) 2013-2021 Antonio Diaz Diaz.
|
||||
Copyright (C) 2013-2022 Antonio Diaz Diaz.
|
||||
|
||||
This program is free software. Redistribution and use in source and
|
||||
binary forms, with or without modification, are permitted provided
|
||||
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
/*
|
||||
Exit status: 0 for a normal exit, 1 for environmental problems
|
||||
(file not found, invalid flags, I/O errors, etc), 2 to indicate a
|
||||
corrupt or invalid input file.
|
||||
(file not found, invalid command line options, I/O errors, etc), 2 to
|
||||
indicate a corrupt or invalid input file.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -29,7 +29,7 @@
|
|||
#include <cstring>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#if defined(__MSVCRT__) || defined(__OS2__) || defined(__DJGPP__)
|
||||
#if defined __MSVCRT__ || defined __OS2__ || defined __DJGPP__
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
@ -147,7 +147,8 @@ class Range_decoder
|
|||
public:
|
||||
Range_decoder() : member_pos( 6 ), code( 0 ), range( 0xFFFFFFFFU )
|
||||
{
|
||||
for( int i = 0; i < 5; ++i ) code = ( code << 8 ) | get_byte();
|
||||
get_byte(); // discard first byte of the LZMA stream
|
||||
for( int i = 0; i < 4; ++i ) code = ( code << 8 ) | get_byte();
|
||||
}
|
||||
|
||||
uint8_t get_byte() { ++member_pos; return std::getc( stdin ); }
|
||||
|
@ -180,8 +181,8 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
range -= bound;
|
||||
code -= bound;
|
||||
range -= bound;
|
||||
bm.probability -= bm.probability >> bit_model_move_bits;
|
||||
symbol = 1;
|
||||
}
|
||||
|
@ -308,7 +309,7 @@ void LZ_decoder::flush_data()
|
|||
}
|
||||
|
||||
|
||||
bool LZ_decoder::decode_member() // Returns false if error
|
||||
bool LZ_decoder::decode_member() // Return false if error
|
||||
{
|
||||
Bit_model bm_literal[1<<literal_context_bits][0x300];
|
||||
Bit_model bm_match[State::states][pos_states];
|
||||
|
@ -415,11 +416,11 @@ int main( const int argc, const char * const argv[] )
|
|||
{
|
||||
std::printf(
|
||||
"Lzd %s - Educational decompressor for the lzip format.\n"
|
||||
"Study the source to learn how a lzip decompressor works.\n"
|
||||
"Study the source code to learn how a lzip decompressor works.\n"
|
||||
"See the lzip manual for an explanation of the code.\n"
|
||||
"\nUsage: %s [-d] < file.lz > file\n"
|
||||
"Lzd decompresses from standard input to standard output.\n"
|
||||
"\nCopyright (C) 2021 Antonio Diaz Diaz.\n"
|
||||
"\nCopyright (C) 2022 Antonio Diaz Diaz.\n"
|
||||
"License 2-clause BSD.\n"
|
||||
"This is free software: you are free to change and redistribute it.\n"
|
||||
"There is NO WARRANTY, to the extent permitted by law.\n"
|
||||
|
@ -429,7 +430,7 @@ int main( const int argc, const char * const argv[] )
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__MSVCRT__) || defined(__OS2__) || defined(__DJGPP__)
|
||||
#if defined __MSVCRT__ || defined __OS2__ || defined __DJGPP__
|
||||
setmode( STDIN_FILENO, O_BINARY );
|
||||
setmode( STDOUT_FILENO, O_BINARY );
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue