avoid segfault and print more meaningful error message with empty lines in coeff sections
This commit is contained in:
@ -9990,25 +9990,25 @@ quote. :dd
|
|||||||
|
|
||||||
Self-explanatory. :dd
|
Self-explanatory. :dd
|
||||||
|
|
||||||
{Unexpected end of AngleCoeffs section} :dt
|
{Unexpected empty line in AngleCoeffs section} :dt
|
||||||
|
|
||||||
Read a blank line. :dd
|
Read a blank line where there should be coefficient data. :dd
|
||||||
|
|
||||||
{Unexpected end of BondCoeffs section} :dt
|
{Unexpected empty line in BondCoeffs section} :dt
|
||||||
|
|
||||||
Read a blank line. :dd
|
Read a blank line where there should be coefficient data. :dd
|
||||||
|
|
||||||
{Unexpected end of DihedralCoeffs section} :dt
|
{Unexpected empty line in DihedralCoeffs section} :dt
|
||||||
|
|
||||||
Read a blank line. :dd
|
Read a blank line where there should be coefficient data. :dd
|
||||||
|
|
||||||
{Unexpected end of ImproperCoeffs section} :dt
|
{Unexpected empty line in ImproperCoeffs section} :dt
|
||||||
|
|
||||||
Read a blank line. :dd
|
Read a blank line where there should be coefficient data. :dd
|
||||||
|
|
||||||
{Unexpected end of PairCoeffs section} :dt
|
{Unexpected empty line in PairCoeffs section} :dt
|
||||||
|
|
||||||
Read a blank line. :dd
|
Read a blank line where there should be coefficient data. :dd
|
||||||
|
|
||||||
{Unexpected end of custom file} :dt
|
{Unexpected end of custom file} :dt
|
||||||
|
|
||||||
|
|||||||
@ -1768,7 +1768,8 @@ void ReadData::paircoeffs()
|
|||||||
next = strchr(buf,'\n');
|
next = strchr(buf,'\n');
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
parse_coeffs(buf,NULL,1,2,toffset);
|
parse_coeffs(buf,NULL,1,2,toffset);
|
||||||
if (narg == 0) error->all(FLERR,"Unexpected end of PairCoeffs section");
|
if (narg == 0)
|
||||||
|
error->all(FLERR,"Unexpected empty line in PairCoeffs section");
|
||||||
force->pair->coeff(narg,arg);
|
force->pair->coeff(narg,arg);
|
||||||
buf = next + 1;
|
buf = next + 1;
|
||||||
}
|
}
|
||||||
@ -1794,7 +1795,8 @@ void ReadData::pairIJcoeffs()
|
|||||||
next = strchr(buf,'\n');
|
next = strchr(buf,'\n');
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
parse_coeffs(buf,NULL,0,2,toffset);
|
parse_coeffs(buf,NULL,0,2,toffset);
|
||||||
if (narg == 0) error->all(FLERR,"Unexpected end of PairCoeffs section");
|
if (narg == 0)
|
||||||
|
error->all(FLERR,"Unexpected empty line in PairCoeffs section");
|
||||||
force->pair->coeff(narg,arg);
|
force->pair->coeff(narg,arg);
|
||||||
buf = next + 1;
|
buf = next + 1;
|
||||||
}
|
}
|
||||||
@ -1818,7 +1820,8 @@ void ReadData::bondcoeffs()
|
|||||||
next = strchr(buf,'\n');
|
next = strchr(buf,'\n');
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
parse_coeffs(buf,NULL,0,1,boffset);
|
parse_coeffs(buf,NULL,0,1,boffset);
|
||||||
if (narg == 0) error->all(FLERR,"Unexpected end of BondCoeffs section");
|
if (narg == 0)
|
||||||
|
error->all(FLERR,"Unexpected empty line in BondCoeffs section");
|
||||||
force->bond->coeff(narg,arg);
|
force->bond->coeff(narg,arg);
|
||||||
buf = next + 1;
|
buf = next + 1;
|
||||||
}
|
}
|
||||||
@ -1844,7 +1847,7 @@ void ReadData::anglecoeffs(int which)
|
|||||||
if (which == 0) parse_coeffs(buf,NULL,0,1,aoffset);
|
if (which == 0) parse_coeffs(buf,NULL,0,1,aoffset);
|
||||||
else if (which == 1) parse_coeffs(buf,"bb",0,1,aoffset);
|
else if (which == 1) parse_coeffs(buf,"bb",0,1,aoffset);
|
||||||
else if (which == 2) parse_coeffs(buf,"ba",0,1,aoffset);
|
else if (which == 2) parse_coeffs(buf,"ba",0,1,aoffset);
|
||||||
if (narg == 0) error->all(FLERR,"Unexpected end of AngleCoeffs section");
|
if (narg == 0) error->all(FLERR,"Unexpected empty line in AngleCoeffs section");
|
||||||
force->angle->coeff(narg,arg);
|
force->angle->coeff(narg,arg);
|
||||||
buf = next + 1;
|
buf = next + 1;
|
||||||
}
|
}
|
||||||
@ -1873,7 +1876,8 @@ void ReadData::dihedralcoeffs(int which)
|
|||||||
else if (which == 3) parse_coeffs(buf,"at",0,1,doffset);
|
else if (which == 3) parse_coeffs(buf,"at",0,1,doffset);
|
||||||
else if (which == 4) parse_coeffs(buf,"aat",0,1,doffset);
|
else if (which == 4) parse_coeffs(buf,"aat",0,1,doffset);
|
||||||
else if (which == 5) parse_coeffs(buf,"bb13",0,1,doffset);
|
else if (which == 5) parse_coeffs(buf,"bb13",0,1,doffset);
|
||||||
if (narg == 0) error->all(FLERR,"Unexpected end of DihedralCoeffs section");
|
if (narg == 0)
|
||||||
|
error->all(FLERR,"Unexpected empty line in DihedralCoeffs section");
|
||||||
force->dihedral->coeff(narg,arg);
|
force->dihedral->coeff(narg,arg);
|
||||||
buf = next + 1;
|
buf = next + 1;
|
||||||
}
|
}
|
||||||
@ -1898,7 +1902,7 @@ void ReadData::impropercoeffs(int which)
|
|||||||
*next = '\0';
|
*next = '\0';
|
||||||
if (which == 0) parse_coeffs(buf,NULL,0,1,ioffset);
|
if (which == 0) parse_coeffs(buf,NULL,0,1,ioffset);
|
||||||
else if (which == 1) parse_coeffs(buf,"aa",0,1,ioffset);
|
else if (which == 1) parse_coeffs(buf,"aa",0,1,ioffset);
|
||||||
if (narg == 0) error->all(FLERR,"Unexpected end of ImproperCoeffs section");
|
if (narg == 0) error->all(FLERR,"Unexpected empty line in ImproperCoeffs section");
|
||||||
force->improper->coeff(narg,arg);
|
force->improper->coeff(narg,arg);
|
||||||
buf = next + 1;
|
buf = next + 1;
|
||||||
}
|
}
|
||||||
@ -2092,6 +2096,10 @@ void ReadData::parse_coeffs(char *line, const char *addstr,
|
|||||||
word = strtok(NULL," \t\n\r\f");
|
word = strtok(NULL," \t\n\r\f");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to avoid segfaults on empty lines
|
||||||
|
|
||||||
|
if (narg == 0) return;
|
||||||
|
|
||||||
if (noffset) {
|
if (noffset) {
|
||||||
int value = force->inumeric(FLERR,arg[0]);
|
int value = force->inumeric(FLERR,arg[0]);
|
||||||
sprintf(argoffset1,"%d",value+offset);
|
sprintf(argoffset1,"%d",value+offset);
|
||||||
|
|||||||
@ -533,25 +533,25 @@ E: Too many lines in one body in data file - boost MAXBODY
|
|||||||
MAXBODY is a setting at the top of the src/read_data.cpp file.
|
MAXBODY is a setting at the top of the src/read_data.cpp file.
|
||||||
Set it larger and re-compile the code.
|
Set it larger and re-compile the code.
|
||||||
|
|
||||||
E: Unexpected end of PairCoeffs section
|
E: Unexpected empty line in PairCoeffs section
|
||||||
|
|
||||||
Read a blank line.
|
Read a blank line where there should be coefficient data.
|
||||||
|
|
||||||
E: Unexpected end of BondCoeffs section
|
E: Unexpected empty line in BondCoeffs section
|
||||||
|
|
||||||
Read a blank line.
|
Read a blank line where there should be coefficient data.
|
||||||
|
|
||||||
E: Unexpected end of AngleCoeffs section
|
E: Unexpected empty line in AngleCoeffs section
|
||||||
|
|
||||||
Read a blank line.
|
Read a blank line where there should be coefficient data.
|
||||||
|
|
||||||
E: Unexpected end of DihedralCoeffs section
|
E: Unexpected empty line in DihedralCoeffs section
|
||||||
|
|
||||||
Read a blank line.
|
Read a blank line where there should be coefficient data.
|
||||||
|
|
||||||
E: Unexpected end of ImproperCoeffs section
|
E: Unexpected empty line in ImproperCoeffs section
|
||||||
|
|
||||||
Read a blank line.
|
Read a blank line where there should be coefficient data.
|
||||||
|
|
||||||
E: Cannot open gzipped file
|
E: Cannot open gzipped file
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user