Commit 989496d2 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

use utils::sfgets() where the return status of fgets() is not checked

parent a401998e
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

@@ -361,9 +362,9 @@ void PairTable::read_table(Table *tb, char *file, char *keyword)

  FILE *fp = force->open_potential(file);
  if (fp == NULL) {
    char str[128];
    snprintf(str,128,"Cannot open file %s",file);
    error->one(FLERR,str);
    std::string str("Cannot open file ");
    str += file;
    error->one(FLERR,str.c_str());
  }

  // loop until section found with matching keyword
@@ -375,16 +376,17 @@ void PairTable::read_table(Table *tb, char *file, char *keyword)
    if (line[0] == '#') continue;                          // comment
    char *word = strtok(line," \t\n\r");
    if (strcmp(word,keyword) == 0) break;            // matching keyword
    fgets(line,MAXLINE,fp);                         // no match, skip section
    utils::sfgets(FLERR,line,MAXLINE,fp,file,error); // no match, skip section
    param_extract(tb,line);
    fgets(line,MAXLINE,fp);
    for (int i = 0; i < tb->ninput; i++) fgets(line,MAXLINE,fp);
    utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
    for (int i = 0; i < tb->ninput; i++) 
      utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
  }

  // read args on 2nd line of section
  // allocate table arrays for file values

  fgets(line,MAXLINE,fp);
  utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
  param_extract(tb,line);
  memory->create(tb->rfile,tb->ninput,"pair:rfile");
  memory->create(tb->efile,tb->ninput,"pair:efile");
@@ -412,7 +414,7 @@ void PairTable::read_table(Table *tb, char *file, char *keyword)
  int rerror = 0;
  int cerror = 0;

  fgets(line,MAXLINE,fp);
  utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
  for (int i = 0; i < tb->ninput; i++) {
    if (NULL == fgets(line,MAXLINE,fp))
      error->one(FLERR,"Premature end of file in pair table");