summaryrefslogtreecommitdiff
path: root/codec/compat
diff options
context:
space:
mode:
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-06-04 13:23:26 +0000
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-06-04 13:23:26 +0000
commitea9335ff48f106556e04a249d88246dba493a62a (patch)
tree405b1f1960745fa1c4645b0abedab9e7cb8da1a6 /codec/compat
parentadc1aacb600419d6ce8427d652da4f53efc5e408 (diff)
Bugs corrected in decoding of command line (getopt.c), in the handling of 16 bit files (t1.c and tcd.c) and the calculation of elapsed time for multiple tiles parts (tcd.c and tdc.h).
Diffstat (limited to 'codec/compat')
-rw-r--r--codec/compat/getopt.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/codec/compat/getopt.c b/codec/compat/getopt.c
index 3ecbde15..1491bf03 100644
--- a/codec/compat/getopt.c
+++ b/codec/compat/getopt.c
@@ -129,11 +129,27 @@ struct option *longopts, int totlen) {
static int lastidx,lastofs;
char *tmp;
int i,len;
+ char param = 1;
+
again:
- if (optind>argc || !argv[optind] || *argv[optind]!='-' || argv[optind][1]==0)
+ if (optind>argc || !argv[optind] || *argv[optind]!='-')
return -1;
if (argv[optind][0]=='-' && argv[optind][1]==0) {
+ if(optind >= (argc - 1)){ /* no more input parameters */
+ param = 0;
+ }
+ else{ /* more input parameters */
+ if(argv[optind + 1][0] == '-'){
+ param = 0; /* Missing parameter after '-' */
+ }
+ else{
+ param = 2;
+ }
+ }
+ }
+
+ if (param == 0) {
++optind;
return (BADCH);
}
@@ -144,11 +160,18 @@ again:
o=longopts;
len=sizeof(longopts[0]);
+ if (param > 1){
+ arg = argv[optind+1];
+ optind++;
+ }
+ else
+ arg = argv[optind]+1;
+
if(strlen(arg)>1){
for (i=0;i<totlen;i=i+len,o++) {
if (!strcmp(o->name,arg)) { /* match */
if (o->has_arg == 0) {
- if (!(argv[optind+1][0]=='-')){
+ if ((argv[optind+1])&&(!(argv[optind+1][0]=='-'))){
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[optind+1]);
++optind;
}