change write_coeff to use utils:sfgets()

This commit is contained in:
Axel Kohlmeyer
2019-02-02 10:20:49 -05:00
parent 989496d26c
commit a8aeba78f3

View File

@ -25,6 +25,7 @@
#include "universe.h" #include "universe.h"
#include "error.h" #include "error.h"
#include "domain.h" #include "domain.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -112,18 +113,18 @@ void WriteCoeff::command(int narg, char **arg)
const char *section = (const char *)""; const char *section = (const char *)"";
fputs(str,two); // style fputs(str,two); // style
fgets(str,256,one); // coeff utils::sfgets(FLERR,str,256,one,file,error); // coeff
n = strlen(str); n = strlen(str);
strcpy(coeff,str); strcpy(coeff,str);
coeff[n-1] = '\0'; coeff[n-1] = '\0';
fgets(str,256,one); utils::sfgets(FLERR,str,256,one,file,error);
while (strcmp(str,"end\n") != 0) { while (strcmp(str,"end\n") != 0) {
if (coeff_mode == REGULAR_MODE) { if (coeff_mode == REGULAR_MODE) {
fprintf(two,"%s %s",coeff,str); fprintf(two,"%s %s",coeff,str);
fgets(str,256,one); utils::sfgets(FLERR,str,256,one,file,error);
} else if (coeff_mode == CLASS2_MODE) { } else if (coeff_mode == CLASS2_MODE) {
@ -135,7 +136,7 @@ void WriteCoeff::command(int narg, char **arg)
// all but the the last section end with an empty line. // all but the the last section end with an empty line.
// skip it and read and parse the next section title // skip it and read and parse the next section title
fgets(str,256,one); utils::sfgets(FLERR,str,256,one,file,error);
if (strcmp(str,"BondBond Coeffs\n") == 0) if (strcmp(str,"BondBond Coeffs\n") == 0)
section = (const char *)"bb"; section = (const char *)"bb";
@ -154,8 +155,9 @@ void WriteCoeff::command(int narg, char **arg)
else if (strcmp(str,"AngleAngle Coeffs\n") == 0) else if (strcmp(str,"AngleAngle Coeffs\n") == 0)
section = (const char *)"aa"; section = (const char *)"aa";
fgets(str,256,one); // gobble up one more empty line // gobble up one more empty line
fgets(str,256,one); utils::sfgets(FLERR,str,256,one,file,error);
utils::sfgets(FLERR,str,256,one,file,error);
} }
// parse type number and skip over it // parse type number and skip over it
@ -165,7 +167,7 @@ void WriteCoeff::command(int narg, char **arg)
while ((*p != '\0') && isdigit(*p)) ++p; while ((*p != '\0') && isdigit(*p)) ++p;
fprintf(two,"%s %d %s %s",coeff,type,section,p); fprintf(two,"%s %d %s %s",coeff,type,section,p);
fgets(str,256,one); utils::sfgets(FLERR,str,256,one,file,error);
} }
} }
fputc('\n',two); fputc('\n',two);