Skip to content

Commit

Permalink
Merge pull request #6 from h01ger/h01ger
Browse files Browse the repository at this point in the history
H01ger
  • Loading branch information
jnovy committed Sep 30, 2012
2 parents 537418b + 4774800 commit eb3bb6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -12,7 +12,7 @@ MANDIR?=/usr/share/man
all: $(OBJECTS) $(NAME) all: $(OBJECTS) $(NAME)


$(NAME): $(SOURCES) $(OBJECTS) $(NAME): $(SOURCES) $(OBJECTS)
$(CC) -o $(NAME) $(CFLAGS) $(NAME).c $(OBJECTS) $(LDFLAGS) -DPXZ_BUILD_DATE=\"`date +%Y%m%d`\" -DPXZ_VERSION=\"$(VERSION)\" $(CC) -o $(NAME) $(CPPFLAGS) $(CFLAGS) $(NAME).c $(OBJECTS) $(LDFLAGS) -DPXZ_BUILD_DATE=\"`date +%Y%m%d`\" -DPXZ_VERSION=\"$(VERSION)\"


clean: clean:
rm -f *.o $(NAME) rm -f *.o $(NAME)
Expand Down
23 changes: 16 additions & 7 deletions pxz.c
Expand Up @@ -236,13 +236,22 @@ int main( int argc, char **argv ) {
size_t page_size; size_t page_size;
struct sigaction new_action, old_action; struct sigaction new_action, old_action;
struct utimbuf u; struct utimbuf u;
lzma_filter filters[LZMA_FILTERS_MAX + 1];
lzma_options_lzma lzma_options;


xzcmd_max = sysconf(_SC_ARG_MAX); xzcmd_max = sysconf(_SC_ARG_MAX);
page_size = sysconf(_SC_PAGE_SIZE); page_size = sysconf(_SC_PAGE_SIZE);
xzcmd = malloc(xzcmd_max); xzcmd = malloc(xzcmd_max);
snprintf(xzcmd, xzcmd_max, XZ_BINARY); snprintf(xzcmd, xzcmd_max, XZ_BINARY);


parse_args(argc, argv); parse_args(argc, argv);

lzma_lzma_preset(&lzma_options, opt_complevel);

filters[0].id = LZMA_FILTER_LZMA2;
filters[0].options = &lzma_options;
filters[1].id = LZMA_VLI_UNKNOWN;



for (i=0; i<files; i++) { for (i=0; i<files; i++) {
int std_in = file[i][0] == '-' && file[i][1] == '\0'; int std_in = file[i][0] == '-' && file[i][1] == '\0';
Expand All @@ -264,11 +273,11 @@ int main( int argc, char **argv ) {
} }
} }


chunk_size = opt_context_size*(1<<(opt_complevel <= 1 ? 16 : opt_complevel + 17)); chunk_size = opt_context_size * lzma_options.dict_size;
chunk_size = (chunk_size + page_size)&~(page_size-1); chunk_size = (chunk_size + page_size)&~(page_size-1);


if ( opt_verbose ) { if ( opt_verbose ) {
fprintf(stderr, "context size per thread: %ld B\n", chunk_size); fprintf(stderr, "context size per thread: %llu B\n", chunk_size);
} }


if ( opt_threads && (threads > opt_threads || opt_force) ) { if ( opt_threads && (threads > opt_threads || opt_force) ) {
Expand All @@ -292,9 +301,9 @@ int main( int argc, char **argv ) {


if ( opt_verbose ) { if ( opt_verbose ) {
if ( fo != stdout ) { if ( fo != stdout ) {
fprintf(stderr, "%s -> %ld/%ld thread%c: [", file[i], threads, (s.st_size+chunk_size-1)/chunk_size, threads != 1 ? 's' : ' '); fprintf(stderr, "%s -> %llu/%llu thread%c: [", file[i], threads, (s.st_size+chunk_size-1)/chunk_size, threads != 1 ? 's' : ' ');
} else { } else {
fprintf(stderr, "%ld thread%c: [", threads, threads != 1 ? 's' : ' '); fprintf(stderr, "%llu thread%c: [", threads, threads != 1 ? 's' : ' ');
} }
fflush(stderr); fflush(stderr);
} }
Expand Down Expand Up @@ -337,7 +346,7 @@ int main( int argc, char **argv ) {


mo = malloc(BUFFSIZE); mo = malloc(BUFFSIZE);


if ( lzma_easy_encoder(&strm, opt_complevel, LZMA_CHECK_CRC64) != LZMA_OK ) { if ( lzma_stream_encoder(&strm, filters, LZMA_CHECK_CRC64) != LZMA_OK ) {
error(EXIT_FAILURE, errno, "unable to initialize LZMA encoder"); error(EXIT_FAILURE, errno, "unable to initialize LZMA encoder");
} }


Expand Down Expand Up @@ -381,7 +390,7 @@ int main( int argc, char **argv ) {
free(mo); free(mo);


if ( opt_verbose ) { if ( opt_verbose ) {
fprintf(stderr, "%ld ", p); fprintf(stderr, "%llu ", p);
fflush(stderr); fflush(stderr);
} }
} }
Expand Down Expand Up @@ -442,7 +451,7 @@ int main( int argc, char **argv ) {
sigaction(SIGTERM, &old_action, NULL); sigaction(SIGTERM, &old_action, NULL);


if ( opt_verbose ) { if ( opt_verbose ) {
fprintf(stderr, "%ld -> %ld %3.3f%%\n", s.st_size, ts, ts*100./s.st_size); fprintf(stderr, "%llu -> %zd %3.3f%%\n", s.st_size, ts, ts*100./s.st_size);
} }


if ( !opt_keep && unlink(file[i]) ) { if ( !opt_keep && unlink(file[i]) ) {
Expand Down

0 comments on commit eb3bb6b

Please sign in to comment.