summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>2014-02-27 10:02:46 +0000
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2014-02-27 10:02:46 +0000
commit7c120281c7659809a783d0b1bcfd844e634b77c8 (patch)
tree2f14e7b82af332439216ac8347c7bac174449112 /src/bin
parent8a4095b40566634a17912e10f1cc041c96f0d162 (diff)
[trunk] improve command line parser syntax checking
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/jp2/opj_compress.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c
index 33efe757..5ed5228f 100644
--- a/src/bin/jp2/opj_compress.c
+++ b/src/bin/jp2/opj_compress.c
@@ -683,10 +683,17 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
int res_spec = 0;
char *s = opj_optarg;
+ int ret;
do {
sep = 0;
- sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec],
+ ret = sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec],
&parameters->prch_init[res_spec], &sep);
+ if( !(ret == 2 && sep == 0) && !(ret == 3 && sep == ',') )
+ {
+ fprintf(stderr,"\nError: could not parse precinct dimension: '%s' %x\n", s, sep);
+ fprintf(stderr,"Example: -i lena.raw -o lena.j2k -c [128,128],[128,128]\n");
+ return 1;
+ }
parameters->csty |= 0x01;
res_spec++;
s = strpbrk(s, "]") + 2;