add check that allows only %f and %g conversions in variable format strings
This commit is contained in:
@ -5828,6 +5828,12 @@ Must have periodic x,y dimensions and non-periodic z dimension to use
|
||||
Must have periodic x,y dimensions and non-periodic z dimension to use
|
||||
2d slab option with pppm/disp. :dd
|
||||
|
||||
{Incorrect conversion in format string} :dt
|
||||
|
||||
A format style variable was not using either a %f or a %g conversion.
|
||||
Or an immediate variable with format suffix was not using either
|
||||
a %f or a %g conversion in the format suffix. :dd
|
||||
|
||||
{Incorrect element names in ADP potential file} :dt
|
||||
|
||||
The element names in the ADP file do not match those requested. :dd
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
#include "accelerator_kokkos.h"
|
||||
#include "error.h"
|
||||
#include "memory.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
@ -526,6 +527,11 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag)
|
||||
*fmtflag='\0';
|
||||
}
|
||||
|
||||
// quick check for proper format string
|
||||
|
||||
if (!utils::strmatch(fmtstr,"%[0-9 ]*\\.[0-9]+[fg]"))
|
||||
error->all(FLERR,"Incorrect conversion in format string");
|
||||
|
||||
snprintf(immediate,256,fmtstr,variable->compute_equal(var));
|
||||
value = immediate;
|
||||
|
||||
|
||||
@ -173,6 +173,11 @@ E: Unbalanced quotes in input line
|
||||
No matching end double quote was found following a leading double
|
||||
quote.
|
||||
|
||||
E: Incorrect conversion in format string
|
||||
|
||||
An immediate variable with format suffix was not using
|
||||
either a %f or a %g conversion in the format suffix.
|
||||
|
||||
E: Input line quote not followed by white-space
|
||||
|
||||
An end quote must be followed by white-space.
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include "memory.h"
|
||||
#include "info.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
@ -383,6 +384,8 @@ void Variable::set(int narg, char **arg)
|
||||
num[nvar] = 3;
|
||||
which[nvar] = 0;
|
||||
pad[nvar] = 0;
|
||||
if (!utils::strmatch(arg[2],"%[0-9 ]*\\.[0-9]+[fg]"))
|
||||
error->all(FLERR,"Incorrect conversion in format string");
|
||||
data[nvar] = new char*[num[nvar]];
|
||||
copy(2,&arg[2],data[nvar]);
|
||||
data[nvar][2] = new char[VALUELENGTH];
|
||||
|
||||
@ -210,6 +210,10 @@ E: Invalid variable style with next command
|
||||
Variable styles {equal} and {world} cannot be used in a next
|
||||
command.
|
||||
|
||||
E: Incorrect conversion in format string
|
||||
|
||||
A format style variable was not using either a %f or a %g conversion.
|
||||
|
||||
E: Next command must list all universe and uloop variables
|
||||
|
||||
This is to insure they stay in sync.
|
||||
|
||||
Reference in New Issue
Block a user