[trunk] improve command line parser syntax checking
This commit is contained in:
parent
8a4095b405
commit
7c120281c7
|
@ -683,10 +683,17 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||||
int res_spec = 0;
|
int res_spec = 0;
|
||||||
|
|
||||||
char *s = opj_optarg;
|
char *s = opj_optarg;
|
||||||
|
int ret;
|
||||||
do {
|
do {
|
||||||
sep = 0;
|
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);
|
¶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;
|
parameters->csty |= 0x01;
|
||||||
res_spec++;
|
res_spec++;
|
||||||
s = strpbrk(s, "]") + 2;
|
s = strpbrk(s, "]") + 2;
|
||||||
|
|
Loading…
Reference in New Issue