mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-09-09 12:16:42 -04:00
programs: define begin_program()
In preparation for testing freestanding library builds, make all programs call a function begin_program().
This commit is contained in:
parent
c872728fc8
commit
740820bd66
@ -503,7 +503,7 @@ tmain(int argc, tchar *argv[])
|
|||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
program_invocation_name = get_filename(argv[0]);
|
begin_program(argv);
|
||||||
|
|
||||||
while ((opt_char = tgetopt(argc, argv, optstring)) != -1) {
|
while ((opt_char = tgetopt(argc, argv, optstring)) != -1) {
|
||||||
switch (opt_char) {
|
switch (opt_char) {
|
||||||
|
@ -115,7 +115,7 @@ tmain(int argc, tchar *argv[])
|
|||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
program_invocation_name = get_filename(argv[0]);
|
begin_program(argv);
|
||||||
|
|
||||||
while ((opt_char = tgetopt(argc, argv, optstring)) != -1) {
|
while ((opt_char = tgetopt(argc, argv, optstring)) != -1) {
|
||||||
switch (opt_char) {
|
switch (opt_char) {
|
||||||
|
@ -528,7 +528,7 @@ tmain(int argc, tchar *argv[])
|
|||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
program_invocation_name = get_filename(argv[0]);
|
begin_program(argv);
|
||||||
|
|
||||||
options.to_stdout = false;
|
options.to_stdout = false;
|
||||||
options.decompress = is_gunzip();
|
options.decompress = is_gunzip();
|
||||||
|
@ -112,7 +112,7 @@ xmalloc(size_t size)
|
|||||||
* properly for directories, since a path to a directory might have trailing
|
* properly for directories, since a path to a directory might have trailing
|
||||||
* slashes.
|
* slashes.
|
||||||
*/
|
*/
|
||||||
const tchar *
|
static const tchar *
|
||||||
get_filename(const tchar *path)
|
get_filename(const tchar *path)
|
||||||
{
|
{
|
||||||
const tchar *slash = tstrrchr(path, '/');
|
const tchar *slash = tstrrchr(path, '/');
|
||||||
@ -126,6 +126,12 @@ get_filename(const tchar *path)
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
begin_program(tchar *argv[])
|
||||||
|
{
|
||||||
|
program_invocation_name = get_filename(argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a copy of 'path' surrounded by double quotes */
|
/* Create a copy of 'path' surrounded by double quotes */
|
||||||
static tchar *
|
static tchar *
|
||||||
quote_path(const tchar *path)
|
quote_path(const tchar *path)
|
||||||
|
@ -119,7 +119,7 @@ void _printf(1, 2) msg_errno(const char *fmt, ...);
|
|||||||
|
|
||||||
void *xmalloc(size_t size);
|
void *xmalloc(size_t size);
|
||||||
|
|
||||||
const tchar *get_filename(const tchar *path);
|
void begin_program(tchar *argv[]);
|
||||||
|
|
||||||
struct file_stream {
|
struct file_stream {
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -151,7 +151,7 @@ tmain(int argc, tchar *argv[])
|
|||||||
u8 *buffer = xmalloc(32768);
|
u8 *buffer = xmalloc(32768);
|
||||||
u8 *guarded_buf_start, *guarded_buf_end;
|
u8 *guarded_buf_start, *guarded_buf_end;
|
||||||
|
|
||||||
program_invocation_name = get_filename(argv[0]);
|
begin_program(argv);
|
||||||
|
|
||||||
alloc_guarded_buffer(32768, &guarded_buf_start, &guarded_buf_end);
|
alloc_guarded_buffer(32768, &guarded_buf_start, &guarded_buf_end);
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ test_singleton_offset_code_notsymzero(void)
|
|||||||
int
|
int
|
||||||
tmain(int argc, tchar *argv[])
|
tmain(int argc, tchar *argv[])
|
||||||
{
|
{
|
||||||
program_invocation_name = get_filename(argv[0]);
|
begin_program(argv);
|
||||||
|
|
||||||
test_empty_offset_code();
|
test_empty_offset_code();
|
||||||
test_singleton_litrunlen_code();
|
test_singleton_litrunlen_code();
|
||||||
|
@ -430,7 +430,7 @@ tmain(int argc, tchar *argv[])
|
|||||||
u8 out[10000];
|
u8 out[10000];
|
||||||
u64 t, tz;
|
u64 t, tz;
|
||||||
|
|
||||||
program_invocation_name = get_filename(argv[0]);
|
begin_program(argv);
|
||||||
|
|
||||||
begin_performance_test();
|
begin_performance_test();
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ tmain(int argc, tchar *argv[])
|
|||||||
size_t actual_compressed_nbytes;
|
size_t actual_compressed_nbytes;
|
||||||
size_t actual_decompressed_nbytes;
|
size_t actual_decompressed_nbytes;
|
||||||
|
|
||||||
program_invocation_name = get_filename(argv[0]);
|
begin_program(argv);
|
||||||
|
|
||||||
ASSERT(compressed_nbytes_avail < compressed_nbytes_total);
|
ASSERT(compressed_nbytes_avail < compressed_nbytes_total);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user