summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/ucl/uclpack.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/tools/ucl/uclpack.c b/tools/ucl/uclpack.c
index 08b33af48d..ddf9e04d93 100644
--- a/tools/ucl/uclpack.c
+++ b/tools/ucl/uclpack.c
@@ -149,9 +149,11 @@ static char method_name[64];
149static ucl_bool set_method_name(int method, int level) 149static ucl_bool set_method_name(int method, int level)
150{ 150{
151 method_name[0] = 0; 151 method_name[0] = 0;
152 if (level < 1 || level > 10) 152 if (level < 0 || level > 10)
153 return 0; 153 return 0;
154 if (method == 0x2b) 154 if (level == 0)
155 sprintf(method_name,"uncompressed/%d", level);
156 else if (method == 0x2b)
155 sprintf(method_name,"NRV2B-99/%d", level); 157 sprintf(method_name,"NRV2B-99/%d", level);
156 else if (method == 0x2d) 158 else if (method == 0x2d)
157 sprintf(method_name,"NRV2D-99/%d", level); 159 sprintf(method_name,"NRV2D-99/%d", level);
@@ -219,7 +221,12 @@ int do_compress(FILE *fi, FILE *fo, int method, int level, ucl_uint block_size)
219 221
220 /* compress block */ 222 /* compress block */
221 r = UCL_E_ERROR; 223 r = UCL_E_ERROR;
222 if (method == 0x2b) 224 if (level == 0)
225 {
226 out_len = in_len; /* uncompressed */
227 r = UCL_E_OK;
228 }
229 else if (method == 0x2b)
223 r = ucl_nrv2b_99_compress(in,in_len,out,&out_len,0,level,NULL,NULL); 230 r = ucl_nrv2b_99_compress(in,in_len,out,&out_len,0,level,NULL,NULL);
224 else if (method == 0x2d) 231 else if (method == 0x2d)
225 r = ucl_nrv2d_99_compress(in,in_len,out,&out_len,0,level,NULL,NULL); 232 r = ucl_nrv2d_99_compress(in,in_len,out,&out_len,0,level,NULL,NULL);
@@ -439,7 +446,7 @@ err:
439 446
440static void usage(void) 447static void usage(void)
441{ 448{
442 printf("usage: %s [-123456789] input-file output-file (compress)\n", progname); 449 printf("usage: %s [-0123456789] input-file output-file (compress)\n", progname);
443 printf("usage: %s -d input-file output-file (decompress)\n", progname); 450 printf("usage: %s -d input-file output-file (decompress)\n", progname);
444 printf("usage: %s -t input-file... (test)\n", progname); 451 printf("usage: %s -t input-file... (test)\n", progname);
445 exit(1); 452 exit(1);
@@ -575,12 +582,14 @@ int main(int argc, char *argv[])
575 opt_method = 0x2e; 582 opt_method = 0x2e;
576 else if (strcmp(argv[i],"--nrv2e") == 0) 583 else if (strcmp(argv[i],"--nrv2e") == 0)
577 opt_method = 0x2e; 584 opt_method = 0x2e;
578 else if ((argv[i][1] >= '1' && argv[i][1] <= '9') && !argv[i][2]) 585 else if ((argv[i][1] >= '0' && argv[i][1] <= '9') && !argv[i][2])
579 opt_level = argv[i][1] - '0'; 586 opt_level = argv[i][1] - '0';
580 else if (strcmp(argv[i],"--10") == 0) 587 else if (strcmp(argv[i],"--10") == 0)
581 opt_level = 10; 588 opt_level = 10;
582 else if (strcmp(argv[i],"--best") == 0) 589 else if (strcmp(argv[i],"--best") == 0)
583 opt_level = 10; 590 opt_level = 10;
591 else if (strcmp(argv[i],"--none") == 0)
592 opt_level = 0;
584 else if (argv[i][1] == 'b' && argv[i][2]) 593 else if (argv[i][1] == 'b' && argv[i][2])
585 { 594 {
586#if (UCL_UINT_MAX > UINT_MAX) && defined(HAVE_ATOL) 595#if (UCL_UINT_MAX > UINT_MAX) && defined(HAVE_ATOL)