T2345: Replace instances of NULL with nullptr
The following changes have been applied to src and lib folders: regex replace: ([^"_])NULL ⇒ \1nullptr (8968 chgs in src, 1153 in lib) Manually find/change: (void \*) nullptr ⇒ nullptr (1 case) regex find: ".*?nullptr.*?" Manually ~14 cases back to "NULL" in src, ~2 in lib regex finds a few false positive where nullptr appears between two strings in a function call
This commit is contained in:
@ -96,15 +96,15 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp)
|
||||
MPI_Comm_rank(world,&me);
|
||||
|
||||
maxline = maxcopy = maxwork = 0;
|
||||
line = copy = work = NULL;
|
||||
line = copy = work = nullptr;
|
||||
narg = maxarg = 0;
|
||||
arg = NULL;
|
||||
arg = nullptr;
|
||||
|
||||
echo_screen = 0;
|
||||
echo_log = 1;
|
||||
|
||||
label_active = 0;
|
||||
labelstr = NULL;
|
||||
labelstr = nullptr;
|
||||
jump_skip = 0;
|
||||
|
||||
if (me == 0) {
|
||||
@ -112,7 +112,7 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp)
|
||||
maxfile = 16;
|
||||
infiles = new FILE *[maxfile];
|
||||
infiles[0] = infile;
|
||||
} else infiles = NULL;
|
||||
} else infiles = nullptr;
|
||||
|
||||
variable = new Variable(lmp);
|
||||
|
||||
@ -196,7 +196,7 @@ void Input::file()
|
||||
// end of file reached, so break
|
||||
// n == 0 if nothing read, else n = line with str terminator
|
||||
|
||||
if (fgets(&line[m],maxline-m,infile) == NULL) {
|
||||
if (fgets(&line[m],maxline-m,infile) == nullptr) {
|
||||
if (m) n = strlen(line) + 1;
|
||||
else n = 0;
|
||||
break;
|
||||
@ -252,7 +252,7 @@ void Input::file()
|
||||
// if no command, skip to next line in input script
|
||||
|
||||
parse();
|
||||
if (command == NULL) continue;
|
||||
if (command == nullptr) continue;
|
||||
|
||||
// if scanning for label, skip command unless it's a label command
|
||||
|
||||
@ -292,7 +292,7 @@ void Input::file(const char *filename)
|
||||
error->one(FLERR,"Too many nested levels of input scripts");
|
||||
|
||||
infile = fopen(filename,"r");
|
||||
if (infile == NULL)
|
||||
if (infile == nullptr)
|
||||
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||
filename, utils::getsyserror()));
|
||||
|
||||
@ -317,7 +317,7 @@ void Input::file(const char *filename)
|
||||
This function takes the text in *single*, makes a copy, parses that,
|
||||
executes the command and returns the name of the command (without the
|
||||
arguments). If there was no command in *single* it will return
|
||||
``NULL``.
|
||||
``nullptr``.
|
||||
|
||||
\endverbatim
|
||||
*
|
||||
@ -338,14 +338,14 @@ char *Input::one(const std::string &single)
|
||||
}
|
||||
|
||||
// parse the line
|
||||
// if no command, just return NULL
|
||||
// if no command, just return nullptr
|
||||
|
||||
parse();
|
||||
if (command == NULL) return NULL;
|
||||
if (command == nullptr) return nullptr;
|
||||
|
||||
// if scanning for label, skip command unless it's a label command
|
||||
|
||||
if (label_active && strcmp(command,"label") != 0) return NULL;
|
||||
if (label_active && strcmp(command,"label") != 0) return nullptr;
|
||||
|
||||
// execute the command and return its name
|
||||
|
||||
@ -423,7 +423,7 @@ void Input::parse()
|
||||
|
||||
char *next;
|
||||
command = nextword(copy,&next);
|
||||
if (command == NULL) return;
|
||||
if (command == nullptr) return;
|
||||
|
||||
// point arg[] at each subsequent arg in copy string
|
||||
// nextword() inserts string terminators into copy string to delimit args
|
||||
@ -450,7 +450,7 @@ void Input::parse()
|
||||
treat text between single/double/triple quotes as one arg
|
||||
matching quote must be followed by whitespace char if not end of string
|
||||
strip quotes from returned word
|
||||
return ptr to start of word or NULL if no word in string
|
||||
return ptr to start of word or nullptr if no word in string
|
||||
also return next = ptr after word
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -461,16 +461,16 @@ char *Input::nextword(char *str, char **next)
|
||||
// start = first non-whitespace char
|
||||
|
||||
start = &str[strspn(str," \t\n\v\f\r")];
|
||||
if (*start == '\0') return NULL;
|
||||
if (*start == '\0') return nullptr;
|
||||
|
||||
// if start is single/double/triple quote:
|
||||
// start = first char beyond quote
|
||||
// stop = first char of matching quote
|
||||
// next = first char beyond matching quote
|
||||
// next must be NULL or whitespace
|
||||
// next must be nullptr or whitespace
|
||||
// if start is not single/double/triple quote:
|
||||
// stop = first whitespace char after start
|
||||
// next = char after stop, or stop itself if stop is NULL
|
||||
// next = char after stop, or stop itself if stop is nullptr
|
||||
|
||||
if (strstr(start,"\"\"\"") == start) {
|
||||
stop = strstr(&start[3],"\"\"\"");
|
||||
@ -492,7 +492,7 @@ char *Input::nextword(char *str, char **next)
|
||||
else *next = stop+1;
|
||||
}
|
||||
|
||||
// set stop to NULL to terminate word
|
||||
// set stop to nullptr to terminate word
|
||||
|
||||
*stop = '\0';
|
||||
return start;
|
||||
@ -510,9 +510,9 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag)
|
||||
// use str2 as scratch space to expand str, then copy back to str
|
||||
// reallocate str and str2 as necessary
|
||||
// do not replace $ inside single/double/triple quotes
|
||||
// var = pts at variable name, ended by NULL
|
||||
// if $ is followed by '{', trailing '}' becomes NULL
|
||||
// else $x becomes x followed by NULL
|
||||
// var = pts at variable name, ended by nullptr
|
||||
// if $ is followed by '{', trailing '}' becomes nullptr
|
||||
// else $x becomes x followed by nullptr
|
||||
// beyond = points to text following variable
|
||||
|
||||
int i,n,paren_count;
|
||||
@ -593,7 +593,7 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag)
|
||||
value = variable->retrieve(var);
|
||||
}
|
||||
|
||||
if (value == NULL)
|
||||
if (value == nullptr)
|
||||
error->one(FLERR,fmt::format("Substitution for illegal "
|
||||
"variable {}",var));
|
||||
|
||||
@ -950,7 +950,7 @@ void Input::include()
|
||||
error->one(FLERR,"Too many nested levels of input scripts");
|
||||
|
||||
infile = fopen(arg[0],"r");
|
||||
if (infile == NULL)
|
||||
if (infile == nullptr)
|
||||
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||
arg[0], utils::getsyserror()));
|
||||
|
||||
@ -984,7 +984,7 @@ void Input::jump()
|
||||
else {
|
||||
if (infile && infile != stdin) fclose(infile);
|
||||
infile = fopen(arg[0],"r");
|
||||
if (infile == NULL)
|
||||
if (infile == nullptr)
|
||||
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||
arg[0], utils::getsyserror()));
|
||||
|
||||
@ -1023,12 +1023,12 @@ void Input::log()
|
||||
|
||||
if (me == 0) {
|
||||
if (logfile) fclose(logfile);
|
||||
if (strcmp(arg[0],"none") == 0) logfile = NULL;
|
||||
if (strcmp(arg[0],"none") == 0) logfile = nullptr;
|
||||
else {
|
||||
if (appendflag) logfile = fopen(arg[0],"a");
|
||||
else logfile = fopen(arg[0],"w");
|
||||
|
||||
if (logfile == NULL)
|
||||
if (logfile == nullptr)
|
||||
error->one(FLERR,fmt::format("Cannot open logfile {}: {}",
|
||||
arg[0], utils::getsyserror()));
|
||||
|
||||
@ -1063,8 +1063,8 @@ void Input::partition()
|
||||
|
||||
strcpy(copy,line);
|
||||
char *ptr = strtok(copy," \t\n\r\f");
|
||||
ptr = strtok(NULL," \t\n\r\f");
|
||||
ptr = strtok(NULL," \t\n\r\f");
|
||||
ptr = strtok(nullptr," \t\n\r\f");
|
||||
ptr = strtok(nullptr," \t\n\r\f");
|
||||
ptr += strlen(ptr) + 1;
|
||||
ptr += strspn(ptr," \t\n\r\f");
|
||||
|
||||
@ -1094,7 +1094,7 @@ void Input::print()
|
||||
|
||||
// parse optional args
|
||||
|
||||
FILE *fp = NULL;
|
||||
FILE *fp = nullptr;
|
||||
int screenflag = 1;
|
||||
int universeflag = 0;
|
||||
|
||||
@ -1103,10 +1103,10 @@ void Input::print()
|
||||
if (strcmp(arg[iarg],"file") == 0 || strcmp(arg[iarg],"append") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal print command");
|
||||
if (me == 0) {
|
||||
if (fp != NULL) fclose(fp);
|
||||
if (fp != nullptr) fclose(fp);
|
||||
if (strcmp(arg[iarg],"file") == 0) fp = fopen(arg[iarg+1],"w");
|
||||
else fp = fopen(arg[iarg+1],"a");
|
||||
if (fp == NULL)
|
||||
if (fp == nullptr)
|
||||
error->one(FLERR,fmt::format("Cannot open print file {}: {}",
|
||||
arg[iarg+1], utils::getsyserror()));
|
||||
}
|
||||
@ -1237,9 +1237,9 @@ void Input::shell()
|
||||
char *ptr = strdup(arg[i]);
|
||||
rv = 0;
|
||||
#ifdef _WIN32
|
||||
if (ptr != NULL) rv = _putenv(ptr);
|
||||
if (ptr != nullptr) rv = _putenv(ptr);
|
||||
#else
|
||||
if (ptr != NULL) rv = putenv(ptr);
|
||||
if (ptr != nullptr) rv = putenv(ptr);
|
||||
#endif
|
||||
rv = (rv < 0) ? errno : 0;
|
||||
MPI_Reduce(&rv,&err,1,MPI_INT,MPI_MAX,0,world);
|
||||
@ -1291,7 +1291,7 @@ void Input::angle_coeff()
|
||||
{
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR,"Angle_coeff command before simulation box is defined");
|
||||
if (force->angle == NULL)
|
||||
if (force->angle == nullptr)
|
||||
error->all(FLERR,"Angle_coeff command before angle_style is defined");
|
||||
if (atom->avec->angles_allow == 0)
|
||||
error->all(FLERR,"Angle_coeff command when no angles allowed");
|
||||
@ -1332,7 +1332,7 @@ void Input::bond_coeff()
|
||||
{
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR,"Bond_coeff command before simulation box is defined");
|
||||
if (force->bond == NULL)
|
||||
if (force->bond == nullptr)
|
||||
error->all(FLERR,"Bond_coeff command before bond_style is defined");
|
||||
if (atom->avec->bonds_allow == 0)
|
||||
error->all(FLERR,"Bond_coeff command when no bonds allowed");
|
||||
@ -1356,7 +1356,7 @@ void Input::bond_write()
|
||||
{
|
||||
if (atom->avec->bonds_allow == 0)
|
||||
error->all(FLERR,"Bond_write command when no bonds allowed");
|
||||
if (force->bond == NULL)
|
||||
if (force->bond == nullptr)
|
||||
error->all(FLERR,"Bond_write command before bond_style is defined");
|
||||
else force->bond->write_file(narg,arg);
|
||||
}
|
||||
@ -1435,7 +1435,7 @@ void Input::dihedral_coeff()
|
||||
{
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR,"Dihedral_coeff command before simulation box is defined");
|
||||
if (force->dihedral == NULL)
|
||||
if (force->dihedral == nullptr)
|
||||
error->all(FLERR,"Dihedral_coeff command before dihedral_style is defined");
|
||||
if (atom->avec->dihedrals_allow == 0)
|
||||
error->all(FLERR,"Dihedral_coeff command when no dihedrals allowed");
|
||||
@ -1512,7 +1512,7 @@ void Input::improper_coeff()
|
||||
{
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR,"Improper_coeff command before simulation box is defined");
|
||||
if (force->improper == NULL)
|
||||
if (force->improper == nullptr)
|
||||
error->all(FLERR,"Improper_coeff command before improper_style is defined");
|
||||
if (atom->avec->impropers_allow == 0)
|
||||
error->all(FLERR,"Improper_coeff command when no impropers allowed");
|
||||
@ -1534,7 +1534,7 @@ void Input::improper_style()
|
||||
|
||||
void Input::kspace_modify()
|
||||
{
|
||||
if (force->kspace == NULL)
|
||||
if (force->kspace == nullptr)
|
||||
error->all(FLERR,"KSpace style has not yet been set");
|
||||
force->kspace->modify_params(narg,arg);
|
||||
}
|
||||
@ -1650,7 +1650,7 @@ void Input::package()
|
||||
modify->add_fix(fixcmd);
|
||||
|
||||
} else if (strcmp(arg[0],"kokkos") == 0) {
|
||||
if (lmp->kokkos == NULL || lmp->kokkos->kokkos_exists == 0)
|
||||
if (lmp->kokkos == nullptr || lmp->kokkos->kokkos_exists == 0)
|
||||
error->all(FLERR,
|
||||
"Package kokkos command without KOKKOS package enabled");
|
||||
lmp->kokkos->accelerator(narg-1,&arg[1]);
|
||||
@ -1682,7 +1682,7 @@ void Input::pair_coeff()
|
||||
{
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR,"Pair_coeff command before simulation box is defined");
|
||||
if (force->pair == NULL)
|
||||
if (force->pair == nullptr)
|
||||
error->all(FLERR,"Pair_coeff command before pair_style is defined");
|
||||
force->pair->coeff(narg,arg);
|
||||
}
|
||||
@ -1691,7 +1691,7 @@ void Input::pair_coeff()
|
||||
|
||||
void Input::pair_modify()
|
||||
{
|
||||
if (force->pair == NULL)
|
||||
if (force->pair == nullptr)
|
||||
error->all(FLERR,"Pair_modify command before pair_style is defined");
|
||||
force->pair->modify_params(narg,arg);
|
||||
}
|
||||
@ -1729,7 +1729,7 @@ void Input::pair_style()
|
||||
|
||||
void Input::pair_write()
|
||||
{
|
||||
if (force->pair == NULL)
|
||||
if (force->pair == nullptr)
|
||||
error->all(FLERR,"Pair_write command before pair_style is defined");
|
||||
force->pair->write_file(narg,arg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user