int res_spec = 0;
char *s = opj_optarg;
+ int ret;
do {
sep = 0;
- sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
+ ret = sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
¶meters->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;