Commit a401998e authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

correct sfgets() API to use const char for preprocessor string. whitespace cleanup

parent 0fe5b6c3
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -98,8 +98,8 @@ int utils::cfvarg(std::string mode, const char *arg, char *&cfv_id)
}

/* like fgets() but aborts with an error or EOF is encountered */
void utils::sfgets(char* srcname, int srcline, char *s, int size,
                   FILE *fp, std::string filename, Error *error)
void utils::sfgets(const char *srcname, int srcline, char *s, int size,
                   FILE *fp, const char *filename, Error *error)
{
  char *rv = fgets(s,size,fp);
  if (rv == NULL) { // something went wrong
@@ -112,7 +112,8 @@ void utils::sfgets(char* srcname, int srcline, char *s, int size,
    } else {
      errmsg = "Unexpected short read while reading file '";
    }
    errmsg += filename + "'";
    errmsg += filename;
    errmsg += "'";

    if (error) error->one(srcname,srcline,errmsg.c_str());
    if (s) *s = '\0'; // truncate string to empty in case error is NULL
+2 −2
Original line number Diff line number Diff line
@@ -64,8 +64,8 @@ namespace LAMMPS_NS {
     *  \param filename file name associated with fp (for error message)
     *  \param error    pointer to Error class instance (for abort)
     */
    void sfgets(char* srcname, int srcline, char *s, int size,
                FILE *fp, std::string filename, Error *error);
    void sfgets(const char *srcname, int srcline, char *s, int size,
                FILE *fp, const char *filename, Error *error);
  }
}