Remove trailing whitespace from all files (#497)

This commit is contained in:
Jared Miller 2022-07-20 23:31:16 -04:00 committed by GitHub
parent d3f3cb7ab4
commit 7e2eae5c15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
356 changed files with 41701 additions and 41680 deletions

View file

@ -193,12 +193,12 @@ stub: mov $0x40,%dl # *literally* dos
to a program as soon as its first sector is loaded. That gives to a program as soon as its first sector is loaded. That gives
us control over user-facing latency, even though the next step us control over user-facing latency, even though the next step
will generally be asking the BIOS to load more. will generally be asking the BIOS to load more.
The process is trivial enough that this entrypoint can support The process is trivial enough that this entrypoint can support
handoffs from alternative program-loaders e.g. Grub and MS-DOS handoffs from alternative program-loaders e.g. Grub and MS-DOS
so long as they either load our full program, or implement the so long as they either load our full program, or implement the
PC BIOS disk service API. PC BIOS disk service API.
Since so many different implementations of these APIs have been Since so many different implementations of these APIs have been
built the last forty years these routines also canonicalize the built the last forty years these routines also canonicalize the
cpu and program state, as it is written in the System V ABI. */ cpu and program state, as it is written in the System V ABI. */
@ -910,7 +910,7 @@ ape_macho:
αcτµαlly pδrταblε εxεcµταblε § the new technology αcτµαlly pδrταblε εxεcµταblε § the new technology
The Portable Executable Format The Portable Executable Format
@see https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format @see https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format
@see "The Portable Executable File Format from Top to Bottom", @see "The Portable Executable File Format from Top to Bottom",
Randy Kath, Microsoft Developer Network Technology Group. */ Randy Kath, Microsoft Developer Network Technology Group. */

View file

@ -37,10 +37,10 @@ This library provides several interfaces to load, demux and decode MPEG video
and audio data. A high-level API combines the demuxer, video & audio decoders and audio data. A high-level API combines the demuxer, video & audio decoders
in an easy to use wrapper. in an easy to use wrapper.
Lower-level APIs for accessing the demuxer, video decoder and audio decoder, Lower-level APIs for accessing the demuxer, video decoder and audio decoder,
as well as providing different data sources are also available. as well as providing different data sources are also available.
Interfaces are written in an object orientet style, meaning you create object Interfaces are written in an object orientet style, meaning you create object
instances via various different constructor functions (plm_*create()), instances via various different constructor functions (plm_*create()),
do some work on them and later dispose them via plm_*destroy(). do some work on them and later dispose them via plm_*destroy().
@ -51,11 +51,11 @@ plm_video_* -- the MPEG1 Video ("mpeg1") decoder
plm_audio_* -- the MPEG1 Audio Layer II ("mp2") decoder plm_audio_* -- the MPEG1 Audio Layer II ("mp2") decoder
This library uses malloc(), realloc() and free() to manage memory. Typically This library uses malloc(), realloc() and free() to manage memory. Typically
all allocation happens up-front when creating the interface. However, the all allocation happens up-front when creating the interface. However, the
default buffer size may be too small for certain inputs. In these cases plmpeg default buffer size may be too small for certain inputs. In these cases plmpeg
will realloc() the buffer with a larger size whenever needed. You can configure will realloc() the buffer with a larger size whenever needed. You can configure
the default buffer size by defining PLM_BUFFER_DEFAULT_SIZE *before* the default buffer size by defining PLM_BUFFER_DEFAULT_SIZE *before*
including this library. including this library.
With the high-level interface you have two options to decode video & audio: With the high-level interface you have two options to decode video & audio:
@ -85,7 +85,7 @@ mat4 rec601 = mat4(
gl_FragColor = vec4(y, cb, cr, 1.0) * rec601; gl_FragColor = vec4(y, cb, cr, 1.0) * rec601;
Audio data is decoded into a struct with either one single float array with the Audio data is decoded into a struct with either one single float array with the
samples for the left and right channel interleaved, or if the samples for the left and right channel interleaved, or if the
PLM_AUDIO_SEPARATE_CHANNELS is defined *before* including this library, into PLM_AUDIO_SEPARATE_CHANNELS is defined *before* including this library, into
two separate float arrays - one for each channel. two separate float arrays - one for each channel.

View file

@ -115,8 +115,8 @@ plm_packet_t *plm_demux_decode(plm_demux_t *self) {
do { do {
code = plm_buffer_next_start_code(self->buffer); code = plm_buffer_next_start_code(self->buffer);
if ( if (
code == PLM_DEMUX_PACKET_VIDEO_1 || code == PLM_DEMUX_PACKET_VIDEO_1 ||
code == PLM_DEMUX_PACKET_PRIVATE || code == PLM_DEMUX_PACKET_PRIVATE ||
(code >= PLM_DEMUX_PACKET_AUDIO_1 && code <= PLM_DEMUX_PACKET_AUDIO_4) (code >= PLM_DEMUX_PACKET_AUDIO_1 && code <= PLM_DEMUX_PACKET_AUDIO_4)
) { ) {
return plm_demux_decode_packet(self, code); return plm_demux_decode_packet(self, code);

View file

@ -273,7 +273,7 @@ typedef plm_audio_t plm_audio_t;
int plm_audio_decode_header(plm_audio_t *self); int plm_audio_decode_header(plm_audio_t *self);
void plm_audio_decode_frame(plm_audio_t *self); void plm_audio_decode_frame(plm_audio_t *self);
const plm_quantizer_spec_t *plm_audio_read_allocation(plm_audio_t *self, int sb, int tab3); const plm_quantizer_spec_t *plm_audio_read_allocation(plm_audio_t *self, int sb, int tab3);
void plm_audio_read_samples(plm_audio_t *self, int ch, int sb, int part); void plm_audio_read_samples(plm_audio_t *self, int ch, int sb, int part);
void plm_audio_matrix_transform(int s[32][3], int ss, float *d, int dp); void plm_audio_matrix_transform(int s[32][3], int ss, float *d, int dp);
plm_audio_t *plm_audio_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) { plm_audio_t *plm_audio_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) {
@ -345,7 +345,7 @@ plm_samples_t *plm_audio_decode(plm_audio_t *self) {
self->samples.time = self->time; self->samples.time = self->time;
self->samples_decoded += PLM_AUDIO_SAMPLES_PER_FRAME; self->samples_decoded += PLM_AUDIO_SAMPLES_PER_FRAME;
self->time = (double)self->samples_decoded / self->time = (double)self->samples_decoded /
(double)PLM_AUDIO_SAMPLE_RATE[self->samplerate_index]; (double)PLM_AUDIO_SAMPLE_RATE[self->samplerate_index];
return &self->samples; return &self->samples;
@ -402,7 +402,7 @@ int plm_audio_decode_header(plm_audio_t *self) {
plm_buffer_skip(self->buffer, 16); plm_buffer_skip(self->buffer, 16);
} }
// Compute frame size, check if we have enough data to decode the whole // Compute frame size, check if we have enough data to decode the whole
// frame. // frame.
int bitrate = PLM_AUDIO_BIT_RATE[self->bitrate_index]; int bitrate = PLM_AUDIO_BIT_RATE[self->bitrate_index];
int samplerate = PLM_AUDIO_SAMPLE_RATE[self->samplerate_index]; int samplerate = PLM_AUDIO_SAMPLE_RATE[self->samplerate_index];
@ -561,7 +561,7 @@ void plm_audio_decode_frame(plm_audio_t *self) {
} }
#else #else
for (int j = 0; j < 32; j++) { for (int j = 0; j < 32; j++) {
self->samples.interleaved[((out_pos + j) << 1) + ch] = self->samples.interleaved[((out_pos + j) << 1) + ch] =
self->U[j] / 2147418112.0f; self->U[j] / 2147418112.0f;
} }
#endif #endif

View file

@ -94,7 +94,7 @@ plm_t *plm_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) {
self->demux = plm_demux_create(buffer, destroy_when_done); self->demux = plm_demux_create(buffer, destroy_when_done);
// In theory we should check plm_demux_get_num_video_streams() and // In theory we should check plm_demux_get_num_video_streams() and
// plm_demux_get_num_audio_streams() here, but older files typically // plm_demux_get_num_audio_streams() here, but older files typically
// do not specify these correctly. So we just assume we have a video and // do not specify these correctly. So we just assume we have a video and
// audio stream and create the decoders. // audio stream and create the decoders.
@ -159,7 +159,7 @@ double plm_get_framerate(plm_t *self) {
int plm_get_num_audio_streams(plm_t *self) { int plm_get_num_audio_streams(plm_t *self) {
// Some files do not specify the number of audio streams in the system header. // Some files do not specify the number of audio streams in the system header.
// If the reported number of streams is 0, we check if we have a samplerate, // If the reported number of streams is 0, we check if we have a samplerate,
// indicating at least one audio stream. // indicating at least one audio stream.
int num_streams = plm_demux_get_num_audio_streams(self->demux); int num_streams = plm_demux_get_num_audio_streams(self->demux);
return num_streams == 0 && plm_get_samplerate(self) ? 1 : num_streams; return num_streams == 0 && plm_get_samplerate(self) ? 1 : num_streams;

View file

@ -96,7 +96,7 @@ char *realpath(const char *filename, char *resolved)
return 0; return 0;
} }
if (l >= PATH_MAX) goto toolong; if (l >= PATH_MAX) goto toolong;
if (l >= 4 && READ32LE(filename) == READ32LE("/zip") && if (l >= 4 && READ32LE(filename) == READ32LE("/zip") &&
(!filename[4] || filename[4] == '/')) { (!filename[4] || filename[4] == '/')) {
return ResolvePath(resolved, filename, l); return ResolvePath(resolved, filename, l);
} }

View file

@ -32,7 +32,7 @@ void PrintGarbageNumeric(FILE *f) {
fprintf(f, " garbage entry parent frame original ret callback arg \n"); fprintf(f, " garbage entry parent frame original ret callback arg \n");
fprintf(f, "-------------- -------------- ------------------ ------------------ ------------------\n"); fprintf(f, "-------------- -------------- ------------------ ------------------ ------------------\n");
for (i = __garbage.i; i--;) { for (i = __garbage.i; i--;) {
fprintf(f, "0x%012lx 0x%012lx 0x%016lx 0x%016lx 0x%016lx\n", fprintf(f, "0x%012lx 0x%012lx 0x%016lx 0x%016lx 0x%016lx\n",
__garbage.p + i, __garbage.p + i,
__garbage.p[i].frame, __garbage.p[i].frame,
__garbage.p[i].ret, __garbage.p[i].ret,

View file

@ -48,11 +48,11 @@
// //
// //
// //
// //
// //
// //
// //
// //
// THERE WILL BE BLOCKS march 01 2017 // THERE WILL BE BLOCKS march 01 2017
// //
// @see libc/str/str.h // @see libc/str/str.h

View file

@ -5,11 +5,11 @@
/* /*
Compute probability of measured Chi Square value. Compute probability of measured Chi Square value.
This code was developed by Gary Perlman of the Wang This code was developed by Gary Perlman of the Wang
Institute (full citation below) and has been minimally Institute (full citation below) and has been minimally
modified for use in this program. modified for use in this program.
*/ */
#include "libc/math.h" #include "libc/math.h"

View file

@ -151,12 +151,12 @@ void rt_end(double *r_ent, double *r_chisq, double *r_mean,
in the entropy calculation below. While we're at it, in the entropy calculation below. While we're at it,
we sum of all the data which will be used to compute the we sum of all the data which will be used to compute the
mean. */ mean. */
cexp_ = totalc / (binary ? 2.0 : 256.0); /* Expected count per bin */ cexp_ = totalc / (binary ? 2.0 : 256.0); /* Expected count per bin */
for (i = 0; i < (binary ? 2 : 256); i++) { for (i = 0; i < (binary ? 2 : 256); i++) {
double a = ccount[i] - cexp_; double a = ccount[i] - cexp_;
prob[i] = ((double) ccount[i]) / totalc; prob[i] = ((double) ccount[i]) / totalc;
chisq += (a * a) / cexp_; chisq += (a * a) / cexp_;
datasum += ((double) i) * ccount[i]; datasum += ((double) i) * ccount[i];
} }

View file

@ -24,9 +24,9 @@
▄██▀▄▄░░▀▐▄████▄ █████▀▄░░█▀▄▀░░ ▄██░ ▄██▀▄▄░░▀▐▄████▄ █████▀▄░░█▀▄▀░░ ▄██░
█████▄▄▄███▀░█▌██▄▀▀█████▄▄░░░▄▄███▀██▄ ▄▀▀▀▄▄ █████▄▄▄███▀░█▌██▄▀▀█████▄▄░░░▄▄███▀██▄ ▄▀▀▀▄▄
▀██████▀■▄█▄▄ ░▀███████████████▓▓░░▄██▀▄████▄▄▀▄ ▀██████▀■▄█▄▄ ░▀███████████████▓▓░░▄██▀▄████▄▄▀▄
█▀█ █ █▀█ █▀█ █▄▀ ▐▀█▀▌█▀█ █▀█ █▄ █ ▀█▀ █▀█ █▀▀ █▀█ █ █▀█ █▀█ █▄▀ ▐▀█▀▌█▀█ █▀█ █▄ █ ▀█▀ █▀█ █▀▀
█▀▄ █ █ █ █ █ ▀▄ █ █▀▄ █ █ █ ▀█ █ █ ▀▀█ █▀▄ █ █ █ █ █ ▀▄ █ █▀▄ █ █ █ ▀█ █ █ ▀▀█
█▄█ █▄▌█▄█ █▄█ █ █ █ █ █ █▄█ █ █ ▄█▄ █▄█ █▄█ █▄█ █▄▌█▄█ █▄█ █ █ █ █ █ █▄█ █ █ ▄█▄ █▄█ █▄█
THERE WILL BE BLOCKS march 01 2017 THERE WILL BE BLOCKS march 01 2017

View file

@ -187,7 +187,7 @@ static bool increment_overflow(int *, int);
static bool increment_overflow_time(time_t *, int_fast32_t); static bool increment_overflow_time(time_t *, int_fast32_t);
static int_fast32_t leapcorr(struct state const *, time_t); static int_fast32_t leapcorr(struct state const *, time_t);
static bool normalize_overflow32(int_fast32_t *, int *, int); static bool normalize_overflow32(int_fast32_t *, int *, int);
static struct tm *localtime_timesub(time_t const *, int_fast32_t, static struct tm *localtime_timesub(time_t const *, int_fast32_t,
struct state const *, struct tm *); struct state const *, struct tm *);
static bool localtime_typesequiv(struct state const *, int, int); static bool localtime_typesequiv(struct state const *, int, int);
static bool localtime_tzparse(char const *, struct state *, struct state *); static bool localtime_tzparse(char const *, struct state *, struct state *);

View file

@ -109,7 +109,7 @@ double asin(double x)
int ng; int ng;
uint32_t ix,lx; uint32_t ix,lx;
double z,r,s,f,c; double z,r,s,f,c;
union { union {
double f; double f;
int64_t s; int64_t s;
uint64_t i; uint64_t i;

View file

@ -36,7 +36,7 @@ asm(".include \"libc/disclaimer.inc\"");
/** /**
* Returns hyperbolic sine of 𝑥. * Returns hyperbolic sine of 𝑥.
* *
* sinh(x) = (exp(x) - 1/exp(x))/2 * sinh(x) = (exp(x) - 1/exp(x))/2
* = (exp(x)-1 + (exp(x)-1)/exp(x))/2 * = (exp(x)-1 + (exp(x)-1)/exp(x))/2
* = x + x^3/6 + o(x^5) * = x + x^3/6 + o(x^5)

View file

@ -36,7 +36,7 @@ asm(".include \"libc/disclaimer.inc\"");
/** /**
* Returns hyperbolic sine of 𝑥. * Returns hyperbolic sine of 𝑥.
* *
* sinh(x) = (exp(x) - 1/exp(x))/2 * sinh(x) = (exp(x) - 1/exp(x))/2
* = (exp(x)-1 + (exp(x)-1)/exp(x))/2 * = (exp(x)-1 + (exp(x)-1)/exp(x))/2
* = x + x^3/6 + o(x^5) * = x + x^3/6 + o(x^5)

View file

@ -37,7 +37,7 @@ asm(".include \"libc/disclaimer.inc\"");
/** /**
* Returns hyperbolic sine of 𝑥. * Returns hyperbolic sine of 𝑥.
* *
* sinh(x) = (exp(x) - 1/exp(x))/2 * sinh(x) = (exp(x) - 1/exp(x))/2
* = (exp(x)-1 + (exp(x)-1)/exp(x))/2 * = (exp(x)-1 + (exp(x)-1)/exp(x))/2
* = x + x^3/6 + o(x^5) * = x + x^3/6 + o(x^5)

View file

@ -75,7 +75,7 @@ kCombiningCharsLz4:
.byte 0x00,0xa0,0x57,0x00,0x50,0xfe,0x7f,0xdf # áW P .byte 0x00,0xa0,0x57,0x00,0x50,0xfe,0x7f,0xdf # áW P
.byte 0xe0,0xff,0x41,0x01,0x28,0x1f,0x40,0x2f #αλA(@/ .byte 0xe0,0xff,0x41,0x01,0x28,0x1f,0x40,0x2f #αλA(@/
.byte 0x00,0xff,0x00,0xe0,0xfd,0x66,0x00,0x00 # λ α²f   .byte 0x00,0xff,0x00,0xe0,0xfd,0x66,0x00,0x00 # λ α²f  
.byte 0x00,0xc3,0x01,0x00,0x1e,0x00,0x64,0x20 #   d .byte 0x00,0xc3,0x01,0x00,0x1e,0x00,0x64,0x20 #   d
.byte 0x00,0x20,0xcc,0x01,0x0b,0x0f,0xd2,0x01 #  .byte 0x00,0x20,0xcc,0x01,0x0b,0x0f,0xd2,0x01 # 
.byte 0x1d,0x06,0x66,0x00,0x1f,0x00,0x01,0x00 #f    .byte 0x1d,0x06,0x66,0x00,0x1f,0x00,0x01,0x00 #f   
.byte 0x62,0x13,0x1c,0x04,0x00,0x26,0x0c,0x00 #b &  .byte 0x62,0x13,0x1c,0x04,0x00,0x26,0x0c,0x00 #b & 
@ -110,7 +110,7 @@ kCombiningCharsLz4:
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ .byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
.byte 0xdb,0x1f,0x40,0x60,0x1f,0x4b,0x2f,0x00 #@`K/  .byte 0xdb,0x1f,0x40,0x60,0x1f,0x4b,0x2f,0x00 #@`K/ 
.byte 0x00,0x06,0x1a,0x08,0x1f,0x80,0x3f,0x00 # Ç  .byte 0x00,0x06,0x1a,0x08,0x1f,0x80,0x3f,0x00 # Ç 
.byte 0x0c,0x1f,0x0e,0x7f,0x00,0x2c,0x1f,0x20 # , .byte 0x0c,0x1f,0x0e,0x7f,0x00,0x2c,0x1f,0x20 # ,
.byte 0x1d,0x00,0x09,0x0e,0x3e,0x1c,0x2f,0xc0 # >/ .byte 0x1d,0x00,0x09,0x0e,0x3e,0x1c,0x2f,0xc0 # >/
.byte 0x07,0xdd,0x01,0xbd,0x22,0x6e,0xf0,0x23 #.n. .byte 0x07,0xdd,0x01,0xbd,0x22,0x6e,0xf0,0x23 #.n.
.byte 0x1e,0x0f,0x1c,0x00,0x01,0x1f,0x60,0x64 # `d .byte 0x1e,0x0f,0x1c,0x00,0x01,0x1f,0x60,0x64 # `d
@ -120,7 +120,7 @@ kCombiningCharsLz4:
.byte 0x01,0x00,0xf0,0x0c,0x33,0x80,0xef,0x1f # 3Ç .byte 0x01,0x00,0xf0,0x0c,0x33,0x80,0xef,0x1f # 3Ç
.byte 0x2e,0x00,0x13,0x08,0x52,0x0d,0x48,0xc0 #. RH .byte 0x2e,0x00,0x13,0x08,0x52,0x0d,0x48,0xc0 #. RH
.byte 0x7f,0x00,0x1e,0x66,0x02,0x1f,0xd3,0xe4 # fΣ .byte 0x7f,0x00,0x1e,0x66,0x02,0x1f,0xd3,0xe4 # fΣ
.byte 0x02,0x01,0x36,0x80,0xf8,0x07,0xc0,0x20 #6ǰ .byte 0x02,0x01,0x36,0x80,0xf8,0x07,0xc0,0x20 #6ǰ
.byte 0x00,0x7e,0x00,0x3f,0xc0,0x1f,0x1f,0xc7 # ~  .byte 0x00,0x7e,0x00,0x3f,0xc0,0x1f,0x1f,0xc7 # ~ 
.byte 0x02,0x06,0x19,0x5c,0x28,0x03,0x3f,0xf8 #\(° .byte 0x02,0x06,0x19,0x5c,0x28,0x03,0x3f,0xf8 #\(°
.byte 0x85,0x0d,0xb1,0x1c,0x0b,0x22,0xb0,0x01 #à. .byte 0x85,0x0d,0xb1,0x1c,0x0b,0x22,0xb0,0x01 #à.

View file

@ -524,9 +524,9 @@ TEST(ShowCrashReports, testBssOverrunCrash) {
// clang-format off // clang-format off
// asan error: null pointer dereference 1-byte load at 0x000000000000 shadow 0x00007fff8000 // asan error: null pointer dereference 1-byte load at 0x000000000000 shadow 0x00007fff8000
// x // x
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅ // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅∅
// |-17 |-17 |-17 |-17 |-17 |-1 |-1 |-1 |-1 |-1 // |-17 |-17 |-17 |-17 |-17 |-1 |-1 |-1 |-1 |-1
// ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ // ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
// 000000400000-000000464000 .text // 000000400000-000000464000 .text
// 000000464000-00000046d000 .data // 000000464000-00000046d000 .data

View file

@ -25,37 +25,37 @@ assert(not DecodeJson([[
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail16.json -- JSON parsing sample test case: fail16.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ \naked] [ \naked]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail17.json -- JSON parsing sample test case: fail17.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ "Illegal backslash escape: \017"] [ "Illegal backslash escape: \017"]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail22.json -- JSON parsing sample test case: fail22.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ "Colon instead of comma": false] [ "Colon instead of comma": false]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail23.json -- JSON parsing sample test case: fail23.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ "Bad value", truth] [ "Bad value", truth]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail24.json -- JSON parsing sample test case: fail24.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ 'single quote'] [ 'single quote']
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail29.json -- JSON parsing sample test case: fail29.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ 0e] [ 0e]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
@ -67,13 +67,13 @@ assert(not DecodeJson([[
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail30.json -- JSON parsing sample test case: fail30.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ 0e+] [ 0e+]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail31.json -- JSON parsing sample test case: fail31.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ 0e+-1] [ 0e+-1]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
@ -103,7 +103,7 @@ assert(not DecodeJson([[
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail8.json -- JSON parsing sample test case: fail8.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ "Extra close"] ] [ "Extra close"] ]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
@ -121,32 +121,32 @@ assert(not DecodeJson([[
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail26.json -- JSON parsing sample test case: fail26.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ "tab\ character\ in\ string\ "] [ "tab\ character\ in\ string\ "]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail28.json -- JSON parsing sample test case: fail28.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ "line\ [ "line\
break"] break"]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail4.json -- JSON parsing sample test case: fail4.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ "extra comma",] [ "extra comma",]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail5.json -- JSON parsing sample test case: fail5.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ "double extra comma",,] [ "double extra comma",,]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail6.json -- JSON parsing sample test case: fail6.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ , "<-- missing value"] [ , "<-- missing value"]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
@ -164,14 +164,14 @@ assert(not DecodeJson([[
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail25.json -- JSON parsing sample test case: fail25.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ " tab character in string "] [ " tab character in string "]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail27.json -- JSON parsing sample test case: fail27.json
assert(not DecodeJson([[ assert(not DecodeJson([[
[ "line [ "line
break"] break"]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip

View file

@ -1,7 +1,7 @@
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: pass1.json -- JSON parsing sample test case: pass1.json
assert(DecodeJson([[ assert(DecodeJson([[
[ [
"JSON Test Pattern pass1", "JSON Test Pattern pass1",
{"object with 1 member":[ "array with 1 element"] }, {"object with 1 member":[ "array with 1 element"] },
{}, {},
@ -58,13 +58,13 @@ assert(DecodeJson([[
0.1e1, 0.1e1,
1e-1, 1e-1,
1e00,2e+00,2e-00 1e00,2e+00,2e-00
,"rosebud"] ,"rosebud"]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: pass2.json -- JSON parsing sample test case: pass2.json
assert(DecodeJson([[ assert(DecodeJson([[
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Not too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Not too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]
]])) ]]))
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
@ -94,5 +94,5 @@ assert(DecodeJson([[
-- https://www.json.org/JSON_checker/test.zip -- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail18.json (actually passes) -- JSON parsing sample test case: fail18.json (actually passes)
assert(DecodeJson([[ assert(DecodeJson([[
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]
]])) ]]))

View file

@ -1,22 +1,22 @@
-- --
-- Nicolas Seriot's JSONTestSuite -- Nicolas Seriot's JSONTestSuite
-- https://github.com/nst/JSONTestSuite -- https://github.com/nst/JSONTestSuite
-- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82 -- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82
-- --
-- MIT License -- MIT License
-- --
-- Copyright (c) 2016 Nicolas Seriot -- Copyright (c) 2016 Nicolas Seriot
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a copy -- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal -- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights -- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is -- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions: -- furnished to do so, subject to the following conditions:
-- --
-- The above copyright notice and this permission notice shall be included in all -- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software. -- copies or substantial portions of the Software.
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -24,7 +24,7 @@
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE. -- SOFTWARE.
-- --
-- these test cases are prefixed with n_ -- these test cases are prefixed with n_
-- ljson should reject all of them as invalid -- ljson should reject all of them as invalid

View file

@ -1,22 +1,22 @@
-- --
-- Nicolas Seriot's JSONTestSuite -- Nicolas Seriot's JSONTestSuite
-- https://github.com/nst/JSONTestSuite -- https://github.com/nst/JSONTestSuite
-- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82 -- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82
-- --
-- MIT License -- MIT License
-- --
-- Copyright (c) 2016 Nicolas Seriot -- Copyright (c) 2016 Nicolas Seriot
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a copy -- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal -- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights -- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is -- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions: -- furnished to do so, subject to the following conditions:
-- --
-- The above copyright notice and this permission notice shall be included in all -- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software. -- copies or substantial portions of the Software.
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -24,7 +24,7 @@
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE. -- SOFTWARE.
-- --
-- these test cases are prefixed with n_ -- these test cases are prefixed with n_
-- ljson should reject all of them as invalid -- ljson should reject all of them as invalid

File diff suppressed because it is too large Load diff

View file

@ -1,22 +1,22 @@
-- --
-- Nicolas Seriot's JSONTestSuite -- Nicolas Seriot's JSONTestSuite
-- https://github.com/nst/JSONTestSuite -- https://github.com/nst/JSONTestSuite
-- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82 -- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82
-- --
-- MIT License -- MIT License
-- --
-- Copyright (c) 2016 Nicolas Seriot -- Copyright (c) 2016 Nicolas Seriot
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a copy -- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal -- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights -- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is -- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions: -- furnished to do so, subject to the following conditions:
-- --
-- The above copyright notice and this permission notice shall be included in all -- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software. -- copies or substantial portions of the Software.
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -24,7 +24,7 @@
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE. -- SOFTWARE.
-- --
-- these test cases are prefixed with n_ -- these test cases are prefixed with n_
-- ljson should reject all of them as invalid -- ljson should reject all of them as invalid

View file

@ -1,22 +1,22 @@
-- --
-- Nicolas Seriot's JSONTestSuite -- Nicolas Seriot's JSONTestSuite
-- https://github.com/nst/JSONTestSuite -- https://github.com/nst/JSONTestSuite
-- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82 -- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82
-- --
-- MIT License -- MIT License
-- --
-- Copyright (c) 2016 Nicolas Seriot -- Copyright (c) 2016 Nicolas Seriot
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a copy -- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal -- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights -- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is -- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions: -- furnished to do so, subject to the following conditions:
-- --
-- The above copyright notice and this permission notice shall be included in all -- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software. -- copies or substantial portions of the Software.
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -24,7 +24,7 @@
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE. -- SOFTWARE.
-- --
-- these test cases are prefixed with i_ -- these test cases are prefixed with i_
-- ljson is free to accept or reject, -- ljson is free to accept or reject,

View file

@ -1,22 +1,22 @@
-- --
-- Nicolas Seriot's JSONTestSuite -- Nicolas Seriot's JSONTestSuite
-- https://github.com/nst/JSONTestSuite -- https://github.com/nst/JSONTestSuite
-- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82 -- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82
-- --
-- MIT License -- MIT License
-- --
-- Copyright (c) 2016 Nicolas Seriot -- Copyright (c) 2016 Nicolas Seriot
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a copy -- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal -- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights -- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is -- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions: -- furnished to do so, subject to the following conditions:
-- --
-- The above copyright notice and this permission notice shall be included in all -- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software. -- copies or substantial portions of the Software.
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -24,7 +24,7 @@
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE. -- SOFTWARE.
-- --
-- these test cases are prefixed with y_ -- these test cases are prefixed with y_
-- ljson should accept all of them as valid -- ljson should accept all of them as valid

View file

@ -3,7 +3,7 @@ Argon2 reference source code package - reference C implementations
Copyright 2015 Copyright 2015
Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
You may use this work under the terms of a Creative Commons CC0 1.0 You may use this work under the terms of a Creative Commons CC0 1.0
License/Waiver or the Apache Public License 2.0, at your option. The terms of License/Waiver or the Apache Public License 2.0, at your option. The terms of
these licenses can be found at: these licenses can be found at:

View file

@ -5,7 +5,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -20,7 +20,7 @@ First version.
0.9.0a 0.9.0a
~~~~~~ ~~~~~~
Removed 'ranlib' from Makefile, since most modern Unix-es Removed 'ranlib' from Makefile, since most modern Unix-es
don't need it, or even know about it. don't need it, or even know about it.
@ -52,7 +52,7 @@ In bzlib.c:
bzBuffToBuffDecompress. Fixed. bzBuffToBuffDecompress. Fixed.
In compress.c: In compress.c:
* changed setting of nGroups in sendMTFValues() so as to * changed setting of nGroups in sendMTFValues() so as to
do a bit better on small files. This _does_ effect do a bit better on small files. This _does_ effect
bzip2.c. bzip2.c.
@ -117,7 +117,7 @@ changes are minor documentation changes.
Several minor bugfixes and enhancements: Several minor bugfixes and enhancements:
* Large file support. The library uses 64-bit counters to * Large file support. The library uses 64-bit counters to
count the volume of data passing through it. bzip2.c count the volume of data passing through it. bzip2.c
is now compiled with -D_FILE_OFFSET_BITS=64 to get large is now compiled with -D_FILE_OFFSET_BITS=64 to get large
file support from the C library. -v correctly prints out file support from the C library. -v correctly prints out
file sizes greater than 4 gigabytes. All these changes have file sizes greater than 4 gigabytes. All these changes have
@ -128,7 +128,7 @@ Several minor bugfixes and enhancements:
* Decompression robustness. The library/program should be * Decompression robustness. The library/program should be
robust to any corruption of compressed data, detecting and robust to any corruption of compressed data, detecting and
handling _all_ corruption, instead of merely relying on handling _all_ corruption, instead of merely relying on
the CRCs. What this means is that the program should the CRCs. What this means is that the program should
never crash, given corrupted data, and the library should never crash, given corrupted data, and the library should
always return BZ_DATA_ERROR. always return BZ_DATA_ERROR.
@ -140,13 +140,13 @@ Several minor bugfixes and enhancements:
* Don't run out of file handles on test/decompression when * Don't run out of file handles on test/decompression when
large numbers of files have invalid magic numbers. large numbers of files have invalid magic numbers.
* Avoid library namespace pollution. Prefix all exported * Avoid library namespace pollution. Prefix all exported
symbols with BZ2_. symbols with BZ2_.
* Minor sorting enhancements from my DCC2000 paper. * Minor sorting enhancements from my DCC2000 paper.
* Advance the version number to 1.0, so as to counteract the * Advance the version number to 1.0, so as to counteract the
(false-in-this-case) impression some people have that programs (false-in-this-case) impression some people have that programs
with version numbers less than 1.0 are in some way, experimental, with version numbers less than 1.0 are in some way, experimental,
pre-release versions. pre-release versions.
@ -156,10 +156,10 @@ Several minor bugfixes and enhancements:
* Make the program exit with 2 instead of 0 when decompression * Make the program exit with 2 instead of 0 when decompression
fails due to a bad magic number (ie, an invalid bzip2 header). fails due to a bad magic number (ie, an invalid bzip2 header).
Also exit with 1 (as the manual claims :-) whenever a diagnostic Also exit with 1 (as the manual claims :-) whenever a diagnostic
message would have been printed AND the corresponding operation message would have been printed AND the corresponding operation
is aborted, for example is aborted, for example
bzip2: Output file xx already exists. bzip2: Output file xx already exists.
When a diagnostic message is printed but the operation is not When a diagnostic message is printed but the operation is not
aborted, for example aborted, for example
bzip2: Can't guess original name for wurble -- using wurble.out bzip2: Can't guess original name for wurble -- using wurble.out
then the exit value 0 is returned, unless some other problem is then the exit value 0 is returned, unless some other problem is
@ -272,7 +272,7 @@ Fixes some minor bugs since the last version, 1.0.2.
* Further robustification against corrupted compressed data. * Further robustification against corrupted compressed data.
There are currently no known bitstreams which can cause the There are currently no known bitstreams which can cause the
decompressor to crash, loop or access memory which does not decompressor to crash, loop or access memory which does not
belong to it. If you are using bzip2 or the library to belong to it. If you are using bzip2 or the library to
decompress bitstreams from untrusted sources, an upgrade decompress bitstreams from untrusted sources, an upgrade
to 1.0.3 is recommended. This fixes CAN-2005-1260. to 1.0.3 is recommended. This fixes CAN-2005-1260.

View file

@ -12,16 +12,16 @@ are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented; you must 2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product software in a product, an acknowledgment in the product
documentation would be appreciated but is not required. documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must 3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software. not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote 4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written products derived from this software without specific prior written
permission. permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS

View file

@ -79,7 +79,7 @@ unmodified with MS Visual C. If you have difficulties building, you
might want to read README.COMPILATION.PROBLEMS. might want to read README.COMPILATION.PROBLEMS.
At least using MS Visual C++ 6, you can build from the unmodified At least using MS Visual C++ 6, you can build from the unmodified
sources by issuing, in a command shell: sources by issuing, in a command shell:
nmake -f makefile.msc nmake -f makefile.msc
@ -103,12 +103,12 @@ Please read and be aware of the following:
WARNING: WARNING:
This program and library (attempts to) compress data by This program and library (attempts to) compress data by
performing several non-trivial transformations on it. performing several non-trivial transformations on it.
Unless you are 100% familiar with *all* the algorithms Unless you are 100% familiar with *all* the algorithms
contained herein, and with the consequences of modifying them, contained herein, and with the consequences of modifying them,
you should NOT meddle with the compression or decompression you should NOT meddle with the compression or decompression
machinery. Incorrect changes can and very likely *will* machinery. Incorrect changes can and very likely *will*
lead to disastrous loss of data. lead to disastrous loss of data.
@ -128,16 +128,16 @@ DISCLAIMER:
PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER
SMALL, THAT THE DATA WILL NOT BE RECOVERABLE. SMALL, THAT THE DATA WILL NOT BE RECOVERABLE.
That is not to say this program is inherently unreliable. That is not to say this program is inherently unreliable.
Indeed, I very much hope the opposite is true. bzip2/libbzip2 Indeed, I very much hope the opposite is true. bzip2/libbzip2
has been carefully constructed and extensively tested. has been carefully constructed and extensively tested.
PATENTS: PATENTS:
To the best of my knowledge, bzip2/libbzip2 does not use any To the best of my knowledge, bzip2/libbzip2 does not use any
patented algorithms. However, I do not have the resources patented algorithms. However, I do not have the resources
to carry out a patent search. Therefore I cannot give any to carry out a patent search. Therefore I cannot give any
guarantee of the above statement. guarantee of the above statement.

View file

@ -12,7 +12,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -30,11 +30,11 @@
/*---------------------------------------------*/ /*---------------------------------------------*/
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
__inline__ __inline__
void fallbackSimpleSort ( UInt32* fmap, void fallbackSimpleSort ( UInt32* fmap,
UInt32* eclass, UInt32* eclass,
Int32 lo, Int32 lo,
Int32 hi ) Int32 hi )
{ {
Int32 i, j, tmp; Int32 i, j, tmp;
@ -93,9 +93,9 @@ void fallbackSimpleSort ( UInt32* fmap,
static static
void fallbackQSort3 ( UInt32* fmap, void fallbackQSort3 ( UInt32* fmap,
UInt32* eclass, UInt32* eclass,
Int32 loSt, Int32 loSt,
Int32 hiSt ) Int32 hiSt )
{ {
Int32 unLo, unHi, ltLo, gtHi, n, m; Int32 unLo, unHi, ltLo, gtHi, n, m;
@ -120,9 +120,9 @@ void fallbackQSort3 ( UInt32* fmap,
} }
/* Random partitioning. Median of 3 sometimes fails to /* Random partitioning. Median of 3 sometimes fails to
avoid bad cases. Median of 9 seems to help but avoid bad cases. Median of 9 seems to help but
looks rather expensive. This too seems to work but looks rather expensive. This too seems to work but
is cheaper. Guidance for the magic constants is cheaper. Guidance for the magic constants
7621 and 32768 is taken from Sedgewick's algorithms 7621 and 32768 is taken from Sedgewick's algorithms
book, chapter 35. book, chapter 35.
*/ */
@ -139,10 +139,10 @@ void fallbackQSort3 ( UInt32* fmap,
while (1) { while (1) {
if (unLo > unHi) break; if (unLo > unHi) break;
n = (Int32)eclass[fmap[unLo]] - (Int32)med; n = (Int32)eclass[fmap[unLo]] - (Int32)med;
if (n == 0) { if (n == 0) {
fswap(fmap[unLo], fmap[ltLo]); fswap(fmap[unLo], fmap[ltLo]);
ltLo++; unLo++; ltLo++; unLo++;
continue; continue;
}; };
if (n > 0) break; if (n > 0) break;
unLo++; unLo++;
@ -150,10 +150,10 @@ void fallbackQSort3 ( UInt32* fmap,
while (1) { while (1) {
if (unLo > unHi) break; if (unLo > unHi) break;
n = (Int32)eclass[fmap[unHi]] - (Int32)med; n = (Int32)eclass[fmap[unHi]] - (Int32)med;
if (n == 0) { if (n == 0) {
fswap(fmap[unHi], fmap[gtHi]); fswap(fmap[unHi], fmap[gtHi]);
gtHi--; unHi--; gtHi--; unHi--;
continue; continue;
}; };
if (n < 0) break; if (n < 0) break;
unHi--; unHi--;
@ -212,8 +212,8 @@ void fallbackQSort3 ( UInt32* fmap,
#define UNALIGNED_BH(zz) ((zz) & 0x01f) #define UNALIGNED_BH(zz) ((zz) & 0x01f)
static static
void fallbackSort ( UInt32* fmap, void fallbackSort ( UInt32* fmap,
UInt32* eclass, UInt32* eclass,
UInt32* bhtab, UInt32* bhtab,
Int32 nblock, Int32 nblock,
Int32 verb ) Int32 verb )
@ -254,7 +254,7 @@ void fallbackSort ( UInt32* fmap,
--*/ --*/
/*-- set sentinel bits for block-end detection --*/ /*-- set sentinel bits for block-end detection --*/
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
SET_BH(nblock + 2*i); SET_BH(nblock + 2*i);
CLEAR_BH(nblock + 2*i + 1); CLEAR_BH(nblock + 2*i + 1);
} }
@ -263,7 +263,7 @@ void fallbackSort ( UInt32* fmap,
H = 1; H = 1;
while (1) { while (1) {
if (verb >= 4) if (verb >= 4)
VPrintf1 ( " depth %6d has ", H ); VPrintf1 ( " depth %6d has ", H );
j = 0; j = 0;
@ -308,14 +308,14 @@ void fallbackSort ( UInt32* fmap,
} }
} }
if (verb >= 4) if (verb >= 4)
VPrintf1 ( "%6d unresolved strings\n", nNotDone ); VPrintf1 ( "%6d unresolved strings\n", nNotDone );
H *= 2; H *= 2;
if (H > nblock || nNotDone == 0) break; if (H > nblock || nNotDone == 0) break;
} }
/*-- /*--
Reconstruct the original block in Reconstruct the original block in
eclass8 [0 .. nblock-1], since the eclass8 [0 .. nblock-1], since the
previous phase destroyed it. previous phase destroyed it.
@ -347,9 +347,9 @@ void fallbackSort ( UInt32* fmap,
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
__inline__ __inline__
Bool mainGtU ( UInt32 i1, Bool mainGtU ( UInt32 i1,
UInt32 i2, UInt32 i2,
UChar* block, UChar* block,
UInt16* quadrant, UInt16* quadrant,
UInt32 nblock, UInt32 nblock,
Int32* budget ) Int32* budget )
@ -489,8 +489,8 @@ void mainSimpleSort ( UInt32* ptr,
UChar* block, UChar* block,
UInt16* quadrant, UInt16* quadrant,
Int32 nblock, Int32 nblock,
Int32 lo, Int32 lo,
Int32 hi, Int32 hi,
Int32 d, Int32 d,
Int32* budget ) Int32* budget )
{ {
@ -514,8 +514,8 @@ void mainSimpleSort ( UInt32* ptr,
if (i > hi) break; if (i > hi) break;
v = ptr[i]; v = ptr[i];
j = i; j = i;
while ( mainGtU ( while ( mainGtU (
ptr[j-h]+d, v+d, block, quadrant, nblock, budget ptr[j-h]+d, v+d, block, quadrant, nblock, budget
) ) { ) ) {
ptr[j] = ptr[j-h]; ptr[j] = ptr[j-h];
j = j - h; j = j - h;
@ -528,8 +528,8 @@ void mainSimpleSort ( UInt32* ptr,
if (i > hi) break; if (i > hi) break;
v = ptr[i]; v = ptr[i];
j = i; j = i;
while ( mainGtU ( while ( mainGtU (
ptr[j-h]+d, v+d, block, quadrant, nblock, budget ptr[j-h]+d, v+d, block, quadrant, nblock, budget
) ) { ) ) {
ptr[j] = ptr[j-h]; ptr[j] = ptr[j-h];
j = j - h; j = j - h;
@ -542,8 +542,8 @@ void mainSimpleSort ( UInt32* ptr,
if (i > hi) break; if (i > hi) break;
v = ptr[i]; v = ptr[i];
j = i; j = i;
while ( mainGtU ( while ( mainGtU (
ptr[j-h]+d, v+d, block, quadrant, nblock, budget ptr[j-h]+d, v+d, block, quadrant, nblock, budget
) ) { ) ) {
ptr[j] = ptr[j-h]; ptr[j] = ptr[j-h];
j = j - h; j = j - h;
@ -581,13 +581,13 @@ void mainSimpleSort ( UInt32* ptr,
} \ } \
} }
static static
__inline__ __inline__
UChar mmed3 ( UChar a, UChar b, UChar c ) UChar mmed3 ( UChar a, UChar b, UChar c )
{ {
UChar t; UChar t;
if (a > b) { t = a; a = b; b = t; }; if (a > b) { t = a; a = b; b = t; };
if (b > c) { if (b > c) {
b = c; b = c;
if (a > b) b = a; if (a > b) b = a;
} }
@ -625,8 +625,8 @@ void mainQSort3 ( UInt32* ptr,
UChar* block, UChar* block,
UInt16* quadrant, UInt16* quadrant,
Int32 nblock, Int32 nblock,
Int32 loSt, Int32 loSt,
Int32 hiSt, Int32 hiSt,
Int32 dSt, Int32 dSt,
Int32* budget ) Int32* budget )
{ {
@ -649,14 +649,14 @@ void mainQSort3 ( UInt32* ptr,
AssertH ( sp < MAIN_QSORT_STACK_SIZE - 2, 1001 ); AssertH ( sp < MAIN_QSORT_STACK_SIZE - 2, 1001 );
mpop ( lo, hi, d ); mpop ( lo, hi, d );
if (hi - lo < MAIN_QSORT_SMALL_THRESH || if (hi - lo < MAIN_QSORT_SMALL_THRESH ||
d > MAIN_QSORT_DEPTH_THRESH) { d > MAIN_QSORT_DEPTH_THRESH) {
mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget ); mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget );
if (*budget < 0) return; if (*budget < 0) return;
continue; continue;
} }
med = (Int32) med = (Int32)
mmed3 ( block[ptr[ lo ]+d], mmed3 ( block[ptr[ lo ]+d],
block[ptr[ hi ]+d], block[ptr[ hi ]+d],
block[ptr[ (lo+hi)>>1 ]+d] ); block[ptr[ (lo+hi)>>1 ]+d] );
@ -668,9 +668,9 @@ void mainQSort3 ( UInt32* ptr,
while (True) { while (True) {
if (unLo > unHi) break; if (unLo > unHi) break;
n = ((Int32)block[ptr[unLo]+d]) - med; n = ((Int32)block[ptr[unLo]+d]) - med;
if (n == 0) { if (n == 0) {
mswap(ptr[unLo], ptr[ltLo]); mswap(ptr[unLo], ptr[ltLo]);
ltLo++; unLo++; continue; ltLo++; unLo++; continue;
}; };
if (n > 0) break; if (n > 0) break;
unLo++; unLo++;
@ -678,9 +678,9 @@ void mainQSort3 ( UInt32* ptr,
while (True) { while (True) {
if (unLo > unHi) break; if (unLo > unHi) break;
n = ((Int32)block[ptr[unHi]+d]) - med; n = ((Int32)block[ptr[unHi]+d]) - med;
if (n == 0) { if (n == 0) {
mswap(ptr[unHi], ptr[gtHi]); mswap(ptr[unHi], ptr[gtHi]);
gtHi--; unHi--; continue; gtHi--; unHi--; continue;
}; };
if (n < 0) break; if (n < 0) break;
unHi--; unHi--;
@ -751,9 +751,9 @@ void mainQSort3 ( UInt32* ptr,
#define CLEARMASK (~(SETMASK)) #define CLEARMASK (~(SETMASK))
static static
void mainSort ( UInt32* ptr, void mainSort ( UInt32* ptr,
UChar* block, UChar* block,
UInt16* quadrant, UInt16* quadrant,
UInt32* ftab, UInt32* ftab,
Int32 nblock, Int32 nblock,
Int32 verb, Int32 verb,
@ -881,7 +881,7 @@ void mainSort ( UInt32* ptr,
/*-- /*--
Step 1: Step 1:
Complete the big bucket [ss] by quicksorting Complete the big bucket [ss] by quicksorting
any unsorted small buckets [ss, j], for j != ss. any unsorted small buckets [ss, j], for j != ss.
Hopefully previous pointer-scanning phases have already Hopefully previous pointer-scanning phases have already
completed many of the small buckets [ss, j], so completed many of the small buckets [ss, j], so
we don't have to sort them at all. we don't have to sort them at all.
@ -897,10 +897,10 @@ void mainSort ( UInt32* ptr,
VPrintf4 ( " qsort [0x%x, 0x%x] " VPrintf4 ( " qsort [0x%x, 0x%x] "
"done %d this %d\n", "done %d this %d\n",
ss, j, numQSorted, hi - lo + 1 ); ss, j, numQSorted, hi - lo + 1 );
mainQSort3 ( mainQSort3 (
ptr, block, quadrant, nblock, ptr, block, quadrant, nblock,
lo, hi, BZ_N_RADIX, budget lo, hi, BZ_N_RADIX, budget
); );
numQSorted += (hi - lo + 1); numQSorted += (hi - lo + 1);
if (*budget < 0) return; if (*budget < 0) return;
} }
@ -932,16 +932,16 @@ void mainSort ( UInt32* ptr,
for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) { for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) {
k = ptr[j]-1; if (k < 0) k += nblock; k = ptr[j]-1; if (k < 0) k += nblock;
c1 = block[k]; c1 = block[k];
if (!bigDone[c1]) if (!bigDone[c1])
ptr[ copyEnd[c1]-- ] = k; ptr[ copyEnd[c1]-- ] = k;
} }
} }
AssertH ( (copyStart[ss]-1 == copyEnd[ss]) AssertH ( (copyStart[ss]-1 == copyEnd[ss])
|| ||
/* Extremely rare case missing in bzip2-1.0.0 and 1.0.1. /* Extremely rare case missing in bzip2-1.0.0 and 1.0.1.
Necessity for this case is demonstrated by compressing Necessity for this case is demonstrated by compressing
a sequence of approximately 48.5 million of character a sequence of approximately 48.5 million of character
251; 1.0.0/1.0.1 will then die here. */ 251; 1.0.0/1.0.1 will then die here. */
(copyStart[ss] == 0 && copyEnd[ss] == nblock-1), (copyStart[ss] == 0 && copyEnd[ss] == nblock-1),
1007 ) 1007 )
@ -958,7 +958,7 @@ void mainSort ( UInt32* ptr,
updating for the last bucket is pointless. updating for the last bucket is pointless.
The quadrant array provides a way to incrementally The quadrant array provides a way to incrementally
cache sort orderings, as they appear, so as to cache sort orderings, as they appear, so as to
make subsequent comparisons in fullGtU() complete make subsequent comparisons in fullGtU() complete
faster. For repetitive blocks this makes a big faster. For repetitive blocks this makes a big
difference (but not big enough to be able to avoid difference (but not big enough to be able to avoid
@ -968,9 +968,9 @@ void mainSort ( UInt32* ptr,
for 0 <= i < nblock and 0 <= j <= nblock for 0 <= i < nblock and 0 <= j <= nblock
if block[i] != block[j], if block[i] != block[j],
then the relative values of quadrant[i] and then the relative values of quadrant[i] and
quadrant[j] are meaningless. quadrant[j] are meaningless.
else { else {
@ -1033,7 +1033,7 @@ void mainSort ( UInt32* ptr,
*/ */
void BZ2_blockSort ( EState* s ) void BZ2_blockSort ( EState* s )
{ {
UInt32* ptr = s->ptr; UInt32* ptr = s->ptr;
UChar* block = s->block; UChar* block = s->block;
UInt32* ftab = s->ftab; UInt32* ftab = s->ftab;
Int32 nblock = s->nblock; Int32 nblock = s->nblock;
@ -1057,8 +1057,8 @@ void BZ2_blockSort ( EState* s )
quadrant = (UInt16*)(&(block[i])); quadrant = (UInt16*)(&(block[i]));
/* (wfact-1) / 3 puts the default-factor-30 /* (wfact-1) / 3 puts the default-factor-30
transition point at very roughly the same place as transition point at very roughly the same place as
with v0.1 and v0.9.0. with v0.1 and v0.9.0.
Not that it particularly matters any more, since the Not that it particularly matters any more, since the
resulting compressed stream is now the same regardless resulting compressed stream is now the same regardless
of whether or not we use the main sort or fallback sort. of whether or not we use the main sort or fallback sort.
@ -1069,14 +1069,14 @@ void BZ2_blockSort ( EState* s )
budget = budgetInit; budget = budgetInit;
mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget ); mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget );
if (verb >= 3) if (verb >= 3)
VPrintf3 ( " %d work, %d block, ratio %5.2f\n", VPrintf3 ( " %d work, %d block, ratio %5.2f\n",
budgetInit - budget, budgetInit - budget,
nblock, nblock,
(float)(budgetInit - budget) / (float)(budgetInit - budget) /
(float)(nblock==0 ? 1 : nblock) ); (float)(nblock==0 ? 1 : nblock) );
if (budget < 0) { if (budget < 0) {
if (verb >= 2) if (verb >= 2)
VPrintf0 ( " too repetitive; using fallback" VPrintf0 ( " too repetitive; using fallback"
" sorting algorithm\n" ); " sorting algorithm\n" );
fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
# Bzcmp/diff wrapped for bzip2, # Bzcmp/diff wrapped for bzip2,
# adapted from zdiff by Philippe Troin <phil@fifi.org> for Debian GNU/Linux. # adapted from zdiff by Philippe Troin <phil@fifi.org> for Debian GNU/Linux.
# Bzcmp and bzdiff are used to invoke the cmp or the diff pro- # Bzcmp and bzdiff are used to invoke the cmp or the diff pro-

View file

@ -13,7 +13,7 @@ bzcmp, bzdiff \- compare bzip2 compressed files
[ file2 ] [ file2 ]
.SH DESCRIPTION .SH DESCRIPTION
.I Bzcmp .I Bzcmp
and and
.I bzdiff .I bzdiff
are used to invoke the are used to invoke the
.I cmp .I cmp
@ -32,7 +32,7 @@ If two files are specified, then they are uncompressed if necessary and fed to
.I cmp .I cmp
or or
.IR diff "." .IR diff "."
The exit status from The exit status from
.I cmp .I cmp
or or
.I diff .I diff

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# Bzgrep wrapped for bzip2, # Bzgrep wrapped for bzip2,
# adapted from zgrep by Philippe Troin <phil@fifi.org> for Debian GNU/Linux. # adapted from zgrep by Philippe Troin <phil@fifi.org> for Debian GNU/Linux.
## zgrep notice: ## zgrep notice:
## zgrep -- a wrapper around a grep program that decompresses files as needed ## zgrep -- a wrapper around a grep program that decompresses files as needed

View file

@ -18,13 +18,13 @@ bzip2recover \- recovers data from damaged bzip2 files
.br .br
.B bunzip2 .B bunzip2
.RB [ " \-fkvsVL " ] .RB [ " \-fkvsVL " ]
[ [
.I "filenames \&..." .I "filenames \&..."
] ]
.br .br
.B bzcat .B bzcat
.RB [ " \-s " ] .RB [ " \-s " ]
[ [
.I "filenames \&..." .I "filenames \&..."
] ]
.br .br
@ -39,15 +39,15 @@ generally considerably better than that achieved by more conventional
LZ77/LZ78-based compressors, and approaches the performance of the PPM LZ77/LZ78-based compressors, and approaches the performance of the PPM
family of statistical compressors. family of statistical compressors.
The command-line options are deliberately very similar to The command-line options are deliberately very similar to
those of those of
.I GNU gzip, .I GNU gzip,
but they are not identical. but they are not identical.
.I bzip2 .I bzip2
expects a list of file names to accompany the expects a list of file names to accompany the
command-line flags. Each file is replaced by a compressed version of command-line flags. Each file is replaced by a compressed version of
itself, with the name "original_name.bz2". itself, with the name "original_name.bz2".
Each compressed file Each compressed file
has the same modification date, permissions, and, when possible, has the same modification date, permissions, and, when possible,
ownership as the corresponding original, so that these properties can ownership as the corresponding original, so that these properties can
@ -74,13 +74,13 @@ incomprehensible and therefore pointless.
.I bunzip2 .I bunzip2
(or (or
.I bzip2 \-d) .I bzip2 \-d)
decompresses all decompresses all
specified files. Files which were not created by specified files. Files which were not created by
.I bzip2 .I bzip2
will be detected and ignored, and a warning issued. will be detected and ignored, and a warning issued.
.I bzip2 .I bzip2
attempts to guess the filename for the decompressed file attempts to guess the filename for the decompressed file
from that of the compressed file as follows: from that of the compressed file as follows:
filename.bz2 becomes filename filename.bz2 becomes filename
@ -89,13 +89,13 @@ from that of the compressed file as follows:
filename.tbz becomes filename.tar filename.tbz becomes filename.tar
anyothername becomes anyothername.out anyothername becomes anyothername.out
If the file does not end in one of the recognised endings, If the file does not end in one of the recognised endings,
.I .bz2, .I .bz2,
.I .bz, .I .bz,
.I .tbz2 .I .tbz2
or or
.I .tbz, .I .tbz,
.I bzip2 .I bzip2
complains that it cannot complains that it cannot
guess the name of the original file, and uses the original name guess the name of the original file, and uses the original name
with with
@ -103,25 +103,25 @@ with
appended. appended.
As with compression, supplying no As with compression, supplying no
filenames causes decompression from filenames causes decompression from
standard input to standard output. standard input to standard output.
.I bunzip2 .I bunzip2
will correctly decompress a file which is the will correctly decompress a file which is the
concatenation of two or more compressed files. The result is the concatenation of two or more compressed files. The result is the
concatenation of the corresponding uncompressed files. Integrity concatenation of the corresponding uncompressed files. Integrity
testing (\-t) testing (\-t)
of concatenated of concatenated
compressed files is also supported. compressed files is also supported.
You can also compress or decompress files to the standard output by You can also compress or decompress files to the standard output by
giving the \-c flag. Multiple files may be compressed and giving the \-c flag. Multiple files may be compressed and
decompressed like this. The resulting outputs are fed sequentially to decompressed like this. The resulting outputs are fed sequentially to
stdout. Compression of multiple files stdout. Compression of multiple files
in this manner generates a stream in this manner generates a stream
containing multiple compressed file representations. Such a stream containing multiple compressed file representations. Such a stream
can be decompressed correctly only by can be decompressed correctly only by
.I bzip2 .I bzip2
version 0.9.0 or version 0.9.0 or
later. Earlier versions of later. Earlier versions of
.I bzip2 .I bzip2
@ -130,7 +130,7 @@ the first file in the stream.
.I bzcat .I bzcat
(or (or
.I bzip2 -dc) .I bzip2 -dc)
decompresses all specified files to decompresses all specified files to
the standard output. the standard output.
@ -140,10 +140,10 @@ will read arguments from the environment variables
and and
.I BZIP, .I BZIP,
in that order, and will process them in that order, and will process them
before any arguments read from the command line. This gives a before any arguments read from the command line. This gives a
convenient way to supply default arguments. convenient way to supply default arguments.
Compression is always performed, even if the compressed Compression is always performed, even if the compressed
file is slightly file is slightly
larger than the original. Files of less than about one hundred bytes larger than the original. Files of less than about one hundred bytes
tend to get larger, since the compression mechanism has a constant tend to get larger, since the compression mechanism has a constant
@ -151,8 +151,8 @@ overhead in the region of 50 bytes. Random data (including the output
of most file compressors) is coded at about 8.05 bits per byte, giving of most file compressors) is coded at about 8.05 bits per byte, giving
an expansion of around 0.5%. an expansion of around 0.5%.
As a self-check for your protection, As a self-check for your protection,
.I .I
bzip2 bzip2
uses 32-bit CRCs to uses 32-bit CRCs to
make sure that the decompressed version of a file is identical to the make sure that the decompressed version of a file is identical to the
@ -163,9 +163,9 @@ against undetected bugs in
chances of data corruption going undetected is microscopic, about one chances of data corruption going undetected is microscopic, about one
chance in four billion for each file processed. Be aware, though, that chance in four billion for each file processed. Be aware, though, that
the check occurs upon decompression, so it can only tell you that the check occurs upon decompression, so it can only tell you that
something is wrong. It can't help you something is wrong. It can't help you
recover the original uncompressed recover the original uncompressed
data. You can use data. You can use
.I bzip2recover .I bzip2recover
to try to recover data from to try to recover data from
damaged files. damaged files.
@ -183,15 +183,15 @@ to panic.
Compress or decompress to standard output. Compress or decompress to standard output.
.TP .TP
.B \-d --decompress .B \-d --decompress
Force decompression. Force decompression.
.I bzip2, .I bzip2,
.I bunzip2 .I bunzip2
and and
.I bzcat .I bzcat
are are
really the same program, and the decision about what actions to take is really the same program, and the decision about what actions to take is
done on the basis of which name is used. This flag overrides that done on the basis of which name is used. This flag overrides that
mechanism, and forces mechanism, and forces
.I bzip2 .I bzip2
to decompress. to decompress.
.TP .TP
@ -205,10 +205,10 @@ This really performs a trial decompression and throws away the result.
.TP .TP
.B \-f --force .B \-f --force
Force overwrite of output files. Normally, Force overwrite of output files. Normally,
.I bzip2 .I bzip2
will not overwrite will not overwrite
existing output files. Also forces existing output files. Also forces
.I bzip2 .I bzip2
to break hard links to break hard links
to files, which it otherwise wouldn't do. to files, which it otherwise wouldn't do.
@ -246,9 +246,9 @@ Display the software version, license terms and conditions.
.B \-1 (or \-\-fast) to \-9 (or \-\-best) .B \-1 (or \-\-fast) to \-9 (or \-\-best)
Set the block size to 100 k, 200 k .. 900 k when compressing. Has no Set the block size to 100 k, 200 k .. 900 k when compressing. Has no
effect when decompressing. See MEMORY MANAGEMENT below. effect when decompressing. See MEMORY MANAGEMENT below.
The \-\-fast and \-\-best aliases are primarily for GNU gzip The \-\-fast and \-\-best aliases are primarily for GNU gzip
compatibility. In particular, \-\-fast doesn't make things compatibility. In particular, \-\-fast doesn't make things
significantly faster. significantly faster.
And \-\-best merely selects the default behaviour. And \-\-best merely selects the default behaviour.
.TP .TP
.B \-- .B \--
@ -263,7 +263,7 @@ earlier versions, which was sometimes useful. 0.9.5 and above have an
improved algorithm which renders these flags irrelevant. improved algorithm which renders these flags irrelevant.
.SH MEMORY MANAGEMENT .SH MEMORY MANAGEMENT
.I bzip2 .I bzip2
compresses large files in blocks. The block size affects compresses large files in blocks. The block size affects
both the compression ratio achieved, and the amount of memory needed for both the compression ratio achieved, and the amount of memory needed for
compression and decompression. The flags \-1 through \-9 compression and decompression. The flags \-1 through \-9
@ -276,7 +276,7 @@ the file. Since block sizes are stored in compressed files, it follows
that the flags \-1 to \-9 are irrelevant to and so ignored that the flags \-1 to \-9 are irrelevant to and so ignored
during decompression. during decompression.
Compression and decompression requirements, Compression and decompression requirements,
in bytes, can be estimated as: in bytes, can be estimated as:
Compression: 400k + ( 8 x block size ) Compression: 400k + ( 8 x block size )
@ -295,7 +295,7 @@ requirement is set at compression time by the choice of block size.
For files compressed with the default 900k block size, For files compressed with the default 900k block size,
.I bunzip2 .I bunzip2
will require about 3700 kbytes to decompress. To support decompression will require about 3700 kbytes to decompress. To support decompression
of any file on a 4 megabyte machine, of any file on a 4 megabyte machine,
.I bunzip2 .I bunzip2
has an option to has an option to
decompress using approximately half this amount of memory, about 2300 decompress using approximately half this amount of memory, about 2300
@ -350,20 +350,20 @@ damaged blocks can be distinguished from undamaged ones.
.I bzip2recover .I bzip2recover
is a simple program whose purpose is to search for is a simple program whose purpose is to search for
blocks in .bz2 files, and write each block out into its own .bz2 blocks in .bz2 files, and write each block out into its own .bz2
file. You can then use file. You can then use
.I bzip2 .I bzip2
\-t \-t
to test the to test the
integrity of the resulting files, and decompress those which are integrity of the resulting files, and decompress those which are
undamaged. undamaged.
.I bzip2recover .I bzip2recover
takes a single argument, the name of the damaged file, takes a single argument, the name of the damaged file,
and writes a number of files "rec00001file.bz2", and writes a number of files "rec00001file.bz2",
"rec00002file.bz2", etc, containing the extracted blocks. "rec00002file.bz2", etc, containing the extracted blocks.
The output filenames are designed so that the use of The output filenames are designed so that the use of
wildcards in subsequent processing -- for example, wildcards in subsequent processing -- for example,
"bzip2 -dc rec*file.bz2 > recovered_data" -- processes the files in "bzip2 -dc rec*file.bz2 > recovered_data" -- processes the files in
the correct order. the correct order.
@ -371,8 +371,8 @@ the correct order.
should be of most use dealing with large .bz2 should be of most use dealing with large .bz2
files, as these will contain many blocks. It is clearly files, as these will contain many blocks. It is clearly
futile to use it on damaged single-block files, since a futile to use it on damaged single-block files, since a
damaged block cannot be recovered. If you wish to minimise damaged block cannot be recovered. If you wish to minimise
any potential data loss through media or transmission errors, any potential data loss through media or transmission errors,
you might consider compressing with a smaller you might consider compressing with a smaller
block size. block size.
@ -395,7 +395,7 @@ that performance, both for compressing and decompressing, is largely
determined by the speed at which your machine can service cache misses. determined by the speed at which your machine can service cache misses.
Because of this, small changes to the code to reduce the miss rate have Because of this, small changes to the code to reduce the miss rate have
been observed to give disproportionately large performance improvements. been observed to give disproportionately large performance improvements.
I imagine I imagine
.I bzip2 .I bzip2
will perform best on machines with very large caches. will perform best on machines with very large caches.
@ -406,7 +406,7 @@ tries hard to detect I/O errors and exit cleanly, but the details of
what the problem is sometimes seem rather misleading. what the problem is sometimes seem rather misleading.
This manual page pertains to version 1.0.8 of This manual page pertains to version 1.0.8 of
.I bzip2. .I bzip2.
Compressed data created by this version is entirely forwards and Compressed data created by this version is entirely forwards and
backwards compatible with the previous public releases, versions backwards compatible with the previous public releases, versions
0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, 1.0.2 and above, but with the following 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, 1.0.2 and above, but with the following
@ -440,13 +440,13 @@ Fenwick (for the structured coding model in the original
.I bzip, .I bzip,
and many refinements), and Alistair Moffat, Radford Neal and Ian Witten and many refinements), and Alistair Moffat, Radford Neal and Ian Witten
(for the arithmetic coder in the original (for the arithmetic coder in the original
.I bzip). .I bzip).
I am much I am much
indebted for their help, support and advice. See the manual in the indebted for their help, support and advice. See the manual in the
source distribution for pointers to sources of documentation. Christian source distribution for pointers to sources of documentation. Christian
von Roques encouraged me to look for faster sorting algorithms, so as to von Roques encouraged me to look for faster sorting algorithms, so as to
speed up compression. Bela Lubkin encouraged me to improve the speed up compression. Bela Lubkin encouraged me to improve the
worst-case compression performance. worst-case compression performance.
Donna Robinson XMLised the documentation. Donna Robinson XMLised the documentation.
The bz* scripts are derived from those of GNU gzip. The bz* scripts are derived from those of GNU gzip.
Many people sent patches, helped Many people sent patches, helped

View file

@ -351,10 +351,10 @@ bzip2(1) bzip2(1)
This manual page pertains to version 1.0.8 of b̲z̲i̲p̲2̲.̲ Com- This manual page pertains to version 1.0.8 of b̲z̲i̲p̲2̲.̲ Com-
pressed data created by this version is entirely forwards pressed data created by this version is entirely forwards
and backwards compatible with the previous public and backwards compatible with the previous public
releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1,
1.0.2 and above, but with the following exception: 0.9.0 1.0.2 and above, but with the following exception: 0.9.0
and above can correctly decompress multiple concatenated and above can correctly decompress multiple concatenated
compressed files. 0.1pl2 cannot do this; it will stop compressed files. 0.1pl2 cannot do this; it will stop
after decompressing just the first file in the stream. after decompressing just the first file in the stream.
b̲z̲i̲p̲2̲r̲e̲c̲o̲v̲e̲r̲ versions prior to 1.0.2 used 32-bit integers b̲z̲i̲p̲2̲r̲e̲c̲o̲v̲e̲r̲ versions prior to 1.0.2 used 32-bit integers

View file

@ -27,7 +27,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -76,7 +76,7 @@ typedef int Int32;
typedef unsigned int UInt32; typedef unsigned int UInt32;
typedef short Int16; typedef short Int16;
typedef unsigned short UInt16; typedef unsigned short UInt16;
#define True ((Bool)1) #define True ((Bool)1)
#define False ((Bool)0) #define False ((Bool)0)
@ -141,7 +141,7 @@ static void applySavedFileAttrToOutputFile ( IntNative fd );
/*---------------------------------------------------*/ /*---------------------------------------------------*/
typedef typedef
struct { UChar b[8]; } struct { UChar b[8]; }
UInt64; UInt64;
@ -184,7 +184,7 @@ Bool uInt64_isZero ( UInt64* n )
/* Divide *n by 10, and return the remainder. */ /* Divide *n by 10, and return the remainder. */
static static
Int32 uInt64_qrm10 ( UInt64* n ) Int32 uInt64_qrm10 ( UInt64* n )
{ {
UInt32 rem, tmp; UInt32 rem, tmp;
@ -215,7 +215,7 @@ void uInt64_toAscii ( char* outbuf, UInt64* n )
nBuf++; nBuf++;
} while (!uInt64_isZero(&n_copy)); } while (!uInt64_isZero(&n_copy));
outbuf[nBuf] = 0; outbuf[nBuf] = 0;
for (i = 0; i < nBuf; i++) for (i = 0; i < nBuf; i++)
outbuf[i] = buf[nBuf-i-1]; outbuf[i] = buf[nBuf-i-1];
} }
@ -225,7 +225,7 @@ void uInt64_toAscii ( char* outbuf, UInt64* n )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
Bool myfeof ( FILE* f ) Bool myfeof ( FILE* f )
{ {
Int32 c = fgetc ( f ); Int32 c = fgetc ( f );
@ -236,7 +236,7 @@ Bool myfeof ( FILE* f )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void compressStream ( FILE *stream, FILE *zStream ) void compressStream ( FILE *stream, FILE *zStream )
{ {
BZFILE* bzf = NULL; BZFILE* bzf = NULL;
@ -252,8 +252,8 @@ void compressStream ( FILE *stream, FILE *zStream )
if (ferror(stream)) goto errhandler_io; if (ferror(stream)) goto errhandler_io;
if (ferror(zStream)) goto errhandler_io; if (ferror(zStream)) goto errhandler_io;
bzf = BZ2_bzWriteOpen ( &bzerr, zStream, bzf = BZ2_bzWriteOpen ( &bzerr, zStream,
blockSize100k, verbosity, workFactor ); blockSize100k, verbosity, workFactor );
if (bzerr != BZ_OK) goto errhandler; if (bzerr != BZ_OK) goto errhandler;
if (verbosity >= 2) (fprintf) ( stderr, "\n" ); if (verbosity >= 2) (fprintf) ( stderr, "\n" );
@ -268,7 +268,7 @@ void compressStream ( FILE *stream, FILE *zStream )
} }
BZ2_bzWriteClose64 ( &bzerr, bzf, 0, BZ2_bzWriteClose64 ( &bzerr, bzf, 0,
&nbytes_in_lo32, &nbytes_in_hi32, &nbytes_in_lo32, &nbytes_in_hi32,
&nbytes_out_lo32, &nbytes_out_hi32 ); &nbytes_out_lo32, &nbytes_out_hi32 );
if (bzerr != BZ_OK) goto errhandler; if (bzerr != BZ_OK) goto errhandler;
@ -296,9 +296,9 @@ void compressStream ( FILE *stream, FILE *zStream )
Char buf_nin[32], buf_nout[32]; Char buf_nin[32], buf_nout[32];
UInt64 nbytes_in, nbytes_out; UInt64 nbytes_in, nbytes_out;
double nbytes_in_d, nbytes_out_d; double nbytes_in_d, nbytes_out_d;
uInt64_from_UInt32s ( &nbytes_in, uInt64_from_UInt32s ( &nbytes_in,
nbytes_in_lo32, nbytes_in_hi32 ); nbytes_in_lo32, nbytes_in_hi32 );
uInt64_from_UInt32s ( &nbytes_out, uInt64_from_UInt32s ( &nbytes_out,
nbytes_out_lo32, nbytes_out_hi32 ); nbytes_out_lo32, nbytes_out_hi32 );
nbytes_in_d = uInt64_to_double ( &nbytes_in ); nbytes_in_d = uInt64_to_double ( &nbytes_in );
nbytes_out_d = uInt64_to_double ( &nbytes_out ); nbytes_out_d = uInt64_to_double ( &nbytes_out );
@ -318,7 +318,7 @@ void compressStream ( FILE *stream, FILE *zStream )
return; return;
errhandler: errhandler:
BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1, BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1,
&nbytes_in_lo32, &nbytes_in_hi32, &nbytes_in_lo32, &nbytes_in_hi32,
&nbytes_out_lo32, &nbytes_out_hi32 ); &nbytes_out_lo32, &nbytes_out_hi32 );
switch (bzerr) { switch (bzerr) {
@ -340,7 +340,7 @@ void compressStream ( FILE *stream, FILE *zStream )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
Bool uncompressStream ( FILE *zStream, FILE *stream ) Bool uncompressStream ( FILE *zStream, FILE *stream )
{ {
BZFILE* bzf = NULL; BZFILE* bzf = NULL;
@ -362,8 +362,8 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
while (True) { while (True) {
bzf = BZ2_bzReadOpen ( bzf = BZ2_bzReadOpen (
&bzerr, zStream, verbosity, &bzerr, zStream, verbosity,
(int)smallMode, unused, nUnused (int)smallMode, unused, nUnused
); );
if (bzf == NULL || bzerr != BZ_OK) goto errhandler; if (bzf == NULL || bzerr != BZ_OK) goto errhandler;
@ -412,7 +412,7 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
if (verbosity >= 2) (fprintf) ( stderr, "\n " ); if (verbosity >= 2) (fprintf) ( stderr, "\n " );
return True; return True;
trycat: trycat:
if (forceOverwrite) { if (forceOverwrite) {
rewind(zStream); rewind(zStream);
while (True) { while (True) {
@ -424,7 +424,7 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
} }
goto closeok; goto closeok;
} }
errhandler: errhandler:
BZ2_bzReadClose ( &bzerr_dummy, bzf ); BZ2_bzReadClose ( &bzerr_dummy, bzf );
switch (bzerr) { switch (bzerr) {
@ -446,10 +446,10 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
return False; return False;
} else { } else {
if (noisy) if (noisy)
(fprintf) ( stderr, (fprintf) ( stderr,
"\n%s: %s: trailing garbage after EOF ignored\n", "\n%s: %s: trailing garbage after EOF ignored\n",
progName, inName ); progName, inName );
return True; return True;
} }
default: default:
panic ( "decompress:unexpected error" ); panic ( "decompress:unexpected error" );
@ -461,7 +461,7 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
Bool testStream ( FILE *zStream ) Bool testStream ( FILE *zStream )
{ {
BZFILE* bzf = NULL; BZFILE* bzf = NULL;
@ -480,8 +480,8 @@ Bool testStream ( FILE *zStream )
while (True) { while (True) {
bzf = BZ2_bzReadOpen ( bzf = BZ2_bzReadOpen (
&bzerr, zStream, verbosity, &bzerr, zStream, verbosity,
(int)smallMode, unused, nUnused (int)smallMode, unused, nUnused
); );
if (bzf == NULL || bzerr != BZ_OK) goto errhandler; if (bzf == NULL || bzerr != BZ_OK) goto errhandler;
@ -514,7 +514,7 @@ Bool testStream ( FILE *zStream )
errhandler: errhandler:
BZ2_bzReadClose ( &bzerr_dummy, bzf ); BZ2_bzReadClose ( &bzerr_dummy, bzf );
if (verbosity == 0) if (verbosity == 0)
(fprintf) ( stderr, "%s: %s: ", progName, inName ); (fprintf) ( stderr, "%s: %s: ", progName, inName );
switch (bzerr) { switch (bzerr) {
case BZ_CONFIG_ERROR: case BZ_CONFIG_ERROR:
@ -535,14 +535,14 @@ Bool testStream ( FILE *zStream )
case BZ_DATA_ERROR_MAGIC: case BZ_DATA_ERROR_MAGIC:
if (zStream != stdin) fclose(zStream); if (zStream != stdin) fclose(zStream);
if (streamNo == 1) { if (streamNo == 1) {
(fprintf) ( stderr, (fprintf) ( stderr,
"bad magic number (file not created by bzip2)\n" ); "bad magic number (file not created by bzip2)\n" );
return False; return False;
} else { } else {
if (noisy) if (noisy)
(fprintf) ( stderr, (fprintf) ( stderr,
"trailing garbage after EOF ignored\n" ); "trailing garbage after EOF ignored\n" );
return True; return True;
} }
default: default:
panic ( "test:unexpected error" ); panic ( "test:unexpected error" );
@ -566,7 +566,7 @@ void setExit ( Int32 v )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void cadvise ( void ) void cadvise ( void )
{ {
if (noisy) if (noisy)
@ -581,26 +581,26 @@ void cadvise ( void )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void showFileNames ( void ) void showFileNames ( void )
{ {
if (noisy) if (noisy)
(fprintf) ( (fprintf) (
stderr, stderr,
"\tInput file = %s, output file = %s\n", "\tInput file = %s, output file = %s\n",
inName, outName inName, outName
); );
} }
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void cleanUpAndFail ( Int32 ec ) void cleanUpAndFail ( Int32 ec )
{ {
IntNative retVal; IntNative retVal;
struct MY_STAT statBuf; struct MY_STAT statBuf;
if ( srcMode == SM_F2F if ( srcMode == SM_F2F
&& opMode != OM_TEST && opMode != OM_TEST
&& deleteOutputOnInterrupt ) { && deleteOutputOnInterrupt ) {
@ -612,7 +612,7 @@ void cleanUpAndFail ( Int32 ec )
retVal = MY_STAT ( inName, &statBuf ); retVal = MY_STAT ( inName, &statBuf );
if (retVal == 0) { if (retVal == 0) {
if (noisy) if (noisy)
(fprintf) ( stderr, (fprintf) ( stderr,
"%s: Deleting output file %s, if it exists.\n", "%s: Deleting output file %s, if it exists.\n",
progName, outName ); progName, outName );
if (outputHandleJustInCase != NULL) if (outputHandleJustInCase != NULL)
@ -633,7 +633,7 @@ void cleanUpAndFail ( Int32 ec )
(fprintf) ( stderr, (fprintf) ( stderr,
"%s: `%s' may be incomplete.\n", "%s: `%s' may be incomplete.\n",
progName, outName ); progName, outName );
(fprintf) ( stderr, (fprintf) ( stderr,
"%s: I suggest doing an integrity test (bzip2 -tv)" "%s: I suggest doing an integrity test (bzip2 -tv)"
" of it.\n", " of it.\n",
progName ); progName );
@ -641,7 +641,7 @@ void cleanUpAndFail ( Int32 ec )
} }
if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) { if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) {
(fprintf) ( stderr, (fprintf) ( stderr,
"%s: WARNING: some files have not been processed:\n" "%s: WARNING: some files have not been processed:\n"
"%s: %d specified on command line, %d not processed yet.\n\n", "%s: %d specified on command line, %d not processed yet.\n\n",
progName, progName, progName, progName,
@ -653,7 +653,7 @@ void cleanUpAndFail ( Int32 ec )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void panic ( const Char* s ) void panic ( const Char* s )
{ {
(fprintf) ( stderr, (fprintf) ( stderr,
@ -668,7 +668,7 @@ void panic ( const Char* s )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void crcError ( void ) void crcError ( void )
{ {
(fprintf) ( stderr, (fprintf) ( stderr,
@ -681,7 +681,7 @@ void crcError ( void )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void compressedStreamEOF ( void ) void compressedStreamEOF ( void )
{ {
if (noisy) { if (noisy) {
@ -698,7 +698,7 @@ void compressedStreamEOF ( void )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void ioError ( void ) void ioError ( void )
{ {
(fprintf) ( stderr, (fprintf) ( stderr,
@ -712,7 +712,7 @@ void ioError ( void )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void mySignalCatcher ( IntNative n ) void mySignalCatcher ( IntNative n )
{ {
(fprintf) ( stderr, (fprintf) ( stderr,
@ -723,11 +723,11 @@ void mySignalCatcher ( IntNative n )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void mySIGSEGVorSIGBUScatcher ( IntNative n ) void mySIGSEGVorSIGBUScatcher ( IntNative n )
{ {
if (opMode == OM_Z) if (opMode == OM_Z)
(fprintf) ( (fprintf) (
stderr, stderr,
"\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n" "\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n"
"\n" "\n"
@ -748,7 +748,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n )
"\n", "\n",
progName ); progName );
else else
(fprintf) ( (fprintf) (
stderr, stderr,
"\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n" "\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n"
"\n" "\n"
@ -779,7 +779,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void outOfMemory ( void ) void outOfMemory ( void )
{ {
(fprintf) ( stderr, (fprintf) ( stderr,
@ -791,7 +791,7 @@ void outOfMemory ( void )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void configError ( void ) void configError ( void )
{ {
(fprintf) ( stderr, (fprintf) ( stderr,
@ -811,11 +811,11 @@ void configError ( void )
/* All rather crufty. The main problem is that input files /* All rather crufty. The main problem is that input files
are stat()d multiple times before use. This should be are stat()d multiple times before use. This should be
cleaned up. cleaned up.
*/ */
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void pad ( Char *s ) void pad ( Char *s )
{ {
Int32 i; Int32 i;
@ -826,8 +826,8 @@ void pad ( Char *s )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void copyFileName ( Char* to, Char* from ) void copyFileName ( Char* to, Char* from )
{ {
if ( strlen(from) > FILE_NAME_LEN-10 ) { if ( strlen(from) > FILE_NAME_LEN-10 ) {
(fprintf) ( (fprintf) (
@ -847,7 +847,7 @@ void copyFileName ( Char* to, Char* from )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
Bool fileExists ( Char* name ) Bool fileExists ( Char* name )
{ {
FILE *tmp = fopen ( name, "rb" ); FILE *tmp = fopen ( name, "rb" );
@ -888,7 +888,7 @@ FILE* fopen_output_safely ( Char* name, const char* mode )
/*-- /*--
if in doubt, return True if in doubt, return True
--*/ --*/
static static
Bool notAStandardFile ( Char* name ) Bool notAStandardFile ( Char* name )
{ {
IntNative i; IntNative i;
@ -905,9 +905,9 @@ Bool notAStandardFile ( Char* name )
/*-- /*--
rac 11/21/98 see if file has hard links to it rac 11/21/98 see if file has hard links to it
--*/ --*/
static static
Int32 countHardLinks ( Char* name ) Int32 countHardLinks ( Char* name )
{ {
IntNative i; IntNative i;
struct MY_STAT statBuf; struct MY_STAT statBuf;
@ -938,14 +938,14 @@ Int32 countHardLinks ( Char* name )
It sounds pretty fragile to me. Whether this carries across It sounds pretty fragile to me. Whether this carries across
robustly to arbitrary Unix-like platforms (or even works robustly robustly to arbitrary Unix-like platforms (or even works robustly
on this one, RedHat 7.2) is unknown to me. Nevertheless ... on this one, RedHat 7.2) is unknown to me. Nevertheless ...
*/ */
#if BZ_UNIX #if BZ_UNIX
static static
struct MY_STAT fileMetaInfo; struct MY_STAT fileMetaInfo;
#endif #endif
static static
void saveInputFileMetaInfo ( Char *srcName ) void saveInputFileMetaInfo ( Char *srcName )
{ {
# if BZ_UNIX # if BZ_UNIX
@ -957,7 +957,7 @@ void saveInputFileMetaInfo ( Char *srcName )
} }
static static
void applySavedTimeInfoToOutputFile ( Char *dstName ) void applySavedTimeInfoToOutputFile ( Char *dstName )
{ {
# if BZ_UNIX # if BZ_UNIX
@ -972,7 +972,7 @@ void applySavedTimeInfoToOutputFile ( Char *dstName )
# endif # endif
} }
static static
void applySavedFileAttrToOutputFile ( IntNative fd ) void applySavedFileAttrToOutputFile ( IntNative fd )
{ {
# if BZ_UNIX # if BZ_UNIX
@ -990,7 +990,7 @@ void applySavedFileAttrToOutputFile ( IntNative fd )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
Bool containsDubiousChars ( Char* name ) Bool containsDubiousChars ( Char* name )
{ {
# if BZ_UNIX # if BZ_UNIX
@ -999,7 +999,7 @@ Bool containsDubiousChars ( Char* name )
*/ */
return False; return False;
# else /* ! BZ_UNIX */ # else /* ! BZ_UNIX */
/* On non-unix (Win* platforms), wildcard characters are not allowed in /* On non-unix (Win* platforms), wildcard characters are not allowed in
* filenames. * filenames.
*/ */
for (; *name != '\0'; name++) for (; *name != '\0'; name++)
@ -1012,12 +1012,12 @@ Bool containsDubiousChars ( Char* name )
/*---------------------------------------------*/ /*---------------------------------------------*/
#define BZ_N_SUFFIX_PAIRS 4 #define BZ_N_SUFFIX_PAIRS 4
const Char* zSuffix[BZ_N_SUFFIX_PAIRS] const Char* zSuffix[BZ_N_SUFFIX_PAIRS]
= { ".bz2", ".bz", ".tbz2", ".tbz" }; = { ".bz2", ".bz", ".tbz2", ".tbz" };
const Char* unzSuffix[BZ_N_SUFFIX_PAIRS] const Char* unzSuffix[BZ_N_SUFFIX_PAIRS]
= { "", "", ".tar", ".tar" }; = { "", "", ".tar", ".tar" };
static static
Bool hasSuffix ( Char* s, const Char* suffix ) Bool hasSuffix ( Char* s, const Char* suffix )
{ {
Int32 ns = strlen(s); Int32 ns = strlen(s);
@ -1027,9 +1027,9 @@ Bool hasSuffix ( Char* s, const Char* suffix )
return False; return False;
} }
static static
Bool mapSuffix ( Char* name, Bool mapSuffix ( Char* name,
const Char* oldSuffix, const Char* oldSuffix,
const Char* newSuffix ) const Char* newSuffix )
{ {
if (!hasSuffix(name,oldSuffix)) return False; if (!hasSuffix(name,oldSuffix)) return False;
@ -1040,7 +1040,7 @@ Bool mapSuffix ( Char* name,
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void compress ( Char *name ) void compress ( Char *name )
{ {
FILE *inStr; FILE *inStr;
@ -1054,18 +1054,18 @@ void compress ( Char *name )
panic ( "compress: bad modes\n" ); panic ( "compress: bad modes\n" );
switch (srcMode) { switch (srcMode) {
case SM_I2O: case SM_I2O:
copyFileName ( inName, (Char*)"(stdin)" ); copyFileName ( inName, (Char*)"(stdin)" );
copyFileName ( outName, (Char*)"(stdout)" ); copyFileName ( outName, (Char*)"(stdout)" );
break; break;
case SM_F2F: case SM_F2F:
copyFileName ( inName, name ); copyFileName ( inName, name );
copyFileName ( outName, name ); copyFileName ( outName, name );
strcat ( outName, ".bz2" ); strcat ( outName, ".bz2" );
break; break;
case SM_F2O: case SM_F2O:
copyFileName ( inName, name ); copyFileName ( inName, name );
copyFileName ( outName, (Char*)"(stdout)" ); copyFileName ( outName, (Char*)"(stdout)" );
break; break;
} }
@ -1085,7 +1085,7 @@ void compress ( Char *name )
for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) { for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) {
if (hasSuffix(inName, zSuffix[i])) { if (hasSuffix(inName, zSuffix[i])) {
if (noisy) if (noisy)
(fprintf) ( stderr, (fprintf) ( stderr,
"%s: Input file %s already has %s suffix.\n", "%s: Input file %s already has %s suffix.\n",
progName, inName, zSuffix[i] ); progName, inName, zSuffix[i] );
setExit(1); setExit(1);
@ -1221,7 +1221,7 @@ void compress ( Char *name )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void uncompress ( Char *name ) void uncompress ( Char *name )
{ {
FILE *inStr; FILE *inStr;
@ -1238,22 +1238,22 @@ void uncompress ( Char *name )
cantGuess = False; cantGuess = False;
switch (srcMode) { switch (srcMode) {
case SM_I2O: case SM_I2O:
copyFileName ( inName, (Char*)"(stdin)" ); copyFileName ( inName, (Char*)"(stdin)" );
copyFileName ( outName, (Char*)"(stdout)" ); copyFileName ( outName, (Char*)"(stdout)" );
break; break;
case SM_F2F: case SM_F2F:
copyFileName ( inName, name ); copyFileName ( inName, name );
copyFileName ( outName, name ); copyFileName ( outName, name );
for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++)
if (mapSuffix(outName,zSuffix[i],unzSuffix[i])) if (mapSuffix(outName,zSuffix[i],unzSuffix[i]))
goto zzz; goto zzz;
cantGuess = True; cantGuess = True;
strcat ( outName, ".out" ); strcat ( outName, ".out" );
break; break;
case SM_F2O: case SM_F2O:
copyFileName ( inName, name ); copyFileName ( inName, name );
copyFileName ( outName, (Char*)"(stdout)" ); copyFileName ( outName, (Char*)"(stdout)" );
break; break;
} }
@ -1290,11 +1290,11 @@ void uncompress ( Char *name )
} }
if ( /* srcMode == SM_F2F implied && */ cantGuess ) { if ( /* srcMode == SM_F2F implied && */ cantGuess ) {
if (noisy) if (noisy)
(fprintf) ( stderr, (fprintf) ( stderr,
"%s: Can't guess original name for %s -- using %s\n", "%s: Can't guess original name for %s -- using %s\n",
progName, inName, outName ); progName, inName, outName );
/* just a warning, no return */ /* just a warning, no return */
} }
if ( srcMode == SM_F2F && fileExists ( outName ) ) { if ( srcMode == SM_F2F && fileExists ( outName ) ) {
if (forceOverwrite) { if (forceOverwrite) {
remove(outName); remove(outName);
@ -1419,7 +1419,7 @@ void uncompress ( Char *name )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void testf ( Char *name ) void testf ( Char *name )
{ {
FILE *inStr; FILE *inStr;
@ -1508,7 +1508,7 @@ void testf ( Char *name )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void license ( void ) void license ( void )
{ {
(fprintf) ( stderr, (fprintf) ( stderr,
@ -1533,7 +1533,7 @@ void license ( void )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void usage ( Char *fullProgName ) void usage ( Char *fullProgName )
{ {
(fprintf) ( (fprintf) (
@ -1577,11 +1577,11 @@ void usage ( Char *fullProgName )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void redundant ( Char* flag ) void redundant ( Char* flag )
{ {
(fprintf) ( (fprintf) (
stderr, stderr,
"%s: %s is redundant in versions 0.9.5 and above\n", "%s: %s is redundant in versions 0.9.5 and above\n",
progName, flag ); progName, flag );
} }
@ -1593,8 +1593,8 @@ void redundant ( Char* flag )
implement a linked list of command-line arguments, implement a linked list of command-line arguments,
into which main() copies argv[1 .. argc-1]. into which main() copies argv[1 .. argc-1].
The purpose of this exercise is to facilitate The purpose of this exercise is to facilitate
the expansion of wildcard characters * and ? in the expansion of wildcard characters * and ? in
filenames for OSs which don't know how to do it filenames for OSs which don't know how to do it
themselves, like MSDOS, Windows 95 and NT. themselves, like MSDOS, Windows 95 and NT.
@ -1611,7 +1611,7 @@ typedef
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void *myMalloc ( Int32 n ) void *myMalloc ( Int32 n )
{ {
void* p; void* p;
@ -1623,7 +1623,7 @@ void *myMalloc ( Int32 n )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
Cell *mkCell ( void ) Cell *mkCell ( void )
{ {
Cell *c; Cell *c;
@ -1636,7 +1636,7 @@ Cell *mkCell ( void )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
Cell *snocString ( Cell *root, Char *name ) Cell *snocString ( Cell *root, Char *name )
{ {
if (root == NULL) { if (root == NULL) {
@ -1654,8 +1654,8 @@ Cell *snocString ( Cell *root, Char *name )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void addFlagsFromEnvVar ( Cell** argList, Char* varName ) void addFlagsFromEnvVar ( Cell** argList, Char* varName )
{ {
Int32 i, j, k; Int32 i, j, k;
Char *envbase, *p; Char *envbase, *p;
@ -1732,7 +1732,7 @@ IntNative main ( IntNative argc, Char *argv[] )
if (*tmp == PATH_SEP) progName = tmp + 1; if (*tmp == PATH_SEP) progName = tmp + 1;
/*-- Copy flags from env var BZIP2, and /*-- Copy flags from env var BZIP2, and
expand filename wildcards in arg list. expand filename wildcards in arg list.
--*/ --*/
argList = NULL; argList = NULL;
@ -1815,7 +1815,7 @@ IntNative main ( IntNative argc, Char *argv[] )
} }
} }
} }
/*-- And again ... --*/ /*-- And again ... --*/
for (aa = argList; aa != NULL; aa = aa->link) { for (aa = argList; aa != NULL; aa = aa->link) {
if (ISFLAG("--")) break; if (ISFLAG("--")) break;
@ -1829,7 +1829,7 @@ IntNative main ( IntNative argc, Char *argv[] )
if (ISFLAG("--quiet")) noisy = False; else if (ISFLAG("--quiet")) noisy = False; else
if (ISFLAG("--version")) license(); else if (ISFLAG("--version")) license(); else
if (ISFLAG("--license")) license(); else if (ISFLAG("--license")) license(); else
if (ISFLAG("--exponential")) workFactor = 1; else if (ISFLAG("--exponential")) workFactor = 1; else
if (ISFLAG("--repetitive-best")) redundant(aa->name); else if (ISFLAG("--repetitive-best")) redundant(aa->name); else
if (ISFLAG("--repetitive-fast")) redundant(aa->name); else if (ISFLAG("--repetitive-fast")) redundant(aa->name); else
if (ISFLAG("--fast")) blockSize100k = 1; else if (ISFLAG("--fast")) blockSize100k = 1; else
@ -1845,7 +1845,7 @@ IntNative main ( IntNative argc, Char *argv[] )
} }
if (verbosity > 4) verbosity = 4; if (verbosity > 4) verbosity = 4;
if (opMode == OM_Z && smallMode && blockSize100k > 2) if (opMode == OM_Z && smallMode && blockSize100k > 2)
blockSize100k = 2; blockSize100k = 2;
if (opMode == OM_TEST && srcMode == SM_F2O) { if (opMode == OM_TEST && srcMode == SM_F2O) {
@ -1879,7 +1879,7 @@ IntNative main ( IntNative argc, Char *argv[] )
compress ( aa->name ); compress ( aa->name );
} }
} }
} }
else else
if (opMode == OM_UNZ) { if (opMode == OM_UNZ) {
@ -1893,13 +1893,13 @@ IntNative main ( IntNative argc, Char *argv[] )
if (aa->name[0] == '-' && decode) continue; if (aa->name[0] == '-' && decode) continue;
numFilesProcessed++; numFilesProcessed++;
uncompress ( aa->name ); uncompress ( aa->name );
} }
} }
if (unzFailsExist) { if (unzFailsExist) {
setExit(2); setExit(2);
exit(exitValue); exit(exitValue);
} }
} }
else { else {
testFailsExist = False; testFailsExist = False;
@ -1927,7 +1927,7 @@ IntNative main ( IntNative argc, Char *argv[] )
} }
} }
/* Free the argument list memory to mollify leak detectors /* Free the argument list memory to mollify leak detectors
(eg) Purify, Checker. Serves no other useful purpose. (eg) Purify, Checker. Serves no other useful purpose.
*/ */
aa = argList; aa = argList;

View file

@ -18,7 +18,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -77,7 +77,7 @@ MaybeUInt64 bytesIn = 0;
#define BZ_HDR_Z 0x5a /* 'Z' */ #define BZ_HDR_Z 0x5a /* 'Z' */
#define BZ_HDR_h 0x68 /* 'h' */ #define BZ_HDR_h 0x68 /* 'h' */
#define BZ_HDR_0 0x30 /* '0' */ #define BZ_HDR_0 0x30 /* '0' */
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*--- I/O errors ---*/ /*--- I/O errors ---*/
@ -130,7 +130,7 @@ static void tooManyBlocks ( Int32 max_handled_blocks )
(fprintf) ( stderr, (fprintf) ( stderr,
"%s: and cannot be handled. To fix, increase\n", "%s: and cannot be handled. To fix, increase\n",
progName ); progName );
(fprintf) ( stderr, (fprintf) ( stderr,
"%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n", "%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n",
progName ); progName );
exit ( 1 ); exit ( 1 );
@ -315,7 +315,7 @@ Int32 main ( Int32 argc, Char** argv )
progName[BZ_MAX_FILENAME-1]='\0'; progName[BZ_MAX_FILENAME-1]='\0';
inFileName[0] = outFileName[0] = 0; inFileName[0] = outFileName[0] = 0;
(fprintf) ( stderr, (fprintf) ( stderr,
"bzip2recover 1.0.8: extracts blocks from damaged .bz2 files.\n" ); "bzip2recover 1.0.8: extracts blocks from damaged .bz2 files.\n" );
if (argc != 2) { if (argc != 2) {
@ -323,18 +323,18 @@ Int32 main ( Int32 argc, Char** argv )
progName, progName ); progName, progName );
switch (sizeof(MaybeUInt64)) { switch (sizeof(MaybeUInt64)) {
case 8: case 8:
(fprintf)(stderr, (fprintf)(stderr,
"\trestrictions on size of recovered file: None\n"); "\trestrictions on size of recovered file: None\n");
break; break;
case 4: case 4:
(fprintf)(stderr, (fprintf)(stderr,
"\trestrictions on size of recovered file: 512 MB\n"); "\trestrictions on size of recovered file: 512 MB\n");
(fprintf)(stderr, (fprintf)(stderr,
"\tto circumvent, recompile with MaybeUInt64 as an\n" "\tto circumvent, recompile with MaybeUInt64 as an\n"
"\tunsigned 64-bit int.\n"); "\tunsigned 64-bit int.\n");
break; break;
default: default:
(fprintf)(stderr, (fprintf)(stderr,
"\tsizeof(MaybeUInt64) is not 4 or 8 -- " "\tsizeof(MaybeUInt64) is not 4 or 8 -- "
"configuration error.\n"); "configuration error.\n");
break; break;
@ -343,7 +343,7 @@ Int32 main ( Int32 argc, Char** argv )
} }
if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) { if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) {
(fprintf) ( stderr, (fprintf) ( stderr,
"%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n", "%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n",
progName, (int)strlen(argv[1]) ); progName, (int)strlen(argv[1]) );
exit(1); exit(1);
@ -375,7 +375,7 @@ Int32 main ( Int32 argc, Char** argv )
(bitsRead - bStart[currBlock]) >= 40) { (bitsRead - bStart[currBlock]) >= 40) {
bEnd[currBlock] = bitsRead-1; bEnd[currBlock] = bitsRead-1;
if (currBlock > 0) if (currBlock > 0)
(fprintf) ( stderr, " block %d runs from " MaybeUInt64_FMT (fprintf) ( stderr, " block %d runs from " MaybeUInt64_FMT
" to " MaybeUInt64_FMT " (incomplete)\n", " to " MaybeUInt64_FMT " (incomplete)\n",
currBlock, bStart[currBlock], bEnd[currBlock] ); currBlock, bStart[currBlock], bEnd[currBlock] );
} else } else
@ -384,10 +384,10 @@ Int32 main ( Int32 argc, Char** argv )
} }
buffHi = (buffHi << 1) | (buffLo >> 31); buffHi = (buffHi << 1) | (buffLo >> 31);
buffLo = (buffLo << 1) | (b & 1); buffLo = (buffLo << 1) | (b & 1);
if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI
&& buffLo == BLOCK_HEADER_LO) && buffLo == BLOCK_HEADER_LO)
|| ||
( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI
&& buffLo == BLOCK_ENDMARK_LO) && buffLo == BLOCK_ENDMARK_LO)
) { ) {
if (bitsRead > 49) { if (bitsRead > 49) {
@ -397,7 +397,7 @@ Int32 main ( Int32 argc, Char** argv )
} }
if (currBlock > 0 && if (currBlock > 0 &&
(bEnd[currBlock] - bStart[currBlock]) >= 130) { (bEnd[currBlock] - bStart[currBlock]) >= 130) {
(fprintf) ( stderr, " block %d runs from " MaybeUInt64_FMT (fprintf) ( stderr, " block %d runs from " MaybeUInt64_FMT
" to " MaybeUInt64_FMT "\n", " to " MaybeUInt64_FMT "\n",
rbCtr+1, bStart[currBlock], bEnd[currBlock] ); rbCtr+1, bStart[currBlock], bEnd[currBlock] );
rbStart[rbCtr] = bStart[currBlock]; rbStart[rbCtr] = bStart[currBlock];
@ -443,7 +443,7 @@ Int32 main ( Int32 argc, Char** argv )
if (b == 2) break; if (b == 2) break;
buffHi = (buffHi << 1) | (buffLo >> 31); buffHi = (buffHi << 1) | (buffLo >> 31);
buffLo = (buffLo << 1) | (b & 1); buffLo = (buffLo << 1) | (b & 1);
if (bitsRead == 47+rbStart[wrBlock]) if (bitsRead == 47+rbStart[wrBlock])
blockCRC = (buffHi << 16) | (buffLo >> 16); blockCRC = (buffHi << 16) | (buffLo >> 16);
if (outFile != NULL && bitsRead >= rbStart[wrBlock] if (outFile != NULL && bitsRead >= rbStart[wrBlock]
@ -466,11 +466,11 @@ Int32 main ( Int32 argc, Char** argv )
wrBlock++; wrBlock++;
} else } else
if (bitsRead == rbStart[wrBlock]) { if (bitsRead == rbStart[wrBlock]) {
/* Create the output file name, correctly handling leading paths. /* Create the output file name, correctly handling leading paths.
(31.10.2001 by Sergey E. Kusikov) */ (31.10.2001 by Sergey E. Kusikov) */
Char* split; Char* split;
Int32 ofs, k; Int32 ofs, k;
for (k = 0; k < BZ_MAX_FILENAME; k++) for (k = 0; k < BZ_MAX_FILENAME; k++)
outFileName[k] = 0; outFileName[k] = 0;
strcpy (outFileName, inFileName); strcpy (outFileName, inFileName);
split = strrchr (outFileName, BZ_SPLIT_SYM); split = strrchr (outFileName, BZ_SPLIT_SYM);
@ -497,9 +497,9 @@ Int32 main ( Int32 argc, Char** argv )
exit(1); exit(1);
} }
bsWr = bsOpenWriteStream ( outFile ); bsWr = bsOpenWriteStream ( outFile );
bsPutUChar ( bsWr, BZ_HDR_B ); bsPutUChar ( bsWr, BZ_HDR_B );
bsPutUChar ( bsWr, BZ_HDR_Z ); bsPutUChar ( bsWr, BZ_HDR_Z );
bsPutUChar ( bsWr, BZ_HDR_h ); bsPutUChar ( bsWr, BZ_HDR_h );
bsPutUChar ( bsWr, BZ_HDR_0 + 9 ); bsPutUChar ( bsWr, BZ_HDR_0 + 9 );
bsPutUChar ( bsWr, 0x31 ); bsPutUChar ( bsWr, 0x41 ); bsPutUChar ( bsWr, 0x31 ); bsPutUChar ( bsWr, 0x41 );
bsPutUChar ( bsWr, 0x59 ); bsPutUChar ( bsWr, 0x26 ); bsPutUChar ( bsWr, 0x59 ); bsPutUChar ( bsWr, 0x26 );

View file

@ -12,7 +12,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -42,7 +42,7 @@
#ifndef BZ_NO_STDIO #ifndef BZ_NO_STDIO
void BZ2_bz__AssertH__fail ( int errcode ) void BZ2_bz__AssertH__fail ( int errcode )
{ {
fprintf(stderr, fprintf(stderr,
"\n\nbzip2/libbzip2: internal error number %d.\n" "\n\nbzip2/libbzip2: internal error number %d.\n"
"This is a bug in bzip2/libbzip2, %s.\n" "This is a bug in bzip2/libbzip2, %s.\n"
"Please report it to: bzip2-devel@sourceware.org. If this happened\n" "Please report it to: bzip2-devel@sourceware.org. If this happened\n"
@ -147,8 +147,8 @@ Bool isempty_RL ( EState* s )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ2_bzCompressInit int BZ2_bzCompressInit
( bz_stream* strm, ( bz_stream* strm,
int blockSize100k, int blockSize100k,
int verbosity, int verbosity,
int workFactor ) int workFactor )
@ -158,7 +158,7 @@ int BZ2_bzCompressInit
if (!bz_config_ok()) return BZ_CONFIG_ERROR; if (!bz_config_ok()) return BZ_CONFIG_ERROR;
if (strm == NULL || if (strm == NULL ||
blockSize100k < 1 || blockSize100k > 9 || blockSize100k < 1 || blockSize100k > 9 ||
workFactor < 0 || workFactor > 250) workFactor < 0 || workFactor > 250)
return BZ_PARAM_ERROR; return BZ_PARAM_ERROR;
@ -301,7 +301,7 @@ Bool copy_input_until_stop ( EState* s )
/*-- no input? --*/ /*-- no input? --*/
if (s->strm->avail_in == 0) break; if (s->strm->avail_in == 0) break;
progress_in = True; progress_in = True;
ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
s->strm->next_in++; s->strm->next_in++;
s->strm->avail_in--; s->strm->avail_in--;
s->strm->total_in_lo32++; s->strm->total_in_lo32++;
@ -319,7 +319,7 @@ Bool copy_input_until_stop ( EState* s )
/*-- flush/finish end? --*/ /*-- flush/finish end? --*/
if (s->avail_in_expect == 0) break; if (s->avail_in_expect == 0) break;
progress_in = True; progress_in = True;
ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
s->strm->next_in++; s->strm->next_in++;
s->strm->avail_in--; s->strm->avail_in--;
s->strm->total_in_lo32++; s->strm->total_in_lo32++;
@ -365,18 +365,18 @@ Bool handle_compress ( bz_stream* strm )
Bool progress_in = False; Bool progress_in = False;
Bool progress_out = False; Bool progress_out = False;
EState* s = strm->state; EState* s = strm->state;
while (True) { while (True) {
if (s->state == BZ_S_OUTPUT) { if (s->state == BZ_S_OUTPUT) {
progress_out |= copy_output_until_stop ( s ); progress_out |= copy_output_until_stop ( s );
if (s->state_out_pos < s->numZ) break; if (s->state_out_pos < s->numZ) break;
if (s->mode == BZ_M_FINISHING && if (s->mode == BZ_M_FINISHING &&
s->avail_in_expect == 0 && s->avail_in_expect == 0 &&
isempty_RL(s)) break; isempty_RL(s)) break;
prepare_new_block ( s ); prepare_new_block ( s );
s->state = BZ_S_INPUT; s->state = BZ_S_INPUT;
if (s->mode == BZ_M_FLUSHING && if (s->mode == BZ_M_FLUSHING &&
s->avail_in_expect == 0 && s->avail_in_expect == 0 &&
isempty_RL(s)) break; isempty_RL(s)) break;
} }
@ -425,7 +425,7 @@ int BZ2_bzCompress ( bz_stream *strm, int action )
if (action == BZ_RUN) { if (action == BZ_RUN) {
progress = handle_compress ( strm ); progress = handle_compress ( strm );
return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
} }
else else
if (action == BZ_FLUSH) { if (action == BZ_FLUSH) {
s->avail_in_expect = strm->avail_in; s->avail_in_expect = strm->avail_in;
@ -438,12 +438,12 @@ int BZ2_bzCompress ( bz_stream *strm, int action )
s->mode = BZ_M_FINISHING; s->mode = BZ_M_FINISHING;
goto preswitch; goto preswitch;
} }
else else
return BZ_PARAM_ERROR; return BZ_PARAM_ERROR;
case BZ_M_FLUSHING: case BZ_M_FLUSHING:
if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
if (s->avail_in_expect != s->strm->avail_in) if (s->avail_in_expect != s->strm->avail_in)
return BZ_SEQUENCE_ERROR; return BZ_SEQUENCE_ERROR;
progress = handle_compress ( strm ); progress = handle_compress ( strm );
if (s->avail_in_expect > 0 || !isempty_RL(s) || if (s->avail_in_expect > 0 || !isempty_RL(s) ||
@ -453,7 +453,7 @@ int BZ2_bzCompress ( bz_stream *strm, int action )
case BZ_M_FINISHING: case BZ_M_FINISHING:
if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
if (s->avail_in_expect != s->strm->avail_in) if (s->avail_in_expect != s->strm->avail_in)
return BZ_SEQUENCE_ERROR; return BZ_SEQUENCE_ERROR;
progress = handle_compress ( strm ); progress = handle_compress ( strm );
if (!progress) return BZ_SEQUENCE_ERROR; if (!progress) return BZ_SEQUENCE_ERROR;
@ -480,7 +480,7 @@ int BZ2_bzCompressEnd ( bz_stream *strm )
if (s->ftab != NULL) BZFREE(s->ftab); if (s->ftab != NULL) BZFREE(s->ftab);
BZFREE(strm->state); BZFREE(strm->state);
strm->state = NULL; strm->state = NULL;
return BZ_OK; return BZ_OK;
} }
@ -491,8 +491,8 @@ int BZ2_bzCompressEnd ( bz_stream *strm )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ2_bzDecompressInit int BZ2_bzDecompressInit
( bz_stream* strm, ( bz_stream* strm,
int verbosity, int verbosity,
int small ) int small )
{ {
@ -557,34 +557,34 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
/* can a new run be started? */ /* can a new run be started? */
if (s->nblock_used == s->save_nblock+1) return False; if (s->nblock_used == s->save_nblock+1) return False;
/* Only caused by corrupt data stream? */ /* Only caused by corrupt data stream? */
if (s->nblock_used > s->save_nblock+1) if (s->nblock_used > s->save_nblock+1)
return True; return True;
s->state_out_len = 1; s->state_out_len = 1;
s->state_out_ch = s->k0; s->state_out_ch = s->k0;
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++; k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue; if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; }; if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 2; s->state_out_len = 2;
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++; k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue; if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; }; if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 3; s->state_out_len = 3;
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++; k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue; if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; }; if (k1 != s->k0) { s->k0 = k1; continue; };
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++; k1 ^= BZ_RAND_MASK; s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4; s->state_out_len = ((Int32)k1) + 4;
BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
s->k0 ^= BZ_RAND_MASK; s->nblock_used++; s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
} }
@ -622,7 +622,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
} }
s_state_out_len_eq_one: s_state_out_len_eq_one:
{ {
if (cs_avail_out == 0) { if (cs_avail_out == 0) {
c_state_out_len = 1; goto return_notr; c_state_out_len = 1; goto return_notr;
}; };
*( (UChar*)(cs_next_out) ) = c_state_out_ch; *( (UChar*)(cs_next_out) ) = c_state_out_ch;
@ -630,7 +630,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
cs_next_out++; cs_next_out++;
cs_avail_out--; cs_avail_out--;
} }
} }
/* Only caused by corrupt data stream? */ /* Only caused by corrupt data stream? */
if (c_nblock_used > s_save_nblockPP) if (c_nblock_used > s_save_nblockPP)
return True; return True;
@ -638,25 +638,25 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
/* can a new run be started? */ /* can a new run be started? */
if (c_nblock_used == s_save_nblockPP) { if (c_nblock_used == s_save_nblockPP) {
c_state_out_len = 0; goto return_notr; c_state_out_len = 0; goto return_notr;
}; };
c_state_out_ch = c_k0; c_state_out_ch = c_k0;
BZ_GET_FAST_C(k1); c_nblock_used++; BZ_GET_FAST_C(k1); c_nblock_used++;
if (k1 != c_k0) { if (k1 != c_k0) {
c_k0 = k1; goto s_state_out_len_eq_one; c_k0 = k1; goto s_state_out_len_eq_one;
}; };
if (c_nblock_used == s_save_nblockPP) if (c_nblock_used == s_save_nblockPP)
goto s_state_out_len_eq_one; goto s_state_out_len_eq_one;
c_state_out_len = 2; c_state_out_len = 2;
BZ_GET_FAST_C(k1); c_nblock_used++; BZ_GET_FAST_C(k1); c_nblock_used++;
if (c_nblock_used == s_save_nblockPP) continue; if (c_nblock_used == s_save_nblockPP) continue;
if (k1 != c_k0) { c_k0 = k1; continue; }; if (k1 != c_k0) { c_k0 = k1; continue; };
c_state_out_len = 3; c_state_out_len = 3;
BZ_GET_FAST_C(k1); c_nblock_used++; BZ_GET_FAST_C(k1); c_nblock_used++;
if (c_nblock_used == s_save_nblockPP) continue; if (c_nblock_used == s_save_nblockPP) continue;
if (k1 != c_k0) { c_k0 = k1; continue; }; if (k1 != c_k0) { c_k0 = k1; continue; };
BZ_GET_FAST_C(k1); c_nblock_used++; BZ_GET_FAST_C(k1); c_nblock_used++;
c_state_out_len = ((Int32)k1) + 4; c_state_out_len = ((Int32)k1) + 4;
BZ_GET_FAST_C(c_k0); c_nblock_used++; BZ_GET_FAST_C(c_k0); c_nblock_used++;
@ -724,37 +724,37 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s )
s->strm->total_out_lo32++; s->strm->total_out_lo32++;
if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
} }
/* can a new run be started? */ /* can a new run be started? */
if (s->nblock_used == s->save_nblock+1) return False; if (s->nblock_used == s->save_nblock+1) return False;
/* Only caused by corrupt data stream? */ /* Only caused by corrupt data stream? */
if (s->nblock_used > s->save_nblock+1) if (s->nblock_used > s->save_nblock+1)
return True; return True;
s->state_out_len = 1; s->state_out_len = 1;
s->state_out_ch = s->k0; s->state_out_ch = s->k0;
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++; k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue; if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; }; if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 2; s->state_out_len = 2;
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++; k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue; if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; }; if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 3; s->state_out_len = 3;
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++; k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue; if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; }; if (k1 != s->k0) { s->k0 = k1; continue; };
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++; k1 ^= BZ_RAND_MASK; s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4; s->state_out_len = ((Int32)k1) + 4;
BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
s->k0 ^= BZ_RAND_MASK; s->nblock_used++; s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
} }
@ -773,30 +773,30 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s )
s->strm->total_out_lo32++; s->strm->total_out_lo32++;
if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
} }
/* can a new run be started? */ /* can a new run be started? */
if (s->nblock_used == s->save_nblock+1) return False; if (s->nblock_used == s->save_nblock+1) return False;
/* Only caused by corrupt data stream? */ /* Only caused by corrupt data stream? */
if (s->nblock_used > s->save_nblock+1) if (s->nblock_used > s->save_nblock+1)
return True; return True;
s->state_out_len = 1; s->state_out_len = 1;
s->state_out_ch = s->k0; s->state_out_ch = s->k0;
BZ_GET_SMALL(k1); s->nblock_used++; BZ_GET_SMALL(k1); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue; if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; }; if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 2; s->state_out_len = 2;
BZ_GET_SMALL(k1); s->nblock_used++; BZ_GET_SMALL(k1); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue; if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; }; if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 3; s->state_out_len = 3;
BZ_GET_SMALL(k1); s->nblock_used++; BZ_GET_SMALL(k1); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue; if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; }; if (k1 != s->k0) { s->k0 = k1; continue; };
BZ_GET_SMALL(k1); s->nblock_used++; BZ_GET_SMALL(k1); s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4; s->state_out_len = ((Int32)k1) + 4;
BZ_GET_SMALL(s->k0); s->nblock_used++; BZ_GET_SMALL(s->k0); s->nblock_used++;
@ -825,14 +825,14 @@ int BZ2_bzDecompress ( bz_stream *strm )
if (corrupt) return BZ_DATA_ERROR; if (corrupt) return BZ_DATA_ERROR;
if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
BZ_FINALISE_CRC ( s->calculatedBlockCRC ); BZ_FINALISE_CRC ( s->calculatedBlockCRC );
if (s->verbosity >= 3) if (s->verbosity >= 3)
VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC,
s->calculatedBlockCRC ); s->calculatedBlockCRC );
if (s->verbosity >= 2) VPrintf0 ( "]" ); if (s->verbosity >= 2) VPrintf0 ( "]" );
if (s->calculatedBlockCRC != s->storedBlockCRC) if (s->calculatedBlockCRC != s->storedBlockCRC)
return BZ_DATA_ERROR; return BZ_DATA_ERROR;
s->calculatedCombinedCRC s->calculatedCombinedCRC
= (s->calculatedCombinedCRC << 1) | = (s->calculatedCombinedCRC << 1) |
(s->calculatedCombinedCRC >> 31); (s->calculatedCombinedCRC >> 31);
s->calculatedCombinedCRC ^= s->calculatedBlockCRC; s->calculatedCombinedCRC ^= s->calculatedBlockCRC;
s->state = BZ_X_BLKHDR_1; s->state = BZ_X_BLKHDR_1;
@ -844,7 +844,7 @@ int BZ2_bzDecompress ( bz_stream *strm )
Int32 r = BZ2_decompress ( s ); Int32 r = BZ2_decompress ( s );
if (r == BZ_STREAM_END) { if (r == BZ_STREAM_END) {
if (s->verbosity >= 3) if (s->verbosity >= 3)
VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x",
s->storedCombinedCRC, s->calculatedCombinedCRC ); s->storedCombinedCRC, s->calculatedCombinedCRC );
if (s->calculatedCombinedCRC != s->storedCombinedCRC) if (s->calculatedCombinedCRC != s->storedCombinedCRC)
return BZ_DATA_ERROR; return BZ_DATA_ERROR;
@ -890,7 +890,7 @@ int BZ2_bzDecompressEnd ( bz_stream *strm )
if (bzf != NULL) bzf->lastErr = eee; \ if (bzf != NULL) bzf->lastErr = eee; \
} }
typedef typedef
struct { struct {
FILE* handle; FILE* handle;
Char buf[BZ_MAX_UNUSED]; Char buf[BZ_MAX_UNUSED];
@ -914,10 +914,10 @@ static Bool myfeof ( FILE* f )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
BZFILE* BZ2_bzWriteOpen BZFILE* BZ2_bzWriteOpen
( int* bzerror, ( int* bzerror,
FILE* f, FILE* f,
int blockSize100k, int blockSize100k,
int verbosity, int verbosity,
int workFactor ) int workFactor )
{ {
@ -949,23 +949,23 @@ BZFILE* BZ2_bzWriteOpen
bzf->strm.opaque = NULL; bzf->strm.opaque = NULL;
if (workFactor == 0) workFactor = 30; if (workFactor == 0) workFactor = 30;
ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k,
verbosity, workFactor ); verbosity, workFactor );
if (ret != BZ_OK) if (ret != BZ_OK)
{ BZ_SETERR(ret); free(bzf); return NULL; }; { BZ_SETERR(ret); free(bzf); return NULL; };
bzf->strm.avail_in = 0; bzf->strm.avail_in = 0;
bzf->initialisedOk = True; bzf->initialisedOk = True;
return bzf; return bzf;
} }
/*---------------------------------------------------*/ /*---------------------------------------------------*/
void BZ2_bzWrite void BZ2_bzWrite
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
void* buf, void* buf,
int len ) int len )
{ {
Int32 n, n2, ret; Int32 n, n2, ret;
@ -994,7 +994,7 @@ void BZ2_bzWrite
if (bzf->strm.avail_out < BZ_MAX_UNUSED) { if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
n = BZ_MAX_UNUSED - bzf->strm.avail_out; n = BZ_MAX_UNUSED - bzf->strm.avail_out;
n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
n, bzf->handle ); n, bzf->handle );
if (n != n2 || ferror(bzf->handle)) if (n != n2 || ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return; }; { BZ_SETERR(BZ_IO_ERROR); return; };
@ -1008,20 +1008,20 @@ void BZ2_bzWrite
/*---------------------------------------------------*/ /*---------------------------------------------------*/
void BZ2_bzWriteClose void BZ2_bzWriteClose
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
int abandon, int abandon,
unsigned int* nbytes_in, unsigned int* nbytes_in,
unsigned int* nbytes_out ) unsigned int* nbytes_out )
{ {
BZ2_bzWriteClose64 ( bzerror, b, abandon, BZ2_bzWriteClose64 ( bzerror, b, abandon,
nbytes_in, NULL, nbytes_out, NULL ); nbytes_in, NULL, nbytes_out, NULL );
} }
void BZ2_bzWriteClose64 void BZ2_bzWriteClose64
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
int abandon, int abandon,
unsigned int* nbytes_in_lo32, unsigned int* nbytes_in_lo32,
unsigned int* nbytes_in_hi32, unsigned int* nbytes_in_hi32,
@ -1053,7 +1053,7 @@ void BZ2_bzWriteClose64
if (bzf->strm.avail_out < BZ_MAX_UNUSED) { if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
n = BZ_MAX_UNUSED - bzf->strm.avail_out; n = BZ_MAX_UNUSED - bzf->strm.avail_out;
n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
n, bzf->handle ); n, bzf->handle );
if (n != n2 || ferror(bzf->handle)) if (n != n2 || ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return; }; { BZ_SETERR(BZ_IO_ERROR); return; };
@ -1085,9 +1085,9 @@ void BZ2_bzWriteClose64
/*---------------------------------------------------*/ /*---------------------------------------------------*/
BZFILE* BZ2_bzReadOpen BZFILE* BZ2_bzReadOpen
( int* bzerror, ( int* bzerror,
FILE* f, FILE* f,
int verbosity, int verbosity,
int small, int small,
void* unused, void* unused,
@ -1098,7 +1098,7 @@ BZFILE* BZ2_bzReadOpen
BZ_SETERR(BZ_OK); BZ_SETERR(BZ_OK);
if (f == NULL || if (f == NULL ||
(small != 0 && small != 1) || (small != 0 && small != 1) ||
(verbosity < 0 || verbosity > 4) || (verbosity < 0 || verbosity > 4) ||
(unused == NULL && nUnused != 0) || (unused == NULL && nUnused != 0) ||
@ -1109,7 +1109,7 @@ BZFILE* BZ2_bzReadOpen
{ BZ_SETERR(BZ_IO_ERROR); return NULL; }; { BZ_SETERR(BZ_IO_ERROR); return NULL; };
bzf = malloc ( sizeof(bzFile) ); bzf = malloc ( sizeof(bzFile) );
if (bzf == NULL) if (bzf == NULL)
{ BZ_SETERR(BZ_MEM_ERROR); return NULL; }; { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
BZ_SETERR(BZ_OK); BZ_SETERR(BZ_OK);
@ -1121,7 +1121,7 @@ BZFILE* BZ2_bzReadOpen
bzf->strm.bzalloc = NULL; bzf->strm.bzalloc = NULL;
bzf->strm.bzfree = NULL; bzf->strm.bzfree = NULL;
bzf->strm.opaque = NULL; bzf->strm.opaque = NULL;
while (nUnused > 0) { while (nUnused > 0) {
bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++; bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
unused = ((void*)( 1 + ((UChar*)(unused)) )); unused = ((void*)( 1 + ((UChar*)(unused)) ));
@ -1136,7 +1136,7 @@ BZFILE* BZ2_bzReadOpen
bzf->strm.next_in = bzf->buf; bzf->strm.next_in = bzf->buf;
bzf->initialisedOk = True; bzf->initialisedOk = True;
return bzf; return bzf;
} }
@ -1159,10 +1159,10 @@ void BZ2_bzReadClose ( int *bzerror, BZFILE *b )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ2_bzRead int BZ2_bzRead
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
void* buf, void* buf,
int len ) int len )
{ {
Int32 n, ret; Int32 n, ret;
@ -1184,11 +1184,11 @@ int BZ2_bzRead
while (True) { while (True) {
if (ferror(bzf->handle)) if (ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return 0; }; { BZ_SETERR(BZ_IO_ERROR); return 0; };
if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) { if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
n = fread ( bzf->buf, sizeof(UChar), n = fread ( bzf->buf, sizeof(UChar),
BZ_MAX_UNUSED, bzf->handle ); BZ_MAX_UNUSED, bzf->handle );
if (ferror(bzf->handle)) if (ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return 0; }; { BZ_SETERR(BZ_IO_ERROR); return 0; };
@ -1202,7 +1202,7 @@ int BZ2_bzRead
if (ret != BZ_OK && ret != BZ_STREAM_END) if (ret != BZ_OK && ret != BZ_STREAM_END)
{ BZ_SETERR(ret); return 0; }; { BZ_SETERR(ret); return 0; };
if (ret == BZ_OK && myfeof(bzf->handle) && if (ret == BZ_OK && myfeof(bzf->handle) &&
bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
{ BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }; { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
@ -1211,7 +1211,7 @@ int BZ2_bzRead
return len - bzf->strm.avail_out; }; return len - bzf->strm.avail_out; };
if (bzf->strm.avail_out == 0) if (bzf->strm.avail_out == 0)
{ BZ_SETERR(BZ_OK); return len; }; { BZ_SETERR(BZ_OK); return len; };
} }
return 0; /*not reached*/ return 0; /*not reached*/
@ -1219,10 +1219,10 @@ int BZ2_bzRead
/*---------------------------------------------------*/ /*---------------------------------------------------*/
void BZ2_bzReadGetUnused void BZ2_bzReadGetUnused
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
void** unused, void** unused,
int* nUnused ) int* nUnused )
{ {
bzFile* bzf = (bzFile*)b; bzFile* bzf = (bzFile*)b;
@ -1244,30 +1244,30 @@ void BZ2_bzReadGetUnused
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ2_bzBuffToBuffCompress int BZ2_bzBuffToBuffCompress
( char* dest, ( char* dest,
unsigned int* destLen, unsigned int* destLen,
char* source, char* source,
unsigned int sourceLen, unsigned int sourceLen,
int blockSize100k, int blockSize100k,
int verbosity, int verbosity,
int workFactor ) int workFactor )
{ {
bz_stream strm; bz_stream strm;
int ret; int ret;
if (dest == NULL || destLen == NULL || if (dest == NULL || destLen == NULL ||
source == NULL || source == NULL ||
blockSize100k < 1 || blockSize100k > 9 || blockSize100k < 1 || blockSize100k > 9 ||
verbosity < 0 || verbosity > 4 || verbosity < 0 || verbosity > 4 ||
workFactor < 0 || workFactor > 250) workFactor < 0 || workFactor > 250)
return BZ_PARAM_ERROR; return BZ_PARAM_ERROR;
if (workFactor == 0) workFactor = 30; if (workFactor == 0) workFactor = 30;
strm.bzalloc = NULL; strm.bzalloc = NULL;
strm.bzfree = NULL; strm.bzfree = NULL;
strm.opaque = NULL; strm.opaque = NULL;
ret = BZ2_bzCompressInit ( &strm, blockSize100k, ret = BZ2_bzCompressInit ( &strm, blockSize100k,
verbosity, workFactor ); verbosity, workFactor );
if (ret != BZ_OK) return ret; if (ret != BZ_OK) return ret;
@ -1281,7 +1281,7 @@ int BZ2_bzBuffToBuffCompress
if (ret != BZ_STREAM_END) goto errhandler; if (ret != BZ_STREAM_END) goto errhandler;
/* normal termination */ /* normal termination */
*destLen -= strm.avail_out; *destLen -= strm.avail_out;
BZ2_bzCompressEnd ( &strm ); BZ2_bzCompressEnd ( &strm );
return BZ_OK; return BZ_OK;
@ -1296,10 +1296,10 @@ int BZ2_bzBuffToBuffCompress
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ2_bzBuffToBuffDecompress int BZ2_bzBuffToBuffDecompress
( char* dest, ( char* dest,
unsigned int* destLen, unsigned int* destLen,
char* source, char* source,
unsigned int sourceLen, unsigned int sourceLen,
int small, int small,
int verbosity ) int verbosity )
@ -1307,10 +1307,10 @@ int BZ2_bzBuffToBuffDecompress
bz_stream strm; bz_stream strm;
int ret; int ret;
if (dest == NULL || destLen == NULL || if (dest == NULL || destLen == NULL ||
source == NULL || source == NULL ||
(small != 0 && small != 1) || (small != 0 && small != 1) ||
verbosity < 0 || verbosity > 4) verbosity < 0 || verbosity > 4)
return BZ_PARAM_ERROR; return BZ_PARAM_ERROR;
strm.bzalloc = NULL; strm.bzalloc = NULL;
@ -1340,11 +1340,11 @@ int BZ2_bzBuffToBuffDecompress
} else { } else {
BZ2_bzDecompressEnd ( &strm ); BZ2_bzDecompressEnd ( &strm );
return BZ_OUTBUFF_FULL; return BZ_OUTBUFF_FULL;
}; };
errhandler: errhandler:
BZ2_bzDecompressEnd ( &strm ); BZ2_bzDecompressEnd ( &strm );
return ret; return ret;
} }
@ -1396,7 +1396,7 @@ BZFILE * bzopen_or_bzdopen
int verbosity = 0; int verbosity = 0;
int workFactor = 30; int workFactor = 30;
int smallMode = 0; int smallMode = 0;
int nUnused = 0; int nUnused = 0;
if (mode == NULL) return NULL; if (mode == NULL) return NULL;
while (*mode) { while (*mode) {
@ -1436,7 +1436,7 @@ BZFILE * bzopen_or_bzdopen
if (writing) { if (writing) {
/* Guard against total chaos and anarchy -- JRS */ /* Guard against total chaos and anarchy -- JRS */
if (blockSize100k < 1) blockSize100k = 1; if (blockSize100k < 1) blockSize100k = 1;
if (blockSize100k > 9) blockSize100k = 9; if (blockSize100k > 9) blockSize100k = 9;
bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k,
verbosity,workFactor); verbosity,workFactor);
} else { } else {
@ -1515,7 +1515,7 @@ void BZ2_bzclose (BZFILE* b)
{ {
int bzerr; int bzerr;
FILE *fp; FILE *fp;
if (b==NULL) {return;} if (b==NULL) {return;}
fp = ((bzFile *)b)->handle; fp = ((bzFile *)b)->handle;
if(((bzFile*)b)->writing){ if(((bzFile*)b)->writing){
@ -1534,7 +1534,7 @@ void BZ2_bzclose (BZFILE* b)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*-- /*--
return last error code return last error code
--*/ --*/
static const char *bzerrorstrings[] = { static const char *bzerrorstrings[] = {
"OK" "OK"

View file

@ -16,7 +16,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -40,7 +40,7 @@ typedef unsigned short UInt16;
#ifndef __GNUC__ #ifndef __GNUC__
#define __inline__ /* */ #define __inline__ /* */
#endif #endif
#ifndef BZ_NO_STDIO #ifndef BZ_NO_STDIO
@ -98,7 +98,7 @@ extern void bz_internal_error ( int errcode );
#define BZ_HDR_Z 0x5a /* 'Z' */ #define BZ_HDR_Z 0x5a /* 'Z' */
#define BZ_HDR_h 0x68 /* 'h' */ #define BZ_HDR_h 0x68 /* 'h' */
#define BZ_HDR_0 0x30 /* '0' */ #define BZ_HDR_0 0x30 /* '0' */
/*-- Constants for the back end. --*/ /*-- Constants for the back end. --*/
#define BZ_MAX_ALPHA_SIZE 258 #define BZ_MAX_ALPHA_SIZE 258
@ -258,19 +258,19 @@ typedef
/*-- externs for compression. --*/ /*-- externs for compression. --*/
extern void extern void
BZ2_blockSort ( EState* ); BZ2_blockSort ( EState* );
extern void extern void
BZ2_compressBlock ( EState*, Bool ); BZ2_compressBlock ( EState*, Bool );
extern void extern void
BZ2_bsInitWrite ( EState* ); BZ2_bsInitWrite ( EState* );
extern void extern void
BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
extern void extern void
BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
@ -414,7 +414,7 @@ typedef
Int32 save_N; Int32 save_N;
Int32 save_curr; Int32 save_curr;
Int32 save_zt; Int32 save_zt;
Int32 save_zn; Int32 save_zn;
Int32 save_zvec; Int32 save_zvec;
Int32 save_zj; Int32 save_zj;
Int32 save_gSel; Int32 save_gSel;
@ -470,12 +470,12 @@ typedef
/*-- externs for decompression. --*/ /*-- externs for decompression. --*/
extern Int32 extern Int32
BZ2_indexIntoF ( Int32, Int32* ); BZ2_indexIntoF ( Int32, Int32* );
extern Int32 extern Int32
BZ2_decompress ( DState* ); BZ2_decompress ( DState* );
extern void extern void
BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
Int32, Int32, Int32 ); Int32, Int32, Int32 );

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# Bzmore wrapped for bzip2, # Bzmore wrapped for bzip2,
# adapted from zmore by Philippe Troin <phil@fifi.org> for Debian GNU/Linux. # adapted from zmore by Philippe Troin <phil@fifi.org> for Debian GNU/Linux.
PATH="/usr/bin:$PATH"; export PATH PATH="/usr/bin:$PATH"; export PATH
@ -43,7 +43,7 @@ else
if test $FIRST -eq 0; then if test $FIRST -eq 0; then
echo $n1 "--More--(Next file: $FILE)$n2" echo $n1 "--More--(Next file: $FILE)$n2"
stty $cb -echo 2>/dev/null stty $cb -echo 2>/dev/null
ANS=`dd bs=1 count=1 2>/dev/null` ANS=`dd bs=1 count=1 2>/dev/null`
stty $ncb echo 2>/dev/null stty $ncb echo 2>/dev/null
echo " " echo " "
if test "$ANS" = 'e' -o "$ANS" = 'q'; then if test "$ANS" = 'e' -o "$ANS" = 'q'; then

View file

@ -78,15 +78,15 @@ skip \fIi\fP screenfuls and print a screenful of lines
quit reading the current file; go on to the next (if any) quit reading the current file; go on to the next (if any)
.PP .PP
.IP "e or q" .IP "e or q"
When the prompt --More--(Next file: When the prompt --More--(Next file:
.IR file ) .IR file )
is printed, this command causes bzmore to exit. is printed, this command causes bzmore to exit.
.PP .PP
.IP s .IP s
When the prompt --More--(Next file: When the prompt --More--(Next file:
.IR file ) .IR file )
is printed, this command causes bzmore to skip the next file and continue. is printed, this command causes bzmore to skip the next file and continue.
.PP .PP
.IP = .IP =
Display the current line number. Display the current line number.
.PP .PP
@ -105,7 +105,7 @@ Erasing back past the first column cancels the search command.
search for the \fIi\|\fP-th occurrence of the last regular expression entered. search for the \fIi\|\fP-th occurrence of the last regular expression entered.
.PP .PP
.IP !command .IP !command
invoke a shell with \fIcommand\|\fP. invoke a shell with \fIcommand\|\fP.
The character `!' in "command" are replaced with the The character `!' in "command" are replaced with the
previous shell command. The sequence "\\!" is replaced by "!". previous shell command. The sequence "\\!" is replaced by "!".
.PP .PP

View file

@ -12,7 +12,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -23,7 +23,7 @@
/* CHANGES /* CHANGES
0.9.0 -- original version. 0.9.0 -- original version.
0.9.0a/b -- no changes in this file. 0.9.0a/b -- no changes in this file.
0.9.0c -- changed setting of nGroups in sendMTFValues() 0.9.0c -- changed setting of nGroups in sendMTFValues()
so as to do a bit better on small files so as to do a bit better on small files
*/ */
@ -126,11 +126,11 @@ void generateMTFValues ( EState* s )
Int32 wr; Int32 wr;
Int32 EOB; Int32 EOB;
/* /*
After sorting (eg, here), After sorting (eg, here),
s->arr1 [ 0 .. s->nblock-1 ] holds sorted order, s->arr1 [ 0 .. s->nblock-1 ] holds sorted order,
and and
((UChar*)s->arr2) [ 0 .. s->nblock-1 ] ((UChar*)s->arr2) [ 0 .. s->nblock-1 ]
holds the original block data. holds the original block data.
The first thing to do is generate the MTF values, The first thing to do is generate the MTF values,
@ -145,7 +145,7 @@ void generateMTFValues ( EState* s )
(UChar*) (&((UChar*)s->arr2)[s->nblock]) (UChar*) (&((UChar*)s->arr2)[s->nblock])
These storage aliases are set up in bzCompressInit(), These storage aliases are set up in bzCompressInit(),
except for the last one, which is arranged in except for the last one, which is arranged in
compressBlock(). compressBlock().
*/ */
UInt32* ptr = s->ptr; UInt32* ptr = s->ptr;
@ -168,7 +168,7 @@ void generateMTFValues ( EState* s )
ll_i = s->unseqToSeq[block[j]]; ll_i = s->unseqToSeq[block[j]];
AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" ); AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" );
if (yy[0] == ll_i) { if (yy[0] == ll_i) {
zPend++; zPend++;
} else { } else {
@ -176,11 +176,11 @@ void generateMTFValues ( EState* s )
zPend--; zPend--;
while (True) { while (True) {
if (zPend & 1) { if (zPend & 1) {
mtfv[wr] = BZ_RUNB; wr++; mtfv[wr] = BZ_RUNB; wr++;
s->mtfFreq[BZ_RUNB]++; s->mtfFreq[BZ_RUNB]++;
} else { } else {
mtfv[wr] = BZ_RUNA; wr++; mtfv[wr] = BZ_RUNA; wr++;
s->mtfFreq[BZ_RUNA]++; s->mtfFreq[BZ_RUNA]++;
} }
if (zPend < 2) break; if (zPend < 2) break;
zPend = (zPend - 2) / 2; zPend = (zPend - 2) / 2;
@ -214,11 +214,11 @@ void generateMTFValues ( EState* s )
zPend--; zPend--;
while (True) { while (True) {
if (zPend & 1) { if (zPend & 1) {
mtfv[wr] = BZ_RUNB; wr++; mtfv[wr] = BZ_RUNB; wr++;
s->mtfFreq[BZ_RUNB]++; s->mtfFreq[BZ_RUNB]++;
} else { } else {
mtfv[wr] = BZ_RUNA; wr++; mtfv[wr] = BZ_RUNA; wr++;
s->mtfFreq[BZ_RUNA]++; s->mtfFreq[BZ_RUNA]++;
} }
if (zPend < 2) break; if (zPend < 2) break;
zPend = (zPend - 2) / 2; zPend = (zPend - 2) / 2;
@ -261,7 +261,7 @@ void sendMTFValues ( EState* s )
if (s->verbosity >= 3) if (s->verbosity >= 3)
VPrintf3( " %d in block, %d after MTF & 1-2 coding, " VPrintf3( " %d in block, %d after MTF & 1-2 coding, "
"%d+2 syms in use\n", "%d+2 syms in use\n",
s->nblock, s->nMTF, s->nInUse ); s->nblock, s->nMTF, s->nInUse );
alphaSize = s->nInUse+2; alphaSize = s->nInUse+2;
@ -278,7 +278,7 @@ void sendMTFValues ( EState* s )
nGroups = 6; nGroups = 6;
/*--- Generate an initial set of coding tables ---*/ /*--- Generate an initial set of coding tables ---*/
{ {
Int32 nPart, remF, tFreq, aFreq; Int32 nPart, remF, tFreq, aFreq;
nPart = nGroups; nPart = nGroups;
@ -293,8 +293,8 @@ void sendMTFValues ( EState* s )
aFreq += s->mtfFreq[ge]; aFreq += s->mtfFreq[ge];
} }
if (ge > gs if (ge > gs
&& nPart != nGroups && nPart != 1 && nPart != nGroups && nPart != 1
&& ((nGroups-nPart) % 2 == 1)) { && ((nGroups-nPart) % 2 == 1)) {
aFreq -= s->mtfFreq[ge]; aFreq -= s->mtfFreq[ge];
ge--; ge--;
@ -303,21 +303,21 @@ void sendMTFValues ( EState* s )
if (s->verbosity >= 3) if (s->verbosity >= 3)
VPrintf5( " initial group %d, [%d .. %d], " VPrintf5( " initial group %d, [%d .. %d], "
"has %d syms (%4.1f%%)\n", "has %d syms (%4.1f%%)\n",
nPart, gs, ge, aFreq, nPart, gs, ge, aFreq,
(100.0 * (float)aFreq) / (float)(s->nMTF) ); (100.0 * (float)aFreq) / (float)(s->nMTF) );
for (v = 0; v < alphaSize; v++) for (v = 0; v < alphaSize; v++)
if (v >= gs && v <= ge) if (v >= gs && v <= ge)
s->len[nPart-1][v] = BZ_LESSER_ICOST; else s->len[nPart-1][v] = BZ_LESSER_ICOST; else
s->len[nPart-1][v] = BZ_GREATER_ICOST; s->len[nPart-1][v] = BZ_GREATER_ICOST;
nPart--; nPart--;
gs = ge+1; gs = ge+1;
remF -= aFreq; remF -= aFreq;
} }
} }
/*--- /*---
Iterate up to BZ_N_ITERS times to improve the tables. Iterate up to BZ_N_ITERS times to improve the tables.
---*/ ---*/
for (iter = 0; iter < BZ_N_ITERS; iter++) { for (iter = 0; iter < BZ_N_ITERS; iter++) {
@ -330,7 +330,7 @@ void sendMTFValues ( EState* s )
/*--- /*---
Set up an auxiliary length table which is used to fast-track Set up an auxiliary length table which is used to fast-track
the common case (nGroups == 6). the common case (nGroups == 6).
---*/ ---*/
if (nGroups == 6) { if (nGroups == 6) {
for (v = 0; v < alphaSize; v++) { for (v = 0; v < alphaSize; v++) {
@ -347,10 +347,10 @@ void sendMTFValues ( EState* s )
/*--- Set group start & end marks. --*/ /*--- Set group start & end marks. --*/
if (gs >= s->nMTF) break; if (gs >= s->nMTF) break;
ge = gs + BZ_G_SIZE - 1; ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF) ge = s->nMTF-1; if (ge >= s->nMTF) ge = s->nMTF-1;
/*-- /*--
Calculate the cost of this group as coded Calculate the cost of this group as coded
by each of the coding tables. by each of the coding tables.
--*/ --*/
@ -387,13 +387,13 @@ void sendMTFValues ( EState* s )
} else { } else {
/*--- slow version which correctly handles all situations ---*/ /*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++) { for (i = gs; i <= ge; i++) {
UInt16 icv = mtfv[i]; UInt16 icv = mtfv[i];
for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
} }
} }
/*-- /*--
Find the coding table which is best for this group, Find the coding table which is best for this group,
and record its identity in the selector table. and record its identity in the selector table.
--*/ --*/
@ -405,7 +405,7 @@ void sendMTFValues ( EState* s )
s->selector[nSelectors] = bt; s->selector[nSelectors] = bt;
nSelectors++; nSelectors++;
/*-- /*--
Increment the symbol frequencies for the selected table. Increment the symbol frequencies for the selected table.
--*/ --*/
if (nGroups == 6 && 50 == ge-gs+1) { if (nGroups == 6 && 50 == ge-gs+1) {
@ -435,7 +435,7 @@ void sendMTFValues ( EState* s )
gs = ge+1; gs = ge+1;
} }
if (s->verbosity >= 3) { if (s->verbosity >= 3) {
VPrintf2 ( " pass %d: size is %d, grp uses are ", VPrintf2 ( " pass %d: size is %d, grp uses are ",
iter+1, totc/8 ); iter+1, totc/8 );
for (t = 0; t < nGroups; t++) for (t = 0; t < nGroups; t++)
VPrintf1 ( "%d ", fave[t] ); VPrintf1 ( "%d ", fave[t] );
@ -445,10 +445,10 @@ void sendMTFValues ( EState* s )
/*-- /*--
Recompute the tables based on the accumulated frequencies. Recompute the tables based on the accumulated frequencies.
--*/ --*/
/* maxLen was changed from 20 to 17 in bzip2-1.0.3. See /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
comment in huffman.c for details. */ comment in huffman.c for details. */
for (t = 0; t < nGroups; t++) for (t = 0; t < nGroups; t++)
BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
alphaSize, 17 /*20*/ ); alphaSize, 17 /*20*/ );
} }
@ -488,19 +488,19 @@ void sendMTFValues ( EState* s )
} }
AssertH ( !(maxLen > 17 /*20*/ ), 3004 ); AssertH ( !(maxLen > 17 /*20*/ ), 3004 );
AssertH ( !(minLen < 1), 3005 ); AssertH ( !(minLen < 1), 3005 );
BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
minLen, maxLen, alphaSize ); minLen, maxLen, alphaSize );
} }
/*--- Transmit the mapping table. ---*/ /*--- Transmit the mapping table. ---*/
{ {
Bool inUse16[16]; Bool inUse16[16];
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
inUse16[i] = False; inUse16[i] = False;
for (j = 0; j < 16; j++) for (j = 0; j < 16; j++)
if (s->inUse[i * 16 + j]) inUse16[i] = True; if (s->inUse[i * 16 + j]) inUse16[i] = True;
} }
nBytes = s->numZ; nBytes = s->numZ;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0); if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0);
@ -511,7 +511,7 @@ void sendMTFValues ( EState* s )
if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0); if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0);
} }
if (s->verbosity >= 3) if (s->verbosity >= 3)
VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes ); VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes );
} }
@ -519,7 +519,7 @@ void sendMTFValues ( EState* s )
nBytes = s->numZ; nBytes = s->numZ;
bsW ( s, 3, nGroups ); bsW ( s, 3, nGroups );
bsW ( s, 15, nSelectors ); bsW ( s, 15, nSelectors );
for (i = 0; i < nSelectors; i++) { for (i = 0; i < nSelectors; i++) {
for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1); for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1);
bsW(s,1,0); bsW(s,1,0);
} }
@ -548,14 +548,14 @@ void sendMTFValues ( EState* s )
gs = 0; gs = 0;
while (True) { while (True) {
if (gs >= s->nMTF) break; if (gs >= s->nMTF) break;
ge = gs + BZ_G_SIZE - 1; ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF) ge = s->nMTF-1; if (ge >= s->nMTF) ge = s->nMTF-1;
AssertH ( s->selector[selCtr] < nGroups, 3006 ); AssertH ( s->selector[selCtr] < nGroups, 3006 );
if (nGroups == 6 && 50 == ge-gs+1) { if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/ /*--- fast track the common case ---*/
UInt16 mtfv_i; UInt16 mtfv_i;
UChar* s_len_sel_selCtr UChar* s_len_sel_selCtr
= &(s->len[s->selector[selCtr]][0]); = &(s->len[s->selector[selCtr]][0]);
Int32* s_code_sel_selCtr Int32* s_code_sel_selCtr
= &(s->code[s->selector[selCtr]][0]); = &(s->code[s->selector[selCtr]][0]);
@ -582,7 +582,7 @@ void sendMTFValues ( EState* s )
} else { } else {
/*--- slow version which correctly handles all situations ---*/ /*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++) { for (i = gs; i <= ge; i++) {
bsW ( s, bsW ( s,
s->len [s->selector[selCtr]] [mtfv[i]], s->len [s->selector[selCtr]] [mtfv[i]],
s->code [s->selector[selCtr]] [mtfv[i]] ); s->code [s->selector[selCtr]] [mtfv[i]] );
} }
@ -637,8 +637,8 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block )
/*-- Now the block's CRC, so it is in a known place. --*/ /*-- Now the block's CRC, so it is in a known place. --*/
bsPutUInt32 ( s, s->blockCRC ); bsPutUInt32 ( s, s->blockCRC );
/*-- /*--
Now a single bit indicating (non-)randomisation. Now a single bit indicating (non-)randomisation.
As of version 0.9.5, we use a better sorting algorithm As of version 0.9.5, we use a better sorting algorithm
which makes randomisation unnecessary. So always set which makes randomisation unnecessary. So always set
the randomised bit to 'no'. Of course, the decoder the randomised bit to 'no'. Of course, the decoder

View file

@ -12,7 +12,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -128,7 +128,7 @@ Int32 BZ2_decompress ( DState* s )
Int32 N; Int32 N;
Int32 curr; Int32 curr;
Int32 zt; Int32 zt;
Int32 zn; Int32 zn;
Int32 zvec; Int32 zvec;
Int32 zj; Int32 zj;
Int32 gSel; Int32 gSel;
@ -182,7 +182,7 @@ Int32 BZ2_decompress ( DState* s )
N = s->save_N; N = s->save_N;
curr = s->save_curr; curr = s->save_curr;
zt = s->save_zt; zt = s->save_zt;
zn = s->save_zn; zn = s->save_zn;
zvec = s->save_zvec; zvec = s->save_zvec;
zj = s->save_zj; zj = s->save_zj;
gSel = s->save_gSel; gSel = s->save_gSel;
@ -205,14 +205,14 @@ Int32 BZ2_decompress ( DState* s )
if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC); if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
if (s->blockSize100k < (BZ_HDR_0 + 1) || if (s->blockSize100k < (BZ_HDR_0 + 1) ||
s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC); s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
s->blockSize100k -= BZ_HDR_0; s->blockSize100k -= BZ_HDR_0;
if (s->smallDecompress) { if (s->smallDecompress) {
s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
s->ll4 = BZALLOC( s->ll4 = BZALLOC(
((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
); );
if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
} else { } else {
@ -238,7 +238,7 @@ Int32 BZ2_decompress ( DState* s )
s->currBlockNo++; s->currBlockNo++;
if (s->verbosity >= 2) if (s->verbosity >= 2)
VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
s->storedBlockCRC = 0; s->storedBlockCRC = 0;
GET_UCHAR(BZ_X_BCRC_1, uc); GET_UCHAR(BZ_X_BCRC_1, uc);
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
@ -261,14 +261,14 @@ Int32 BZ2_decompress ( DState* s )
if (s->origPtr < 0) if (s->origPtr < 0)
RETURN(BZ_DATA_ERROR); RETURN(BZ_DATA_ERROR);
if (s->origPtr > 10 + 100000*s->blockSize100k) if (s->origPtr > 10 + 100000*s->blockSize100k)
RETURN(BZ_DATA_ERROR); RETURN(BZ_DATA_ERROR);
/*--- Receive the mapping table ---*/ /*--- Receive the mapping table ---*/
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
GET_BIT(BZ_X_MAPPING_1, uc); GET_BIT(BZ_X_MAPPING_1, uc);
if (uc == 1) if (uc == 1)
s->inUse16[i] = True; else s->inUse16[i] = True; else
s->inUse16[i] = False; s->inUse16[i] = False;
} }
@ -310,7 +310,7 @@ Int32 BZ2_decompress ( DState* s )
{ {
UChar pos[BZ_N_GROUPS], tmp, v; UChar pos[BZ_N_GROUPS], tmp, v;
for (v = 0; v < nGroups; v++) pos[v] = v; for (v = 0; v < nGroups; v++) pos[v] = v;
for (i = 0; i < nSelectors; i++) { for (i = 0; i < nSelectors; i++) {
v = s->selectorMtf[i]; v = s->selectorMtf[i];
tmp = pos[v]; tmp = pos[v];
@ -343,10 +343,10 @@ Int32 BZ2_decompress ( DState* s )
if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
if (s->len[t][i] < minLen) minLen = s->len[t][i]; if (s->len[t][i] < minLen) minLen = s->len[t][i];
} }
BZ2_hbCreateDecodeTables ( BZ2_hbCreateDecodeTables (
&(s->limit[t][0]), &(s->limit[t][0]),
&(s->base[t][0]), &(s->base[t][0]),
&(s->perm[t][0]), &(s->perm[t][0]),
&(s->len[t][0]), &(s->len[t][0]),
minLen, maxLen, alphaSize minLen, maxLen, alphaSize
); );
@ -445,23 +445,23 @@ Int32 BZ2_decompress ( DState* s )
s->mtfa[(z)-3] = s->mtfa[(z)-4]; s->mtfa[(z)-3] = s->mtfa[(z)-4];
nn -= 4; nn -= 4;
} }
while (nn > 0) { while (nn > 0) {
s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
}; };
s->mtfa[pp] = uc; s->mtfa[pp] = uc;
} else { } else {
/* general case */ /* general case */
lno = nn / MTFL_SIZE; lno = nn / MTFL_SIZE;
off = nn % MTFL_SIZE; off = nn % MTFL_SIZE;
pp = s->mtfbase[lno] + off; pp = s->mtfbase[lno] + off;
uc = s->mtfa[pp]; uc = s->mtfa[pp];
while (pp > s->mtfbase[lno]) { while (pp > s->mtfbase[lno]) {
s->mtfa[pp] = s->mtfa[pp-1]; pp--; s->mtfa[pp] = s->mtfa[pp-1]; pp--;
}; };
s->mtfbase[lno]++; s->mtfbase[lno]++;
while (lno > 0) { while (lno > 0) {
s->mtfbase[lno]--; s->mtfbase[lno]--;
s->mtfa[s->mtfbase[lno]] s->mtfa[s->mtfbase[lno]]
= s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
lno--; lno--;
} }
@ -556,7 +556,7 @@ Int32 BZ2_decompress ( DState* s )
if (s->blockRandomised) { if (s->blockRandomised) {
BZ_RAND_INIT_MASK; BZ_RAND_INIT_MASK;
BZ_GET_SMALL(s->k0); s->nblock_used++; BZ_GET_SMALL(s->k0); s->nblock_used++;
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
} else { } else {
BZ_GET_SMALL(s->k0); s->nblock_used++; BZ_GET_SMALL(s->k0); s->nblock_used++;
} }
@ -575,7 +575,7 @@ Int32 BZ2_decompress ( DState* s )
if (s->blockRandomised) { if (s->blockRandomised) {
BZ_RAND_INIT_MASK; BZ_RAND_INIT_MASK;
BZ_GET_FAST(s->k0); s->nblock_used++; BZ_GET_FAST(s->k0); s->nblock_used++;
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
} else { } else {
BZ_GET_FAST(s->k0); s->nblock_used++; BZ_GET_FAST(s->k0); s->nblock_used++;
} }
@ -644,7 +644,7 @@ Int32 BZ2_decompress ( DState* s )
s->save_gBase = gBase; s->save_gBase = gBase;
s->save_gPerm = gPerm; s->save_gPerm = gPerm;
return retVal; return retVal;
} }

View file

@ -7,7 +7,7 @@
# bzip2/libbzip2 version 1.0.8 of 13 July 2019 # bzip2/libbzip2 version 1.0.8 of 13 July 2019
# Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> # Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
# #
# Please read the WARNING, DISCLAIMER and PATENTS sections in the # Please read the WARNING, DISCLAIMER and PATENTS sections in the
# README file. # README file.
# #
# This program is released under the terms of the license contained # This program is released under the terms of the license contained
@ -30,14 +30,14 @@ if (! -r $infile) {
die "Can't read input $infile\n"; die "Can't read input $infile\n";
} }
# check we can open infile # check we can open infile
open( INFILE,"<$infile" ) or open( INFILE,"<$infile" ) or
die "Can't input $infile $!"; die "Can't input $infile $!";
#my $outfile = 'fmt-manual.xml'; #my $outfile = 'fmt-manual.xml';
my $outfile = shift; my $outfile = shift;
#print "Infile: $infile, Outfile: $outfile\n"; #print "Infile: $infile, Outfile: $outfile\n";
# check we can write to outfile # check we can write to outfile
open( OUTFILE,">$outfile" ) or open( OUTFILE,">$outfile" ) or
die "Can't output $outfile $! for writing"; die "Can't output $outfile $! for writing";
my ($prev, $curr, $str); my ($prev, $curr, $str);

View file

@ -12,7 +12,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -63,7 +63,7 @@
/*---------------------------------------------------*/ /*---------------------------------------------------*/
void BZ2_hbMakeCodeLengths ( UChar *len, void BZ2_hbMakeCodeLengths ( UChar *len,
Int32 *freq, Int32 *freq,
Int32 alphaSize, Int32 alphaSize,
Int32 maxLen ) Int32 maxLen )
@ -99,7 +99,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
} }
AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
while (nHeap > 1) { while (nHeap > 1) {
n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
@ -122,7 +122,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
len[i-1] = j; len[i-1] = j;
if (j > maxLen) tooLong = True; if (j > maxLen) tooLong = True;
} }
if (! tooLong) break; if (! tooLong) break;
/* 17 Oct 04: keep-going condition for the following loop used /* 17 Oct 04: keep-going condition for the following loop used

View file

@ -12,7 +12,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained
@ -24,58 +24,58 @@
/*---------------------------------------------*/ /*---------------------------------------------*/
Int32 BZ2_rNums[512] = { Int32 BZ2_rNums[512] = {
619, 720, 127, 481, 931, 816, 813, 233, 566, 247, 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
985, 724, 205, 454, 863, 491, 741, 242, 949, 214, 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
733, 859, 335, 708, 621, 574, 73, 654, 730, 472, 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
419, 436, 278, 496, 867, 210, 399, 680, 480, 51, 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
878, 465, 811, 169, 869, 675, 611, 697, 867, 561, 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
862, 687, 507, 283, 482, 129, 807, 591, 733, 623, 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
150, 238, 59, 379, 684, 877, 625, 169, 643, 105, 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
170, 607, 520, 932, 727, 476, 693, 425, 174, 647, 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
73, 122, 335, 530, 442, 853, 695, 249, 445, 515, 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
909, 545, 703, 919, 874, 474, 882, 500, 594, 612, 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
641, 801, 220, 162, 819, 984, 589, 513, 495, 799, 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
161, 604, 958, 533, 221, 400, 386, 867, 600, 782, 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
382, 596, 414, 171, 516, 375, 682, 485, 911, 276, 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
98, 553, 163, 354, 666, 933, 424, 341, 533, 870, 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
227, 730, 475, 186, 263, 647, 537, 686, 600, 224, 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
469, 68, 770, 919, 190, 373, 294, 822, 808, 206, 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
184, 943, 795, 384, 383, 461, 404, 758, 839, 887, 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
715, 67, 618, 276, 204, 918, 873, 777, 604, 560, 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
951, 160, 578, 722, 79, 804, 96, 409, 713, 940, 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
652, 934, 970, 447, 318, 353, 859, 672, 112, 785, 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
645, 863, 803, 350, 139, 93, 354, 99, 820, 908, 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
609, 772, 154, 274, 580, 184, 79, 626, 630, 742, 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
653, 282, 762, 623, 680, 81, 927, 626, 789, 125, 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
411, 521, 938, 300, 821, 78, 343, 175, 128, 250, 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
170, 774, 972, 275, 999, 639, 495, 78, 352, 126, 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
857, 956, 358, 619, 580, 124, 737, 594, 701, 612, 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
669, 112, 134, 694, 363, 992, 809, 743, 168, 974, 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
944, 375, 748, 52, 600, 747, 642, 182, 862, 81, 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
344, 805, 988, 739, 511, 655, 814, 334, 249, 515, 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
897, 955, 664, 981, 649, 113, 974, 459, 893, 228, 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
433, 837, 553, 268, 926, 240, 102, 654, 459, 51, 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
686, 754, 806, 760, 493, 403, 415, 394, 687, 700, 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
946, 670, 656, 610, 738, 392, 760, 799, 887, 653, 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
978, 321, 576, 617, 626, 502, 894, 679, 243, 440, 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
680, 879, 194, 572, 640, 724, 926, 56, 204, 700, 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
707, 151, 457, 449, 797, 195, 791, 558, 945, 679, 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
297, 59, 87, 824, 713, 663, 412, 693, 342, 606, 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
134, 108, 571, 364, 631, 212, 174, 643, 304, 329, 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
343, 97, 430, 751, 497, 314, 983, 374, 822, 928, 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
140, 206, 73, 263, 980, 736, 876, 478, 430, 305, 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
170, 514, 364, 692, 829, 82, 855, 953, 676, 246, 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
369, 970, 294, 750, 807, 827, 150, 790, 288, 923, 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
804, 378, 215, 828, 592, 281, 565, 555, 710, 82, 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
896, 831, 547, 261, 524, 462, 293, 465, 502, 56, 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
661, 821, 976, 991, 658, 869, 905, 758, 745, 193, 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
768, 550, 608, 933, 378, 286, 215, 979, 792, 961, 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
61, 688, 793, 644, 986, 403, 106, 366, 905, 644, 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
372, 567, 466, 434, 645, 210, 389, 550, 919, 135, 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
780, 773, 635, 389, 707, 100, 626, 958, 165, 504, 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
920, 176, 193, 713, 857, 265, 203, 50, 668, 108, 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
936, 638 936, 638
}; };

View file

@ -7,7 +7,7 @@
support for large files (> 2GB) in a reasonable amount of time. support for large files (> 2GB) in a reasonable amount of time.
I suggest you use the undocumented --exponential option to I suggest you use the undocumented --exponential option to
bzip2 when compressing the resulting file; this saves a bit of bzip2 when compressing the resulting file; this saves a bit of
time. Note: *don't* bother with --exponential when compressing time. Note: *don't* bother with --exponential when compressing
Real Files; it'll just waste a lot of CPU time :-) Real Files; it'll just waste a lot of CPU time :-)
(but is otherwise harmless). (but is otherwise harmless).
*/ */
@ -19,7 +19,7 @@
bzip2/libbzip2 version 1.0.8 of 13 July 2019 bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file. README file.
This program is released under the terms of the license contained This program is released under the terms of the license contained

View file

@ -1,4 +1,4 @@
Doing 6 tests (3 compress, 3 uncompress) ... Doing 6 tests (3 compress, 3 uncompress) ...
If there's a problem, things might stop at this point. If there's a problem, things might stop at this point.

View file

@ -1,13 +1,13 @@
If you got this far and the 'cmp's didn't complain, it looks If you got this far and the 'cmp's didn't complain, it looks
like you're in business. like you're in business.
To install in /usr/local/bin, /usr/local/lib, /usr/local/man and To install in /usr/local/bin, /usr/local/lib, /usr/local/man and
/usr/local/include, type /usr/local/include, type
make install make install
To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type
make install PREFIX=/xxx/yyy make install PREFIX=/xxx/yyy
@ -21,10 +21,10 @@ The -n instructs make to show the commands it would execute, but
not actually execute them. not actually execute them.
Instructions for use are in the preformatted manual page, in the file Instructions for use are in the preformatted manual page, in the file
bzip2.txt. For more detailed documentation, read the full manual. bzip2.txt. For more detailed documentation, read the full manual.
It is available in Postscript form (manual.ps), PDF form (manual.pdf), It is available in Postscript form (manual.ps), PDF form (manual.pdf),
and HTML form (manual.html). and HTML form (manual.html).
You can also do "bzip2 --help" to see some helpful information. You can also do "bzip2 --help" to see some helpful information.
"bzip2 -L" displays the software license. "bzip2 -L" displays the software license.

View file

@ -14,7 +14,7 @@
*/ */
STATIC_YOINK("huge_compiler_rt_license"); STATIC_YOINK("huge_compiler_rt_license");
#include "third_party/compiler_rt/int_lib.h" #include "third_party/compiler_rt/int_lib.h"
/* Returns: absolute value */ /* Returns: absolute value */

View file

@ -14,7 +14,7 @@
*/ */
STATIC_YOINK("huge_compiler_rt_license"); STATIC_YOINK("huge_compiler_rt_license");
#include "third_party/compiler_rt/int_lib.h" #include "third_party/compiler_rt/int_lib.h"
/* Returns: absolute value */ /* Returns: absolute value */

View file

@ -52,18 +52,18 @@ enum LE_RESULT {
COMPILER_RT_ABI enum LE_RESULT COMPILER_RT_ABI enum LE_RESULT
__ledf2(fp_t a, fp_t b) { __ledf2(fp_t a, fp_t b) {
const srep_t aInt = toRep(a); const srep_t aInt = toRep(a);
const srep_t bInt = toRep(b); const srep_t bInt = toRep(b);
const rep_t aAbs = aInt & absMask; const rep_t aAbs = aInt & absMask;
const rep_t bAbs = bInt & absMask; const rep_t bAbs = bInt & absMask;
// If either a or b is NaN, they are unordered. // If either a or b is NaN, they are unordered.
if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED;
// If a and b are both zeros, they are equal. // If a and b are both zeros, they are equal.
if ((aAbs | bAbs) == 0) return LE_EQUAL; if ((aAbs | bAbs) == 0) return LE_EQUAL;
// If at least one of a and b is positive, we get the same result comparing // If at least one of a and b is positive, we get the same result comparing
// a and b as signed integers as we would with a floating-point compare. // a and b as signed integers as we would with a floating-point compare.
if ((aInt & bInt) >= 0) { if ((aInt & bInt) >= 0) {
@ -71,7 +71,7 @@ __ledf2(fp_t a, fp_t b) {
else if (aInt == bInt) return LE_EQUAL; else if (aInt == bInt) return LE_EQUAL;
else return LE_GREATER; else return LE_GREATER;
} }
// Otherwise, both are negative, so we need to flip the sense of the // Otherwise, both are negative, so we need to flip the sense of the
// comparison to get the correct result. (This assumes a twos- or ones- // comparison to get the correct result. (This assumes a twos- or ones-
// complement integer representation; if integers are represented in a // complement integer representation; if integers are represented in a
@ -98,12 +98,12 @@ enum GE_RESULT {
COMPILER_RT_ABI enum GE_RESULT COMPILER_RT_ABI enum GE_RESULT
__gedf2(fp_t a, fp_t b) { __gedf2(fp_t a, fp_t b) {
const srep_t aInt = toRep(a); const srep_t aInt = toRep(a);
const srep_t bInt = toRep(b); const srep_t bInt = toRep(b);
const rep_t aAbs = aInt & absMask; const rep_t aAbs = aInt & absMask;
const rep_t bAbs = bInt & absMask; const rep_t bAbs = bInt & absMask;
if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED;
if ((aAbs | bAbs) == 0) return GE_EQUAL; if ((aAbs | bAbs) == 0) return GE_EQUAL;
if ((aInt & bInt) >= 0) { if ((aInt & bInt) >= 0) {

View file

@ -52,18 +52,18 @@ enum LE_RESULT {
COMPILER_RT_ABI enum LE_RESULT COMPILER_RT_ABI enum LE_RESULT
__lesf2(fp_t a, fp_t b) { __lesf2(fp_t a, fp_t b) {
const srep_t aInt = toRep(a); const srep_t aInt = toRep(a);
const srep_t bInt = toRep(b); const srep_t bInt = toRep(b);
const rep_t aAbs = aInt & absMask; const rep_t aAbs = aInt & absMask;
const rep_t bAbs = bInt & absMask; const rep_t bAbs = bInt & absMask;
// If either a or b is NaN, they are unordered. // If either a or b is NaN, they are unordered.
if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED;
// If a and b are both zeros, they are equal. // If a and b are both zeros, they are equal.
if ((aAbs | bAbs) == 0) return LE_EQUAL; if ((aAbs | bAbs) == 0) return LE_EQUAL;
// If at least one of a and b is positive, we get the same result comparing // If at least one of a and b is positive, we get the same result comparing
// a and b as signed integers as we would with a fp_ting-point compare. // a and b as signed integers as we would with a fp_ting-point compare.
if ((aInt & bInt) >= 0) { if ((aInt & bInt) >= 0) {
@ -71,7 +71,7 @@ __lesf2(fp_t a, fp_t b) {
else if (aInt == bInt) return LE_EQUAL; else if (aInt == bInt) return LE_EQUAL;
else return LE_GREATER; else return LE_GREATER;
} }
// Otherwise, both are negative, so we need to flip the sense of the // Otherwise, both are negative, so we need to flip the sense of the
// comparison to get the correct result. (This assumes a twos- or ones- // comparison to get the correct result. (This assumes a twos- or ones-
// complement integer representation; if integers are represented in a // complement integer representation; if integers are represented in a
@ -98,12 +98,12 @@ enum GE_RESULT {
COMPILER_RT_ABI enum GE_RESULT COMPILER_RT_ABI enum GE_RESULT
__gesf2(fp_t a, fp_t b) { __gesf2(fp_t a, fp_t b) {
const srep_t aInt = toRep(a); const srep_t aInt = toRep(a);
const srep_t bInt = toRep(b); const srep_t bInt = toRep(b);
const rep_t aAbs = aInt & absMask; const rep_t aAbs = aInt & absMask;
const rep_t bAbs = bInt & absMask; const rep_t bAbs = bInt & absMask;
if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED;
if ((aAbs | bAbs) == 0) return GE_EQUAL; if ((aAbs | bAbs) == 0) return GE_EQUAL;
if ((aInt & bInt) >= 0) { if ((aInt & bInt) >= 0) {

View file

@ -25,36 +25,36 @@ STATIC_YOINK("huge_compiler_rt_license");
COMPILER_RT_ABI fp_t COMPILER_RT_ABI fp_t
__divdf3(fp_t a, fp_t b) { __divdf3(fp_t a, fp_t b) {
const unsigned int aExponent = toRep(a) >> significandBits & maxExponent; const unsigned int aExponent = toRep(a) >> significandBits & maxExponent;
const unsigned int bExponent = toRep(b) >> significandBits & maxExponent; const unsigned int bExponent = toRep(b) >> significandBits & maxExponent;
const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit; const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit;
rep_t aSignificand = toRep(a) & significandMask; rep_t aSignificand = toRep(a) & significandMask;
rep_t bSignificand = toRep(b) & significandMask; rep_t bSignificand = toRep(b) & significandMask;
int scale = 0; int scale = 0;
// Detect if a or b is zero, denormal, infinity, or NaN. // Detect if a or b is zero, denormal, infinity, or NaN.
if (aExponent-1U >= maxExponent-1U || bExponent-1U >= maxExponent-1U) { if (aExponent-1U >= maxExponent-1U || bExponent-1U >= maxExponent-1U) {
const rep_t aAbs = toRep(a) & absMask; const rep_t aAbs = toRep(a) & absMask;
const rep_t bAbs = toRep(b) & absMask; const rep_t bAbs = toRep(b) & absMask;
// NaN / anything = qNaN // NaN / anything = qNaN
if (aAbs > infRep) return fromRep(toRep(a) | quietBit); if (aAbs > infRep) return fromRep(toRep(a) | quietBit);
// anything / NaN = qNaN // anything / NaN = qNaN
if (bAbs > infRep) return fromRep(toRep(b) | quietBit); if (bAbs > infRep) return fromRep(toRep(b) | quietBit);
if (aAbs == infRep) { if (aAbs == infRep) {
// infinity / infinity = NaN // infinity / infinity = NaN
if (bAbs == infRep) return fromRep(qnanRep); if (bAbs == infRep) return fromRep(qnanRep);
// infinity / anything else = +/- infinity // infinity / anything else = +/- infinity
else return fromRep(aAbs | quotientSign); else return fromRep(aAbs | quotientSign);
} }
// anything else / infinity = +/- 0 // anything else / infinity = +/- 0
if (bAbs == infRep) return fromRep(quotientSign); if (bAbs == infRep) return fromRep(quotientSign);
if (!aAbs) { if (!aAbs) {
// zero / zero = NaN // zero / zero = NaN
if (!bAbs) return fromRep(qnanRep); if (!bAbs) return fromRep(qnanRep);
@ -63,28 +63,28 @@ __divdf3(fp_t a, fp_t b) {
} }
// anything else / zero = +/- infinity // anything else / zero = +/- infinity
if (!bAbs) return fromRep(infRep | quotientSign); if (!bAbs) return fromRep(infRep | quotientSign);
// one or both of a or b is denormal, the other (if applicable) is a // one or both of a or b is denormal, the other (if applicable) is a
// normal number. Renormalize one or both of a and b, and set scale to // normal number. Renormalize one or both of a and b, and set scale to
// include the necessary exponent adjustment. // include the necessary exponent adjustment.
if (aAbs < implicitBit) scale += normalize(&aSignificand); if (aAbs < implicitBit) scale += normalize(&aSignificand);
if (bAbs < implicitBit) scale -= normalize(&bSignificand); if (bAbs < implicitBit) scale -= normalize(&bSignificand);
} }
// Or in the implicit significand bit. (If we fell through from the // Or in the implicit significand bit. (If we fell through from the
// denormal path it was already set by normalize( ), but setting it twice // denormal path it was already set by normalize( ), but setting it twice
// won't hurt anything.) // won't hurt anything.)
aSignificand |= implicitBit; aSignificand |= implicitBit;
bSignificand |= implicitBit; bSignificand |= implicitBit;
int quotientExponent = aExponent - bExponent + scale; int quotientExponent = aExponent - bExponent + scale;
// Align the significand of b as a Q31 fixed-point number in the range // Align the significand of b as a Q31 fixed-point number in the range
// [1, 2.0) and get a Q32 approximate reciprocal using a small minimax // [1, 2.0) and get a Q32 approximate reciprocal using a small minimax
// polynomial approximation: reciprocal = 3/4 + 1/sqrt(2) - b/2. This // polynomial approximation: reciprocal = 3/4 + 1/sqrt(2) - b/2. This
// is accurate to about 3.5 binary digits. // is accurate to about 3.5 binary digits.
const uint32_t q31b = bSignificand >> 21; const uint32_t q31b = bSignificand >> 21;
uint32_t recip32 = UINT32_C(0x7504f333) - q31b; uint32_t recip32 = UINT32_C(0x7504f333) - q31b;
// Now refine the reciprocal estimate using a Newton-Raphson iteration: // Now refine the reciprocal estimate using a Newton-Raphson iteration:
// //
// x1 = x0 * (2 - x0 * b) // x1 = x0 * (2 - x0 * b)
@ -99,13 +99,13 @@ __divdf3(fp_t a, fp_t b) {
recip32 = (uint64_t)recip32 * correction32 >> 31; recip32 = (uint64_t)recip32 * correction32 >> 31;
correction32 = -((uint64_t)recip32 * q31b >> 32); correction32 = -((uint64_t)recip32 * q31b >> 32);
recip32 = (uint64_t)recip32 * correction32 >> 31; recip32 = (uint64_t)recip32 * correction32 >> 31;
// recip32 might have overflowed to exactly zero in the preceding // recip32 might have overflowed to exactly zero in the preceding
// computation if the high word of b is exactly 1.0. This would sabotage // computation if the high word of b is exactly 1.0. This would sabotage
// the full-width final stage of the computation that follows, so we adjust // the full-width final stage of the computation that follows, so we adjust
// recip32 downward by one bit. // recip32 downward by one bit.
recip32--; recip32--;
// We need to perform one more iteration to get us to 56 binary digits; // We need to perform one more iteration to get us to 56 binary digits;
// The last iteration needs to happen with extra precision. // The last iteration needs to happen with extra precision.
const uint32_t q63blo = bSignificand << 11; const uint32_t q63blo = bSignificand << 11;
@ -114,14 +114,14 @@ __divdf3(fp_t a, fp_t b) {
uint32_t cHi = correction >> 32; uint32_t cHi = correction >> 32;
uint32_t cLo = correction; uint32_t cLo = correction;
reciprocal = (uint64_t)recip32*cHi + ((uint64_t)recip32*cLo >> 32); reciprocal = (uint64_t)recip32*cHi + ((uint64_t)recip32*cLo >> 32);
// We already adjusted the 32-bit estimate, now we need to adjust the final // We already adjusted the 32-bit estimate, now we need to adjust the final
// 64-bit reciprocal estimate downward to ensure that it is strictly smaller // 64-bit reciprocal estimate downward to ensure that it is strictly smaller
// than the infinitely precise exact reciprocal. Because the computation // than the infinitely precise exact reciprocal. Because the computation
// of the Newton-Raphson step is truncating at every step, this adjustment // of the Newton-Raphson step is truncating at every step, this adjustment
// is small; most of the work is already done. // is small; most of the work is already done.
reciprocal -= 2; reciprocal -= 2;
// The numerical reciprocal is accurate to within 2^-56, lies in the // The numerical reciprocal is accurate to within 2^-56, lies in the
// interval [0.5, 1.0), and is strictly smaller than the true reciprocal // interval [0.5, 1.0), and is strictly smaller than the true reciprocal
// of b. Multiplying a by this reciprocal thus gives a numerical q = a/b // of b. Multiplying a by this reciprocal thus gives a numerical q = a/b
@ -131,12 +131,12 @@ __divdf3(fp_t a, fp_t b) {
// 2. q is in the interval [0.5, 2.0) // 2. q is in the interval [0.5, 2.0)
// 3. the error in q is bounded away from 2^-53 (actually, we have a // 3. the error in q is bounded away from 2^-53 (actually, we have a
// couple of bits to spare, but this is all we need). // couple of bits to spare, but this is all we need).
// We need a 64 x 64 multiply high to compute q, which isn't a basic // We need a 64 x 64 multiply high to compute q, which isn't a basic
// operation in C, so we need to be a little bit fussy. // operation in C, so we need to be a little bit fussy.
rep_t quotient, quotientLo; rep_t quotient, quotientLo;
wideMultiply(aSignificand << 2, reciprocal, &quotient, &quotientLo); wideMultiply(aSignificand << 2, reciprocal, &quotient, &quotientLo);
// Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0). // Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0).
// In either case, we are going to compute a residual of the form // In either case, we are going to compute a residual of the form
// //
@ -145,7 +145,7 @@ __divdf3(fp_t a, fp_t b) {
// We know from the construction of q that r satisfies: // We know from the construction of q that r satisfies:
// //
// 0 <= r < ulp(q)*b // 0 <= r < ulp(q)*b
// //
// if r is greater than 1/2 ulp(q)*b, then q rounds up. Otherwise, we // if r is greater than 1/2 ulp(q)*b, then q rounds up. Otherwise, we
// already have the correct result. The exact halfway case cannot occur. // already have the correct result. The exact halfway case cannot occur.
// We also take this time to right shift quotient if it falls in the [1,2) // We also take this time to right shift quotient if it falls in the [1,2)
@ -158,20 +158,20 @@ __divdf3(fp_t a, fp_t b) {
quotient >>= 1; quotient >>= 1;
residual = (aSignificand << 52) - quotient * bSignificand; residual = (aSignificand << 52) - quotient * bSignificand;
} }
const int writtenExponent = quotientExponent + exponentBias; const int writtenExponent = quotientExponent + exponentBias;
if (writtenExponent >= maxExponent) { if (writtenExponent >= maxExponent) {
// If we have overflowed the exponent, return infinity. // If we have overflowed the exponent, return infinity.
return fromRep(infRep | quotientSign); return fromRep(infRep | quotientSign);
} }
else if (writtenExponent < 1) { else if (writtenExponent < 1) {
// Flush denormals to zero. In the future, it would be nice to add // Flush denormals to zero. In the future, it would be nice to add
// code to round them correctly. // code to round them correctly.
return fromRep(quotientSign); return fromRep(quotientSign);
} }
else { else {
const bool round = (residual << 1) > bSignificand; const bool round = (residual << 1) > bSignificand;
// Clear the implicit bit // Clear the implicit bit

View file

@ -24,7 +24,7 @@ __divmodsi4(si_int a, si_int b, si_int* rem)
{ {
si_int d = __divsi3(a,b); si_int d = __divsi3(a,b);
*rem = a - (d*b); *rem = a - (d*b);
return d; return d;
} }

View file

@ -25,36 +25,36 @@ STATIC_YOINK("huge_compiler_rt_license");
COMPILER_RT_ABI fp_t COMPILER_RT_ABI fp_t
__divsf3(fp_t a, fp_t b) { __divsf3(fp_t a, fp_t b) {
const unsigned int aExponent = toRep(a) >> significandBits & maxExponent; const unsigned int aExponent = toRep(a) >> significandBits & maxExponent;
const unsigned int bExponent = toRep(b) >> significandBits & maxExponent; const unsigned int bExponent = toRep(b) >> significandBits & maxExponent;
const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit; const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit;
rep_t aSignificand = toRep(a) & significandMask; rep_t aSignificand = toRep(a) & significandMask;
rep_t bSignificand = toRep(b) & significandMask; rep_t bSignificand = toRep(b) & significandMask;
int scale = 0; int scale = 0;
// Detect if a or b is zero, denormal, infinity, or NaN. // Detect if a or b is zero, denormal, infinity, or NaN.
if (aExponent-1U >= maxExponent-1U || bExponent-1U >= maxExponent-1U) { if (aExponent-1U >= maxExponent-1U || bExponent-1U >= maxExponent-1U) {
const rep_t aAbs = toRep(a) & absMask; const rep_t aAbs = toRep(a) & absMask;
const rep_t bAbs = toRep(b) & absMask; const rep_t bAbs = toRep(b) & absMask;
// NaN / anything = qNaN // NaN / anything = qNaN
if (aAbs > infRep) return fromRep(toRep(a) | quietBit); if (aAbs > infRep) return fromRep(toRep(a) | quietBit);
// anything / NaN = qNaN // anything / NaN = qNaN
if (bAbs > infRep) return fromRep(toRep(b) | quietBit); if (bAbs > infRep) return fromRep(toRep(b) | quietBit);
if (aAbs == infRep) { if (aAbs == infRep) {
// infinity / infinity = NaN // infinity / infinity = NaN
if (bAbs == infRep) return fromRep(qnanRep); if (bAbs == infRep) return fromRep(qnanRep);
// infinity / anything else = +/- infinity // infinity / anything else = +/- infinity
else return fromRep(aAbs | quotientSign); else return fromRep(aAbs | quotientSign);
} }
// anything else / infinity = +/- 0 // anything else / infinity = +/- 0
if (bAbs == infRep) return fromRep(quotientSign); if (bAbs == infRep) return fromRep(quotientSign);
if (!aAbs) { if (!aAbs) {
// zero / zero = NaN // zero / zero = NaN
if (!bAbs) return fromRep(qnanRep); if (!bAbs) return fromRep(qnanRep);
@ -63,28 +63,28 @@ __divsf3(fp_t a, fp_t b) {
} }
// anything else / zero = +/- infinity // anything else / zero = +/- infinity
if (!bAbs) return fromRep(infRep | quotientSign); if (!bAbs) return fromRep(infRep | quotientSign);
// one or both of a or b is denormal, the other (if applicable) is a // one or both of a or b is denormal, the other (if applicable) is a
// normal number. Renormalize one or both of a and b, and set scale to // normal number. Renormalize one or both of a and b, and set scale to
// include the necessary exponent adjustment. // include the necessary exponent adjustment.
if (aAbs < implicitBit) scale += normalize(&aSignificand); if (aAbs < implicitBit) scale += normalize(&aSignificand);
if (bAbs < implicitBit) scale -= normalize(&bSignificand); if (bAbs < implicitBit) scale -= normalize(&bSignificand);
} }
// Or in the implicit significand bit. (If we fell through from the // Or in the implicit significand bit. (If we fell through from the
// denormal path it was already set by normalize( ), but setting it twice // denormal path it was already set by normalize( ), but setting it twice
// won't hurt anything.) // won't hurt anything.)
aSignificand |= implicitBit; aSignificand |= implicitBit;
bSignificand |= implicitBit; bSignificand |= implicitBit;
int quotientExponent = aExponent - bExponent + scale; int quotientExponent = aExponent - bExponent + scale;
// Align the significand of b as a Q31 fixed-point number in the range // Align the significand of b as a Q31 fixed-point number in the range
// [1, 2.0) and get a Q32 approximate reciprocal using a small minimax // [1, 2.0) and get a Q32 approximate reciprocal using a small minimax
// polynomial approximation: reciprocal = 3/4 + 1/sqrt(2) - b/2. This // polynomial approximation: reciprocal = 3/4 + 1/sqrt(2) - b/2. This
// is accurate to about 3.5 binary digits. // is accurate to about 3.5 binary digits.
uint32_t q31b = bSignificand << 8; uint32_t q31b = bSignificand << 8;
uint32_t reciprocal = UINT32_C(0x7504f333) - q31b; uint32_t reciprocal = UINT32_C(0x7504f333) - q31b;
// Now refine the reciprocal estimate using a Newton-Raphson iteration: // Now refine the reciprocal estimate using a Newton-Raphson iteration:
// //
// x1 = x0 * (2 - x0 * b) // x1 = x0 * (2 - x0 * b)
@ -99,7 +99,7 @@ __divsf3(fp_t a, fp_t b) {
reciprocal = (uint64_t)reciprocal * correction >> 31; reciprocal = (uint64_t)reciprocal * correction >> 31;
correction = -((uint64_t)reciprocal * q31b >> 32); correction = -((uint64_t)reciprocal * q31b >> 32);
reciprocal = (uint64_t)reciprocal * correction >> 31; reciprocal = (uint64_t)reciprocal * correction >> 31;
// Exhaustive testing shows that the error in reciprocal after three steps // Exhaustive testing shows that the error in reciprocal after three steps
// is in the interval [-0x1.f58108p-31, 0x1.d0e48cp-29], in line with our // is in the interval [-0x1.f58108p-31, 0x1.d0e48cp-29], in line with our
// expectations. We bump the reciprocal by a tiny value to force the error // expectations. We bump the reciprocal by a tiny value to force the error
@ -107,7 +107,7 @@ __divsf3(fp_t a, fp_t b) {
// be specific). This also causes 1/1 to give a sensible approximation // be specific). This also causes 1/1 to give a sensible approximation
// instead of zero (due to overflow). // instead of zero (due to overflow).
reciprocal -= 2; reciprocal -= 2;
// The numerical reciprocal is accurate to within 2^-28, lies in the // The numerical reciprocal is accurate to within 2^-28, lies in the
// interval [0x1.000000eep-1, 0x1.fffffffcp-1], and is strictly smaller // interval [0x1.000000eep-1, 0x1.fffffffcp-1], and is strictly smaller
// than the true reciprocal of b. Multiplying a by this reciprocal thus // than the true reciprocal of b. Multiplying a by this reciprocal thus
@ -119,9 +119,9 @@ __divsf3(fp_t a, fp_t b) {
// from the fact that we truncate the product, and the 2^27 term // from the fact that we truncate the product, and the 2^27 term
// is the error in the reciprocal of b scaled by the maximum // is the error in the reciprocal of b scaled by the maximum
// possible value of a. As a consequence of this error bound, // possible value of a. As a consequence of this error bound,
// either q or nextafter(q) is the correctly rounded // either q or nextafter(q) is the correctly rounded
rep_t quotient = (uint64_t)reciprocal*(aSignificand << 1) >> 32; rep_t quotient = (uint64_t)reciprocal*(aSignificand << 1) >> 32;
// Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0). // Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0).
// In either case, we are going to compute a residual of the form // In either case, we are going to compute a residual of the form
// //
@ -130,7 +130,7 @@ __divsf3(fp_t a, fp_t b) {
// We know from the construction of q that r satisfies: // We know from the construction of q that r satisfies:
// //
// 0 <= r < ulp(q)*b // 0 <= r < ulp(q)*b
// //
// if r is greater than 1/2 ulp(q)*b, then q rounds up. Otherwise, we // if r is greater than 1/2 ulp(q)*b, then q rounds up. Otherwise, we
// already have the correct result. The exact halfway case cannot occur. // already have the correct result. The exact halfway case cannot occur.
// We also take this time to right shift quotient if it falls in the [1,2) // We also take this time to right shift quotient if it falls in the [1,2)
@ -145,18 +145,18 @@ __divsf3(fp_t a, fp_t b) {
} }
const int writtenExponent = quotientExponent + exponentBias; const int writtenExponent = quotientExponent + exponentBias;
if (writtenExponent >= maxExponent) { if (writtenExponent >= maxExponent) {
// If we have overflowed the exponent, return infinity. // If we have overflowed the exponent, return infinity.
return fromRep(infRep | quotientSign); return fromRep(infRep | quotientSign);
} }
else if (writtenExponent < 1) { else if (writtenExponent < 1) {
// Flush denormals to zero. In the future, it would be nice to add // Flush denormals to zero. In the future, it would be nice to add
// code to round them correctly. // code to round them correctly.
return fromRep(quotientSign); return fromRep(quotientSign);
} }
else { else {
const bool round = (residual << 1) > bSignificand; const bool round = (residual << 1) > bSignificand;
// Clear the implicit bit // Clear the implicit bit

View file

@ -25,7 +25,7 @@ STATIC_YOINK("huge_compiler_rt_license");
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes /* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
* du_int is a 64 bit integral type * du_int is a 64 bit integral type
* value in long double is representable in du_int or is negative * value in long double is representable in du_int or is negative
* (no range checking performed) * (no range checking performed)
*/ */

View file

@ -25,7 +25,7 @@ STATIC_YOINK("huge_compiler_rt_license");
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes /* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
* su_int is a 32 bit integral type * su_int is a 32 bit integral type
* value in long double is representable in su_int or is negative * value in long double is representable in su_int or is negative
*/ */
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee | /* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |

View file

@ -25,7 +25,7 @@ STATIC_YOINK("huge_compiler_rt_license");
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes /* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
* tu_int is a 128 bit integral type * tu_int is a 128 bit integral type
* value in long double is representable in tu_int or is negative * value in long double is representable in tu_int or is negative
*/ */
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee | /* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |

View file

@ -17,9 +17,9 @@ STATIC_YOINK("huge_compiler_rt_license");
/* Returns: convert a to a float, rounding toward even.*/ /* Returns: convert a to a float, rounding toward even.*/
/* Assumption: float is a IEEE 32 bit floating point type /* Assumption: float is a IEEE 32 bit floating point type
* di_int is a 64 bit integral type * di_int is a 64 bit integral type
*/ */
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */ /* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
@ -37,13 +37,13 @@ __floatdisf(di_int a)
int e = sd - 1; /* exponent */ int e = sd - 1; /* exponent */
if (sd > FLT_MANT_DIG) if (sd > FLT_MANT_DIG)
{ {
/* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx /* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
* finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR * finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
* 12345678901234567890123456 * 12345678901234567890123456
* 1 = msb 1 bit * 1 = msb 1 bit
* P = bit FLT_MANT_DIG-1 bits to the right of 1 * P = bit FLT_MANT_DIG-1 bits to the right of 1
* Q = bit FLT_MANT_DIG bits to the right of 1 * Q = bit FLT_MANT_DIG bits to the right of 1
* R = "or" of all bits to the right of Q * R = "or" of all bits to the right of Q
*/ */
switch (sd) switch (sd)
{ {

View file

@ -11,7 +11,7 @@
* This file implements __floatdixf for the compiler_rt library. * This file implements __floatdixf for the compiler_rt library.
* *
* ===----------------------------------------------------------------------=== * ===----------------------------------------------------------------------===
*/ */
STATIC_YOINK("huge_compiler_rt_license"); STATIC_YOINK("huge_compiler_rt_license");

View file

@ -23,30 +23,30 @@ STATIC_YOINK("huge_compiler_rt_license");
COMPILER_RT_ABI fp_t COMPILER_RT_ABI fp_t
__floatsidf(int a) { __floatsidf(int a) {
const int aWidth = sizeof a * CHAR_BIT; const int aWidth = sizeof a * CHAR_BIT;
// Handle zero as a special case to protect clz // Handle zero as a special case to protect clz
if (a == 0) if (a == 0)
return fromRep(0); return fromRep(0);
// All other cases begin by extracting the sign and absolute value of a // All other cases begin by extracting the sign and absolute value of a
rep_t sign = 0; rep_t sign = 0;
if (a < 0) { if (a < 0) {
sign = signBit; sign = signBit;
a = -a; a = -a;
} }
// Exponent of (fp_t)a is the width of abs(a). // Exponent of (fp_t)a is the width of abs(a).
const int exponent = (aWidth - 1) - __builtin_clz(a); const int exponent = (aWidth - 1) - __builtin_clz(a);
rep_t result; rep_t result;
// Shift a into the significand field and clear the implicit bit. Extra // Shift a into the significand field and clear the implicit bit. Extra
// cast to unsigned int is necessary to get the correct behavior for // cast to unsigned int is necessary to get the correct behavior for
// the input INT_MIN. // the input INT_MIN.
const int shift = significandBits - exponent; const int shift = significandBits - exponent;
result = (rep_t)(unsigned int)a << shift ^ implicitBit; result = (rep_t)(unsigned int)a << shift ^ implicitBit;
// Insert the exponent // Insert the exponent
result += (rep_t)(exponent + exponentBias) << significandBits; result += (rep_t)(exponent + exponentBias) << significandBits;
// Insert the sign bit and return // Insert the sign bit and return

View file

@ -23,24 +23,24 @@ STATIC_YOINK("huge_compiler_rt_license");
COMPILER_RT_ABI fp_t COMPILER_RT_ABI fp_t
__floatsisf(int a) { __floatsisf(int a) {
const int aWidth = sizeof a * CHAR_BIT; const int aWidth = sizeof a * CHAR_BIT;
// Handle zero as a special case to protect clz // Handle zero as a special case to protect clz
if (a == 0) if (a == 0)
return fromRep(0); return fromRep(0);
// All other cases begin by extracting the sign and absolute value of a // All other cases begin by extracting the sign and absolute value of a
rep_t sign = 0; rep_t sign = 0;
if (a < 0) { if (a < 0) {
sign = signBit; sign = signBit;
a = -a; a = -a;
} }
// Exponent of (fp_t)a is the width of abs(a). // Exponent of (fp_t)a is the width of abs(a).
const int exponent = (aWidth - 1) - __builtin_clz(a); const int exponent = (aWidth - 1) - __builtin_clz(a);
rep_t result; rep_t result;
// Shift a into the significand field, rounding if it is a right-shift // Shift a into the significand field, rounding if it is a right-shift
if (exponent <= significandBits) { if (exponent <= significandBits) {
const int shift = significandBits - exponent; const int shift = significandBits - exponent;
@ -52,7 +52,7 @@ __floatsisf(int a) {
if (round > signBit) result++; if (round > signBit) result++;
if (round == signBit) result += result & 1; if (round == signBit) result += result & 1;
} }
// Insert the exponent // Insert the exponent
result += (rep_t)(exponent + exponentBias) << significandBits; result += (rep_t)(exponent + exponentBias) << significandBits;
// Insert the sign bit and return // Insert the sign bit and return

View file

@ -21,7 +21,7 @@ STATIC_YOINK("huge_compiler_rt_license");
/* Returns: convert a to a float, rounding toward even. */ /* Returns: convert a to a float, rounding toward even. */
/* Assumption: float is a IEEE 32 bit floating point type /* Assumption: float is a IEEE 32 bit floating point type
* ti_int is a 128 bit integral type * ti_int is a 128 bit integral type
*/ */

View file

@ -17,7 +17,7 @@ STATIC_YOINK("huge_compiler_rt_license");
/* Returns: convert a to a float, rounding toward even. */ /* Returns: convert a to a float, rounding toward even. */
/* Assumption: float is a IEEE 32 bit floating point type /* Assumption: float is a IEEE 32 bit floating point type
* du_int is a 64 bit integral type * du_int is a 64 bit integral type
*/ */

View file

@ -23,20 +23,20 @@ STATIC_YOINK("huge_compiler_rt_license");
COMPILER_RT_ABI fp_t COMPILER_RT_ABI fp_t
__floatunsidf(unsigned int a) { __floatunsidf(unsigned int a) {
const int aWidth = sizeof a * CHAR_BIT; const int aWidth = sizeof a * CHAR_BIT;
// Handle zero as a special case to protect clz // Handle zero as a special case to protect clz
if (a == 0) return fromRep(0); if (a == 0) return fromRep(0);
// Exponent of (fp_t)a is the width of abs(a). // Exponent of (fp_t)a is the width of abs(a).
const int exponent = (aWidth - 1) - __builtin_clz(a); const int exponent = (aWidth - 1) - __builtin_clz(a);
rep_t result; rep_t result;
// Shift a into the significand field and clear the implicit bit. // Shift a into the significand field and clear the implicit bit.
const int shift = significandBits - exponent; const int shift = significandBits - exponent;
result = (rep_t)a << shift ^ implicitBit; result = (rep_t)a << shift ^ implicitBit;
// Insert the exponent // Insert the exponent
result += (rep_t)(exponent + exponentBias) << significandBits; result += (rep_t)(exponent + exponentBias) << significandBits;
return fromRep(result); return fromRep(result);

View file

@ -23,16 +23,16 @@ STATIC_YOINK("huge_compiler_rt_license");
COMPILER_RT_ABI fp_t COMPILER_RT_ABI fp_t
__floatunsisf(unsigned int a) { __floatunsisf(unsigned int a) {
const int aWidth = sizeof a * CHAR_BIT; const int aWidth = sizeof a * CHAR_BIT;
// Handle zero as a special case to protect clz // Handle zero as a special case to protect clz
if (a == 0) return fromRep(0); if (a == 0) return fromRep(0);
// Exponent of (fp_t)a is the width of abs(a). // Exponent of (fp_t)a is the width of abs(a).
const int exponent = (aWidth - 1) - __builtin_clz(a); const int exponent = (aWidth - 1) - __builtin_clz(a);
rep_t result; rep_t result;
// Shift a into the significand field, rounding if it is a right-shift // Shift a into the significand field, rounding if it is a right-shift
if (exponent <= significandBits) { if (exponent <= significandBits) {
const int shift = significandBits - exponent; const int shift = significandBits - exponent;
@ -44,7 +44,7 @@ __floatunsisf(unsigned int a) {
if (round > signBit) result++; if (round > signBit) result++;
if (round == signBit) result += result & 1; if (round == signBit) result += result & 1;
} }
// Insert the exponent // Insert the exponent
result += (rep_t)(exponent + exponentBias) << significandBits; result += (rep_t)(exponent + exponentBias) << significandBits;
return fromRep(result); return fromRep(result);

View file

@ -21,7 +21,7 @@ STATIC_YOINK("huge_compiler_rt_license");
/* Returns: convert a to a float, rounding toward even. */ /* Returns: convert a to a float, rounding toward even. */
/* Assumption: float is a IEEE 32 bit floating point type /* Assumption: float is a IEEE 32 bit floating point type
* tu_int is a 128 bit integral type * tu_int is a 128 bit integral type
*/ */

View file

@ -27,7 +27,7 @@ __mulodi4(di_int a, di_int b, int* overflow)
const int N = (int)(sizeof(di_int) * CHAR_BIT); const int N = (int)(sizeof(di_int) * CHAR_BIT);
const di_int MIN = (di_int)1 << (N-1); const di_int MIN = (di_int)1 << (N-1);
const di_int MAX = ~MIN; const di_int MAX = ~MIN;
*overflow = 0; *overflow = 0;
di_int result = a * b; di_int result = a * b;
if (a == MIN) if (a == MIN)
{ {

View file

@ -27,7 +27,7 @@ __mulosi4(si_int a, si_int b, int* overflow)
const int N = (int)(sizeof(si_int) * CHAR_BIT); const int N = (int)(sizeof(si_int) * CHAR_BIT);
const si_int MIN = (si_int)1 << (N-1); const si_int MIN = (si_int)1 << (N-1);
const si_int MAX = ~MIN; const si_int MAX = ~MIN;
*overflow = 0; *overflow = 0;
si_int result = a * b; si_int result = a * b;
if (a == MIN) if (a == MIN)
{ {

View file

@ -11,7 +11,7 @@
* This file implements __parityti2 for the compiler_rt library. * This file implements __parityti2 for the compiler_rt library.
* *
* ===----------------------------------------------------------------------=== * ===----------------------------------------------------------------------===
*/ */
STATIC_YOINK("huge_compiler_rt_license"); STATIC_YOINK("huge_compiler_rt_license");

View file

@ -64,7 +64,7 @@ __udivmoddi4(du_int a, du_int b, du_int* rem)
/* K X /* K X
* --- * ---
* 0 0 * 0 0
*/ */
if (rem) if (rem)
*rem = n.s.high % d.s.low; *rem = n.s.high % d.s.low;
return n.s.high / d.s.low; return n.s.high / d.s.low;

View file

@ -1,6 +1,6 @@
DESCRIPTION DESCRIPTION
Efficient binary-decimal and decimal-binary conversion routines for IEEE doubles. Efficient binary-decimal and decimal-binary conversion routines for IEEE doubles.
ORIGIN ORIGIN

View file

@ -4681,7 +4681,7 @@ TEST(StringToFloatHexString) {
CHECK_EQ(5.0f, StrToF(" + 0x5 ", flags, 0.0f, &processed, &all_used)); CHECK_EQ(5.0f, StrToF(" + 0x5 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used); CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF("- -0x5", flags, 0.0f, CHECK_EQ(Single::NaN(), StrToF("- -0x5", flags, 0.0f,
&processed, &all_used)); &processed, &all_used));
CHECK_EQ(0, processed); CHECK_EQ(0, processed);
@ -5949,7 +5949,7 @@ TEST(StringToTemplate) {
// The double rounding example from TEST(StringToFloatHexString), which // The double rounding example from TEST(StringToFloatHexString), which
// yields a slightly different result from StringToFloat than from // yields a slightly different result from StringToFloat than from
// StringToDouble. Allows testing that StringTo<float> behaves like // StringToDouble. Allows testing that StringTo<float> behaves like
// StringToFloat (rather than like StringToDouble). // StringToFloat (rather than like StringToDouble).
const char buffer[] = "0x100000100000008"; const char buffer[] = "0x100000100000008";
const int length = DOUBLE_CONVERSION_ARRAY_SIZE(buffer) - 1; const int length = DOUBLE_CONVERSION_ARRAY_SIZE(buffer) - 1;

View file

@ -89,18 +89,18 @@ fxputc(FILE *f, int ch)
ch = ch&0xff; ch = ch&0xff;
/* on 7-bit terminals, strip high bit */ /* on 7-bit terminals, strip high bit */
if (!is8bit()) ch &= 0x7f; if (!is8bit()) ch &= 0x7f;
/* /*
* Assume anything that isn't a control character is printable. * Assume anything that isn't a control character is printable.
* We can't count on locale stuff to tell us what's printable * We can't count on locale stuff to tell us what's printable
* because we might be looking at someone who uses different * because we might be looking at someone who uses different
* locale settings or is on the other side of the planet. So, * locale settings or is on the other side of the planet. So,
* strip 0-31, 127, 128-159, and 255. Note that not stripping * strip 0-31, 127, 128-159, and 255. Note that not stripping
* 128-159 is asking for trouble, as 155 (M-esc) is interpreted * 128-159 is asking for trouble, as 155 (M-esc) is interpreted
* as esc-[ by most terminals. Hopefully this won't break anyone's * as esc-[ by most terminals. Hopefully this won't break anyone's
* charset. * charset.
* *
* It would be nice if we could set the terminal to display in the * It would be nice if we could set the terminal to display in the
* right charset, but we have no way to know what it is. feh. * right charset, but we have no way to know what it is. feh.
*/ */

View file

@ -153,7 +153,7 @@ The
.Fl l .Fl l
option is the only option that may be passed to a remote machine. option is the only option that may be passed to a remote machine.
.Pp .Pp
If standard output is a socket, If standard output is a socket,
.Nm finger .Nm finger
will emit a carriage return (^M) before every linefeed (^J). This is will emit a carriage return (^M) before every linefeed (^J). This is
for processing remote finger requests when invoked by for processing remote finger requests when invoked by

View file

@ -479,7 +479,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does. and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's 1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an you conspicuously and appropriately publish on each copy an
@ -1518,7 +1518,7 @@ Public License instead of this License. But first, please read
the terms and conditions of version 3 of the GNU General Public the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below. License, supplemented by the additional permissions listed below.
0. Additional Definitions. 0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License, and the "GNU GPL" refers to version 3 of the GNU
@ -1619,7 +1619,7 @@ the following:
a copy of the Library already present on the user's computer a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked of the Library that is interface-compatible with the Linked
Version. Version.
e) Provide Installation Information, but only if you would otherwise e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the be required to provide such information under section 6 of the
@ -4196,7 +4196,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does. and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's 1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an you conspicuously and appropriately publish on each copy an
@ -6764,7 +6764,7 @@ Public License instead of this License. But first, please read
the terms and conditions of version 3 of the GNU General Public the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below. License, supplemented by the additional permissions listed below.
0. Additional Definitions. 0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License, and the "GNU GPL" refers to version 3 of the GNU
@ -6865,7 +6865,7 @@ the following:
a copy of the Library already present on the user's computer a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked of the Library that is interface-compatible with the Linked
Version. Version.
e) Provide Installation Information, but only if you would otherwise e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the be required to provide such information under section 6 of the
@ -8541,7 +8541,7 @@ Public License instead of this License. But first, please read
the terms and conditions of version 3 of the GNU General Public the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below. License, supplemented by the additional permissions listed below.
0. Additional Definitions. 0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License, and the "GNU GPL" refers to version 3 of the GNU
@ -8642,7 +8642,7 @@ the following:
a copy of the Library already present on the user's computer a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked of the Library that is interface-compatible with the Linked
Version. Version.
e) Provide Installation Information, but only if you would otherwise e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the be required to provide such information under section 6 of the
@ -9188,7 +9188,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does. and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's 1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an you conspicuously and appropriately publish on each copy an
@ -10236,7 +10236,7 @@ Public License instead of this License. But first, please read
the terms and conditions of version 3 of the GNU General Public the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below. License, supplemented by the additional permissions listed below.
0. Additional Definitions. 0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License, and the "GNU GPL" refers to version 3 of the GNU
@ -10337,7 +10337,7 @@ the following:
a copy of the Library already present on the user's computer a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked of the Library that is interface-compatible with the Linked
Version. Version.
e) Provide Installation Information, but only if you would otherwise e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the be required to provide such information under section 6 of the
@ -10923,16 +10923,16 @@ are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented; you must 2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product software in a product, an acknowledgment in the product
documentation would be appreciated but is not required. documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must 3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software. not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote 4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written products derived from this software without specific prior written
permission. permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@ -12206,7 +12206,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does. and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's 1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an you conspicuously and appropriately publish on each copy an
@ -13331,7 +13331,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does. and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's 1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an you conspicuously and appropriately publish on each copy an
@ -14170,8 +14170,8 @@ so, subject to the following conditions:
this list of conditions and the following disclaimers in the this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
* Neither the names of Intel Corporation Threading Runtimes Team nor the * Neither the names of Intel Corporation Threading Runtimes Team nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this Software without specific prior written permission. derived from this Software without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
@ -14920,7 +14920,7 @@ Public License instead of this License. But first, please read
the terms and conditions of version 3 of the GNU General Public the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below. License, supplemented by the additional permissions listed below.
0. Additional Definitions. 0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License, and the "GNU GPL" refers to version 3 of the GNU
@ -15021,7 +15021,7 @@ the following:
a copy of the Library already present on the user's computer a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked of the Library that is interface-compatible with the Linked
Version. Version.
e) Provide Installation Information, but only if you would otherwise e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the be required to provide such information under section 6 of the

View file

@ -19,7 +19,7 @@ Author: Rich Felker <dalias@aerifal.cx>
Date: Wed Dec 18 14:29:07 2019 -0500 Date: Wed Dec 18 14:29:07 2019 -0500
switch linux kernel headers to 4.19.88 by default switch linux kernel headers to 4.19.88 by default
using slim headers-only version. this change is needed to support all using slim headers-only version. this change is needed to support all
future versions of musl on 32-bit archs, since prior to 4.16 the future versions of musl on 32-bit archs, since prior to 4.16 the
kernel headers had incompatibility with userspace time_t not matching kernel headers had incompatibility with userspace time_t not matching

View file

@ -5,8 +5,8 @@
%{%:debug-level-gt(0):%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}} %{fdebug-prefix-map=*:--debug-prefix-map %*} %{%:debug-level-gt(0):%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}} %{fdebug-prefix-map=*:--debug-prefix-map %*}
*asm_final: *asm_final:
%{gsplit-dwarf: %{gsplit-dwarf:
objcopy --extract-dwo %{c:%{o*:%*}%{!o*:%b%O}}%{!c:%U%O} %{c:%{o*:%:replace-extension(%{o*:%*} .dwo)}%{!o*:%b.dwo}}%{!c:%b.dwo} objcopy --extract-dwo %{c:%{o*:%*}%{!o*:%b%O}}%{!c:%U%O} %{c:%{o*:%:replace-extension(%{o*:%*} .dwo)}%{!o*:%b.dwo}}%{!c:%b.dwo}
objcopy --strip-dwo %{c:%{o*:%*}%{!o*:%b%O}}%{!c:%U%O} } objcopy --strip-dwo %{c:%{o*:%*}%{!o*:%b%O}}%{!c:%U%O} }
*asm_options: *asm_options:
@ -137,5 +137,5 @@ collect2
%{march=native:%>march=native %:local_cpu_detect(arch) %{!mtune=*:%>mtune=native %:local_cpu_detect(tune)}} %{mtune=native:%>mtune=native %:local_cpu_detect(tune)} %{march=native:%>march=native %:local_cpu_detect(arch) %{!mtune=*:%>mtune=native %:local_cpu_detect(tune)}} %{mtune=native:%>mtune=native %:local_cpu_detect(tune)}
*link_command: *link_command:
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %{fuse-linker-plugin: %e-fuse-linker-plugin is not supported in this configuration}%{flto|flto=*:%<fcompare-debug*} %{flto} %{fno-lto} %{flto=*} %l %{shared|r:;pie|static-pie:-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}} %{fuse-ld=*:-fuse-ld=%*} %{gz|gz=zlib:--compress-debug-sections=zlib} %{gz=none:--compress-debug-sections=none} %{gz=zlib-gnu:--compress-debug-sections=zlib-gnu} %X %{o*} %{e*} %{N} %{n} %{r} %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) %{fvtable-verify=none:} %{fvtable-verify=std: %e-fvtable-verify=std is not supported in this configuration} %{fvtable-verify=preinit: %e-fvtable-verify=preinit is not supported in this configuration} %{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):%{!shared:libasan_preinit%O%s} %{static-libasan:%{!shared:-Bstatic --whole-archive -lasan --no-whole-archive -Bdynamic}}%{!static-libasan:-lasan}} %{%:sanitize(thread):%{!shared:libtsan_preinit%O%s} %{static-libtsan:%{!shared:-Bstatic --whole-archive -ltsan --no-whole-archive -Bdynamic}}%{!static-libtsan:-ltsan}} %{%:sanitize(leak):%{!shared:liblsan_preinit%O%s} %{static-liblsan:%{!shared:-Bstatic --whole-archive -llsan --no-whole-archive -Bdynamic}}%{!static-liblsan:-llsan}}}}} %o %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): %:include(libgomp.spec)%(link_gomp)} %{fgnu-tm:%:include(libitm.spec)%(link_itm)} %(mflib) %{fsplit-stack: --wrap=pthread_create} %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} %{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address): %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)} %{static:%ecannot specify -static with -fsanitize=address}} %{%:sanitize(thread): %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)} %{static:%ecannot specify -static with -fsanitize=thread}} %{%:sanitize(undefined):%{static-libubsan:-Bstatic} -lubsan %{static-libubsan:-Bdynamic} %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}} %{%:sanitize(leak): %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}}}}} %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}} %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %{fuse-linker-plugin: %e-fuse-linker-plugin is not supported in this configuration}%{flto|flto=*:%<fcompare-debug*} %{flto} %{fno-lto} %{flto=*} %l %{shared|r:;pie|static-pie:-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}} %{fuse-ld=*:-fuse-ld=%*} %{gz|gz=zlib:--compress-debug-sections=zlib} %{gz=none:--compress-debug-sections=none} %{gz=zlib-gnu:--compress-debug-sections=zlib-gnu} %X %{o*} %{e*} %{N} %{n} %{r} %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) %{fvtable-verify=none:} %{fvtable-verify=std: %e-fvtable-verify=std is not supported in this configuration} %{fvtable-verify=preinit: %e-fvtable-verify=preinit is not supported in this configuration} %{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):%{!shared:libasan_preinit%O%s} %{static-libasan:%{!shared:-Bstatic --whole-archive -lasan --no-whole-archive -Bdynamic}}%{!static-libasan:-lasan}} %{%:sanitize(thread):%{!shared:libtsan_preinit%O%s} %{static-libtsan:%{!shared:-Bstatic --whole-archive -ltsan --no-whole-archive -Bdynamic}}%{!static-libtsan:-ltsan}} %{%:sanitize(leak):%{!shared:liblsan_preinit%O%s} %{static-liblsan:%{!shared:-Bstatic --whole-archive -llsan --no-whole-archive -Bdynamic}}%{!static-liblsan:-llsan}}}}} %o %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): %:include(libgomp.spec)%(link_gomp)} %{fgnu-tm:%:include(libitm.spec)%(link_itm)} %(mflib) %{fsplit-stack: --wrap=pthread_create} %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} %{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address): %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)} %{static:%ecannot specify -static with -fsanitize=address}} %{%:sanitize(thread): %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)} %{static:%ecannot specify -static with -fsanitize=thread}} %{%:sanitize(undefined):%{static-libubsan:-Bstatic} -lubsan %{static-libubsan:-Bdynamic} %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}} %{%:sanitize(leak): %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}}}}} %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}} %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*}
%(post_link) }}}}}} %(post_link) }}}}}}

View file

@ -31,7 +31,7 @@ struct char_traits
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n); static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
static constexpr size_t length(const char_type* s); static constexpr size_t length(const char_type* s);
static constexpr const char_type* static constexpr const char_type*
find(const char_type* s, size_t n, const char_type& a); find(const char_type* s, size_t n, const char_type& a);
static char_type* move(char_type* s1, const char_type* s2, size_t n); static char_type* move(char_type* s1, const char_type* s2, size_t n);
static char_type* copy(char_type* s1, const char_type* s2, size_t n); static char_type* copy(char_type* s1, const char_type* s2, size_t n);
@ -424,19 +424,19 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
static constexpr static constexpr
size_t length(const char_type* __s) _NOEXCEPT; size_t length(const char_type* __s) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY static constexpr _LIBCPP_INLINE_VISIBILITY static constexpr
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);} {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{ {
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
} }
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);} {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);}
@ -744,7 +744,7 @@ char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCE
// __str_find // __str_find
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find(const _CharT *__p, _SizeT __sz, __str_find(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT _CharT __c, _SizeT __pos) _NOEXCEPT
{ {
if (__pos >= __sz) if (__pos >= __sz)
@ -796,7 +796,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find(const _CharT *__p, _SizeT __sz, __str_find(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{ {
if (__pos > __sz) if (__pos > __sz)
@ -818,7 +818,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_rfind(const _CharT *__p, _SizeT __sz, __str_rfind(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT _CharT __c, _SizeT __pos) _NOEXCEPT
{ {
if (__sz < 1) if (__sz < 1)
@ -837,7 +837,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_rfind(const _CharT *__p, _SizeT __sz, __str_rfind(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{ {
__pos = _VSTD::min(__pos, __sz); __pos = _VSTD::min(__pos, __sz);
@ -846,7 +846,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
else else
__pos = __sz; __pos = __sz;
const _CharT* __r = _VSTD::__find_end( const _CharT* __r = _VSTD::__find_end(
__p, __p + __pos, __s, __s + __n, _Traits::eq, __p, __p + __pos, __s, __s + __n, _Traits::eq,
random_access_iterator_tag(), random_access_iterator_tag()); random_access_iterator_tag(), random_access_iterator_tag());
if (__n > 0 && __r == __p + __pos) if (__n > 0 && __r == __p + __pos)
return __npos; return __npos;
@ -975,7 +975,7 @@ struct __quoted_output_proxy
__quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e) __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
: __first(__f), __last(__l), __delim(__d), __escape(__e) {} : __first(__f), __last(__l), __delim(__d), __escape(__e) {}
// This would be a nice place for a string_ref // This would be a nice place for a string_ref
}; };
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD

View file

@ -453,7 +453,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void __reset() { __id_ = 0; } void __reset() { __id_ = 0; }
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
friend friend
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY

View file

@ -42,7 +42,7 @@ namespace std {
template<class T> template<class T>
constexpr int popcount(T x) noexcept; // C++20 constexpr int popcount(T x) noexcept; // C++20
// 20.15.9, endian // 20.15.9, endian
enum class endian { enum class endian {
little = see below, // C++20 little = see below, // C++20
big = see below, // C++20 big = see below, // C++20
@ -350,7 +350,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bool __ispow2(_Tp __t) _NOEXCEPT bool __ispow2(_Tp __t) _NOEXCEPT
{ {
static_assert(__bitop_unsigned_integer<_Tp>::value, "__ispow2 requires unsigned"); static_assert(__bitop_unsigned_integer<_Tp>::value, "__ispow2 requires unsigned");
return __t != 0 && (((__t & (__t - 1)) == 0)); return __t != 0 && (((__t & (__t - 1)) == 0));
} }

View file

@ -18,7 +18,7 @@ Macros:
NULL NULL
CLOCKS_PER_SEC CLOCKS_PER_SEC
TIME_UTC // C++17 TIME_UTC // C++17
namespace std namespace std
{ {
@ -29,7 +29,7 @@ Types:
time_t time_t
tm tm
timespec // C++17 timespec // C++17
clock_t clock(); clock_t clock();
double difftime(time_t time1, time_t time0); double difftime(time_t time1, time_t time0);
time_t mktime(tm* timeptr); time_t mktime(tm* timeptr);

View file

@ -2211,7 +2211,7 @@ list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred)
__i = __j; __i = __j;
} }
} }
return (__remove_return_type) __deleted_nodes.size(); return (__remove_return_type) __deleted_nodes.size();
} }

View file

@ -435,7 +435,7 @@ a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 ==
-- test of large float/integer indices -- test of large float/integer indices
-- compute maximum integer where all bits fit in a float -- compute maximum integer where all bits fit in a float
local maxint = math.maxinteger local maxint = math.maxinteger

View file

@ -7,7 +7,7 @@ end
print "testing large tables" print "testing large tables"
local debug = require"debug" local debug = require"debug"
local lim = 2^18 + 1000 local lim = 2^18 + 1000
local prog = { "local y = {0" } local prog = { "local y = {0" }
@ -46,7 +46,7 @@ getmetatable(env).__newindex = function () end
local e, m = pcall(f) local e, m = pcall(f)
assert(not e and m:find("global 'X'")) assert(not e and m:find("global 'X'"))
-- errors in metamethods -- errors in metamethods
getmetatable(env).__newindex = function () error("hi") end getmetatable(env).__newindex = function () error("hi") end
local e, m = xpcall(f, debug.traceback) local e, m = xpcall(f, debug.traceback)
assert(not e and m:find("'newindex'")) assert(not e and m:find("'newindex'"))
@ -55,7 +55,7 @@ f, X = nil
coroutine.yield'b' coroutine.yield'b'
if 2^32 == 0 then -- (small integers) { if 2^32 == 0 then -- (small integers) {
print "testing string length overflow" print "testing string length overflow"

View file

@ -162,7 +162,7 @@ do
X = function () return b end -- closure with upvalue X = function () return b end -- closure with upvalue
if a then break end if a then break end
end end
do do
local b = 20 local b = 20
Y = function () return b end -- closure with upvalue Y = function () return b end -- closure with upvalue
@ -172,7 +172,7 @@ do
assert(X() == 10 and Y() == 20) assert(X() == 10 and Y() == 20)
end end
-- testing closures x repeat-until -- testing closures x repeat-until
local a = {} local a = {}

View file

@ -467,7 +467,7 @@ else
print "testing yields inside hooks" print "testing yields inside hooks"
local turn local turn
function fact (t, x) function fact (t, x)
assert(turn == t) assert(turn == t)
if x == 0 then return 1 if x == 0 then return 1
@ -591,7 +591,7 @@ else
print "testing coroutine API" print "testing coroutine API"
-- reusing a thread -- reusing a thread
assert(T.testC([[ assert(T.testC([[
newthread # create thread newthread # create thread
@ -870,7 +870,7 @@ do -- a few more tests for comparison operators
until res ~= 10 until res ~= 10
return res return res
end end
local function test () local function test ()
local a1 = setmetatable({x=1}, mt1) local a1 = setmetatable({x=1}, mt1)
local a2 = setmetatable({x=2}, mt2) local a2 = setmetatable({x=2}, mt2)
@ -882,7 +882,7 @@ do -- a few more tests for comparison operators
assert(2 >= a2) assert(2 >= a2)
return true return true
end end
run(test) run(test)
end end
@ -1042,11 +1042,11 @@ co = coroutine.wrap(function (...) return
cannot be here! cannot be here!
]], ]],
[[ # 1st continuation [[ # 1st continuation
yieldk 0 3 yieldk 0 3
cannot be here! cannot be here!
]], ]],
[[ # 2nd continuation [[ # 2nd continuation
yieldk 0 4 yieldk 0 4
cannot be here! cannot be here!
]], ]],
[[ # 3th continuation [[ # 3th continuation

View file

@ -359,7 +359,7 @@ end
function g(a,b) return (a+1) + f() end function g(a,b) return (a+1) + f() end
assert(g(0,0) == 30) assert(g(0,0) == 30)
debug.sethook(nil); debug.sethook(nil);
assert(not debug.gethook()) assert(not debug.gethook())
@ -411,7 +411,7 @@ debug.sethook(function (e)
dostring("XX = 12") -- test dostring inside hooks dostring("XX = 12") -- test dostring inside hooks
-- testing errors inside hooks -- testing errors inside hooks
assert(not pcall(load("a='joao'+1"))) assert(not pcall(load("a='joao'+1")))
debug.sethook(function (e, l) debug.sethook(function (e, l)
assert(debug.getinfo(2, "l").currentline == l) assert(debug.getinfo(2, "l").currentline == l)
local f,m,c = debug.gethook() local f,m,c = debug.gethook()
assert(e == "line") assert(e == "line")
@ -474,7 +474,7 @@ do print("testing inspection of parameters/returned values")
local t = {} local t = {}
for i = ar.ftransfer, ar.ftransfer + ar.ntransfer - 1 do for i = ar.ftransfer, ar.ftransfer + ar.ntransfer - 1 do
local _, v = debug.getlocal(2, i) local _, v = debug.getlocal(2, i)
t[#t + 1] = v t[#t + 1] = v
end end
if event == "return" then if event == "return" then
out = t out = t
@ -528,7 +528,7 @@ assert(t.a == 1 and t.b == 2 and t.c == 3)
assert(debug.setupvalue(foo1, 1, "xuxu") == "b") assert(debug.setupvalue(foo1, 1, "xuxu") == "b")
assert(({debug.getupvalue(foo2, 3)})[2] == "xuxu") assert(({debug.getupvalue(foo2, 3)})[2] == "xuxu")
-- upvalues of C functions are allways "called" "" (the empty string) -- upvalues of C functions are allways "called" "" (the empty string)
assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "") assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "")
-- testing count hooks -- testing count hooks
@ -960,7 +960,7 @@ end
do -- tests for 'source' in binary dumps do -- tests for 'source' in binary dumps
local prog = [[ local prog = [[
return function (x) return function (x)
return function (y) return function (y)
return x + y return x + y
end end
end end
@ -975,7 +975,7 @@ do -- tests for 'source' in binary dumps
local h = g(3) local h = g(3)
assert(h(5) == 8) assert(h(5) == 8)
assert(debug.getinfo(f).source == name and -- all functions have 'source' assert(debug.getinfo(f).source == name and -- all functions have 'source'
debug.getinfo(g).source == name and debug.getinfo(g).source == name and
debug.getinfo(h).source == name) debug.getinfo(h).source == name)
-- again, without debug info -- again, without debug info
local c = string.dump(p, true) local c = string.dump(p, true)
@ -985,7 +985,7 @@ do -- tests for 'source' in binary dumps
local h = g(30) local h = g(30)
assert(h(50) == 80) assert(h(50) == 80)
assert(debug.getinfo(f).source == '=?' and -- no function has 'source' assert(debug.getinfo(f).source == '=?' and -- no function has 'source'
debug.getinfo(g).source == '=?' and debug.getinfo(g).source == '=?' and
debug.getinfo(h).source == '=?') debug.getinfo(h).source == '=?')
end end

View file

@ -493,7 +493,7 @@ if not _soft then
f(3) f(3)
local function loop (x,y,z) return 1 + loop(x, y, z) end local function loop (x,y,z) return 1 + loop(x, y, z) end
local res, msg = xpcall(loop, function (m) local res, msg = xpcall(loop, function (m)
assert(string.find(m, "stack overflow")) assert(string.find(m, "stack overflow"))
checkerr("error handling", loop) checkerr("error handling", loop)
@ -526,7 +526,7 @@ do
-- 'assert' with extra arguments -- 'assert' with extra arguments
res, msg = pcall(assert, false, "X", t) res, msg = pcall(assert, false, "X", t)
assert(not res and msg == "X") assert(not res and msg == "X")
-- 'assert' with no message -- 'assert' with no message
res, msg = pcall(function () assert(false) end) res, msg = pcall(function () assert(false) end)
local line = string.match(msg, "%w+%.lua:(%d+): assertion failed!$") local line = string.match(msg, "%w+%.lua:(%d+): assertion failed!$")

View file

@ -74,7 +74,7 @@ end
function hugeid () function hugeid ()
print("loading chunk with huge identifier") print("loading chunk with huge identifier")
local st, msg = loadrep("a", "chars") local st, msg = loadrep("a", "chars")
assert(not st and assert(not st and
(string.find(msg, "lexical element too long") or (string.find(msg, "lexical element too long") or
string.find(msg, "not enough memory"))) string.find(msg, "not enough memory")))
print('+') print('+')
@ -158,7 +158,7 @@ function toomanyidx ()
print("expected error: ", msg) print("expected error: ", msg)
print("size:", #a) print("size:", #a)
end end
-- teststring() -- teststring()

View file

@ -32,7 +32,7 @@ LUAMOD_API int anotherfunc (lua_State *L) {
lua_pushfstring(L, "%d%%%d\n", (int)lua_tointeger(L, 1), lua_pushfstring(L, "%d%%%d\n", (int)lua_tointeger(L, 1),
(int)lua_tointeger(L, 2)); (int)lua_tointeger(L, 2));
return 1; return 1;
} }
LUAMOD_API int luaopen_lib1_sub (lua_State *L) { LUAMOD_API int luaopen_lib1_sub (lua_State *L) {

View file

@ -140,7 +140,7 @@ assert(eqT(3.5 // 1.5, 2.0))
assert(eqT(3.5 // -1.5, -3.0)) assert(eqT(3.5 // -1.5, -3.0))
do -- tests for different kinds of opcodes do -- tests for different kinds of opcodes
local x, y local x, y
x = 1; assert(x // 0.0 == 1/0) x = 1; assert(x // 0.0 == 1/0)
x = 1.0; assert(x // 0 == 1/0) x = 1.0; assert(x // 0 == 1/0)
x = 3.5; assert(eqT(x // 1, 3.0)) x = 3.5; assert(eqT(x // 1, 3.0))
@ -618,7 +618,7 @@ assert(minint % -1 == 0)
assert(minint % -2 == 0) assert(minint % -2 == 0)
assert(maxint % -2 == -1) assert(maxint % -2 == -1)
-- non-portable tests because Windows C library cannot compute -- non-portable tests because Windows C library cannot compute
-- fmod(1, huge) correctly -- fmod(1, huge) correctly
if not _port then if not _port then
local function anan (x) assert(isNaN(x)) end -- assert Not a Number local function anan (x) assert(isNaN(x)) end -- assert Not a Number

View file

@ -79,7 +79,7 @@ end
print "testing pack" print "testing pack"
a = table.pack() a = table.pack()
assert(a[1] == undef and a.n == 0) assert(a[1] == undef and a.n == 0)
a = table.pack(table) a = table.pack(table)
assert(a[1] == table and a.n == 1) assert(a[1] == table and a.n == 1)
@ -94,8 +94,8 @@ do
checkerror("table expected", table.move, 1, 2, 3, 4) checkerror("table expected", table.move, 1, 2, 3, 4)
local function eqT (a, b) local function eqT (a, b)
for k, v in pairs(a) do assert(b[k] == v) end for k, v in pairs(a) do assert(b[k] == v) end
for k, v in pairs(b) do assert(a[k] == v) end for k, v in pairs(b) do assert(a[k] == v) end
end end
local a = table.move({10,20,30}, 1, 3, 2) -- move forward local a = table.move({10,20,30}, 1, 3, 2) -- move forward

View file

@ -331,7 +331,7 @@ do print("testing 'format %a %A'")
assert(string.find(string.format("%a", 0/0), "^%-?nan")) assert(string.find(string.format("%a", 0/0), "^%-?nan"))
assert(string.find(string.format("%a", -0.0), "^%-0x0")) assert(string.find(string.format("%a", -0.0), "^%-0x0"))
end end
if not pcall(string.format, "%.3a", 0) then if not pcall(string.format, "%.3a", 0) then
(Message or print)("\n >>> modifiers for format '%a' not available <<<\n") (Message or print)("\n >>> modifiers for format '%a' not available <<<\n")
else else

View file

@ -173,7 +173,7 @@ else
assert(pack("f", 24) == pack(">f", 24)) assert(pack("f", 24) == pack(">f", 24))
end end
print "testing pack/unpack of floating-point numbers" print "testing pack/unpack of floating-point numbers"
for _, n in ipairs{0, -1.1, 1.9, 1/0, -1/0, 1e20, -1e20, 0.1, 2000.7} do for _, n in ipairs{0, -1.1, 1.9, 1/0, -1/0, 1e20, -1e20, 0.1, 2000.7} do
assert(unpack("n", pack("n", n)) == n) assert(unpack("n", pack("n", n)) == n)
@ -243,7 +243,7 @@ do
assert(#x == packsize("<b h b f d f n i")) assert(#x == packsize("<b h b f d f n i"))
local a, b, c, d, e, f, g, h = unpack("<b h b f d f n i", x) local a, b, c, d, e, f, g, h = unpack("<b h b f d f n i", x)
assert(a == 1 and b == 2 and c == 3 and d == 4 and e == 5 and f == 6 and assert(a == 1 and b == 2 and c == 3 and d == 4 and e == 5 and f == 6 and
g == 7 and h == 8) g == 7 and h == 8)
end end
print "testing alignment" print "testing alignment"
@ -253,7 +253,7 @@ do
assert(#x == packsize(">!8 b Xh i4 i8 c1 Xi8")) assert(#x == packsize(">!8 b Xh i4 i8 c1 Xi8"))
assert(x == "\xf4" .. "\0\0\0" .. assert(x == "\xf4" .. "\0\0\0" ..
"\0\0\0\100" .. "\0\0\0\100" ..
"\0\0\0\0\0\0\0\xC8" .. "\0\0\0\0\0\0\0\xC8" ..
"\xEC" .. "\0\0\0\0\0\0\0") "\xEC" .. "\0\0\0\0\0\0\0")
local a, b, c, d, pos = unpack(">!8 c1 Xh i4 i8 b Xi8 XI XH", x) local a, b, c, d, pos = unpack(">!8 c1 Xh i4 i8 b Xi8 XI XH", x)
assert(a == "\xF4" and b == 100 and c == 200 and d == -20 and (pos - 1) == #x) assert(a == "\xF4" and b == 100 and c == 200 and d == -20 and (pos - 1) == #x)
@ -315,7 +315,7 @@ do -- testing initial position
assert(unpack("c0", x, i) == "") assert(unpack("c0", x, i) == "")
end end
checkerror("out of string", unpack, "c0", x, #x + 2) checkerror("out of string", unpack, "c0", x, #x + 2)
end end
print "OK" print "OK"

View file

@ -32,9 +32,9 @@ extern "C" {
******************************************/ ******************************************/
#include "third_party/lz4cli/platform.h" #include "third_party/lz4cli/platform.h"
#include "libc/mem/mem.h" #include "libc/mem/mem.h"
#include "libc/str/str.h" #include "libc/str/str.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/time/time.h" #include "libc/time/time.h"
#include "libc/errno.h" #include "libc/errno.h"

View file

@ -48,7 +48,7 @@ static const unsigned char base64_dec_map[128] =
#define BASE64_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */ #define BASE64_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
/* /*
* Constant flow conditional assignment to unsigned char * Constant flow conditional assignment to unsigned char
*/ */
forceinline void mbedtls_base64_cond_assign_uchar( unsigned char * dest, forceinline void mbedtls_base64_cond_assign_uchar( unsigned char * dest,
const unsigned char * const src, const unsigned char * const src,

View file

@ -80,7 +80,7 @@ int mbedtls_mpi_shift_l(mbedtls_mpi *X, size_t k)
m = k / biL; m = k / biL;
k = k % biL; k = k % biL;
z = X->n; z = X->n;
if (n > X->n && (r = mbedtls_mpi_grow(X, n))) if (n > X->n && (r = mbedtls_mpi_grow(X, n)))
return r; return r;
if (k) if (k)
{ {

Some files were not shown because too many files have changed in this diff Show more