git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@3734 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -559,17 +559,31 @@ void Input::ifthenelse()
|
|||||||
last = narg-1;
|
last = narg-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last-first < 0) error->all("Illegal if command");
|
int ncommands = last-first + 1;
|
||||||
|
if (ncommands <= 0) error->all("Illegal if command");
|
||||||
|
|
||||||
|
// make copies of arg strings that are commands
|
||||||
|
// required because re-parsing commands via one() will wipe out args
|
||||||
|
|
||||||
|
char **commands = new char*[ncommands];
|
||||||
|
ncommands = 0;
|
||||||
|
for (int i = first; i <= last; i++) {
|
||||||
|
int n = strlen(arg[i]) + 1;
|
||||||
|
if (n == 1) error->all("Illegal if command");
|
||||||
|
commands[ncommands] = new char[n];
|
||||||
|
strcpy(commands[ncommands],arg[i]);
|
||||||
|
ncommands++;
|
||||||
|
}
|
||||||
|
|
||||||
// execute the list of commands
|
// execute the list of commands
|
||||||
|
|
||||||
char str[256];
|
for (int i = 0; i < ncommands; i++)
|
||||||
for (int i = first; i <= last; i++) {
|
char *command = input->one(commands[i]);
|
||||||
if (strlen(arg[i]) == 0) error->all("Illegal if command");
|
|
||||||
strcpy(str,arg[i]);
|
// clean up
|
||||||
strcat(str,"\n");
|
|
||||||
char *tmp = one(str);
|
for (int i = 0; i < ncommands; i++) delete [] commands[i];
|
||||||
}
|
delete [] commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -107,7 +107,7 @@ void Run::command(int narg, char **arg)
|
|||||||
if (uptoflag) nsteps -= update->ntimestep;
|
if (uptoflag) nsteps -= update->ntimestep;
|
||||||
|
|
||||||
// if nevery, make copies of arg strings that are commands
|
// if nevery, make copies of arg strings that are commands
|
||||||
// required because re-parsing commands during run will wipe out args
|
// required because re-parsing commands via input->one() will wipe out args
|
||||||
|
|
||||||
char **commands = NULL;
|
char **commands = NULL;
|
||||||
if (nevery && ncommands > 0) {
|
if (nevery && ncommands > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user