summaryrefslogtreecommitdiff
path: root/arg.c
diff options
context:
space:
mode:
Diffstat (limited to 'arg.c')
-rw-r--r--arg.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/arg.c b/arg.c
index da34f92..c6cd489 100644
--- a/arg.c
+++ b/arg.c
@@ -1003,6 +1003,8 @@ CmdArg::CmdArg()
{
this->num = 0;
this->defaultArgs = NULL;
+ this->usedArgs = NULL;
+ this->usedArgsNum = -1;
}
void CmdArg::load(int argc, char **argv)
@@ -1010,8 +1012,11 @@ void CmdArg::load(int argc, char **argv)
int i;
int pos;
+ this->usedArgs = (int *)calloc(argc,sizeof(int)); //DNCHK
+ this->usedArgsNum = argc;
+
i = 1;
- while (i < argc) {
+ while (i < this->usedArgsNum) {
pos = this->searchArg(argv[i]);
@@ -1045,11 +1050,22 @@ void CmdArg::load(int argc, char **argv)
CmdArgVal *val=(CmdArgVal *)param->getResult();
CmdArgValConf *conf=(CmdArgValConf *)param->getDefault();
- param->setUsed();
- val->setUsed();
- //flag->setFlag();
- val->setValue(param->getParam());
- conf->setUsed();
+ if (i+1<argc)
+ {
+ if ((this->usedArgs[i] == 0)
+ && (this->usedArgs[i+1] == 0))
+ {
+
+ param->setUsed();
+ val->setUsed();
+ //CmdArgDefault *valArg = (CmdArgDefault *)this->defaultArgs[pos];
+ //valArg->setUsed();
+ val->setValue(argv[i+1]);
+ conf->setUsed();
+ this->usedArgs[i] = 1;
+ this->usedArgs[i+1] = 1;
+ }
+ }
break;
}
@@ -1058,10 +1074,18 @@ void CmdArg::load(int argc, char **argv)
CmdArgFlag *flag=(CmdArgFlag *)param->getResult();
CmdArgFlagConf *conf=(CmdArgFlagConf *)param->getDefault();
- param->setUsed();
- flag->setUsed();
- flag->setFlag();
- conf->setUsed();
+ PRINT("ARGT_FLAG\n");
+
+ if (this->usedArgs[pos] == 0)
+ {
+ param->setUsed();
+ flag->setUsed();
+ flag->setFlag();
+ conf->setUsed();
+ this->usedArgs[i] = 1;
+ }
+ //warn?
+
break;
}