std.cfg: Allow scientific floating point notation for '<valid>'-tags

This commit is contained in:
orbitcowboy 2020-06-12 08:51:33 +02:00
parent e767bb8ff3
commit a3d58a9302
4 changed files with 90 additions and 2 deletions

View File

@ -228,8 +228,8 @@
</optional>
<optional>
<element name="valid">
<data type="string">
<param name="pattern">(-?[0-9]*(\.[0-9]+)?[,:])*([-]?[0-9]+(\.[0-9]+)?)?</param>
<data type="string"> <!-- regex test: https://regex101.com/r/LoRGVj/2/ -->
<param name="pattern">(-?[0-9]*(\.[0-9]+)?([eE][-+]?[0-9]+)?[,:])*([-]?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?)?</param>
</data>
</element>
</optional>

View File

@ -3173,6 +3173,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>4.94066e-324:</valid>
</arg>
</function>
<!-- float logf(float x); -->
@ -3183,6 +3184,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>1.4013e-45:</valid>
</arg>
</function>
<!-- long double logl(long double x);-->
@ -3193,6 +3195,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>4.94066e-324:</valid>
</arg>
</function>
<!-- double complex clog(double complex x); -->
@ -3494,6 +3497,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>4.94066e-324:</valid>
</arg>
</function>
<!-- float log10f(float x);-->
@ -3505,6 +3509,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>1.4013e-45:</valid>
</arg>
</function>
<!-- long double log10l(long double x); -->
@ -3516,6 +3521,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>4.94066e-324:</valid>
</arg>
</function>
<!-- double log1p(double x); -->
@ -3560,6 +3566,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>4.94066e-324:</valid>
</arg>
</function>
<!-- float log2f(float x); -->
@ -3571,6 +3578,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>1.4013e-45:</valid>
</arg>
</function>
<!-- long double log2l(long double x); -->
@ -3582,6 +3590,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>4.94066e-324:</valid>
</arg>
</function>
<!-- double nearbyint(double x); -->

View File

@ -711,6 +711,7 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
bool error = false;
bool range = false;
bool has_dot = false;
bool has_E = false;
if (!p)
return Error(BAD_ATTRIBUTE_VALUE, "\"\"");
@ -723,15 +724,20 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
error |= range | (*(p+1) == '.');
range = true;
has_dot = false;
has_E = false;
} else if (*p == '-')
error |= (!std::isdigit(*(p+1)));
else if (*p == ',') {
range = false;
error |= *(p+1) == '.';
has_dot = false;
has_E = false;
} else if (*p == '.') {
error |= has_dot | (!std::isdigit(*(p+1)));
has_dot = true;
} else if (*p == 'E' || *p == 'e') {
error |= has_E;
has_E = true;
} else
error = true;
}

View File

@ -23,6 +23,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <inttypes.h>
#include <float.h>
void bufferAccessOutOfBounds(void)
{
@ -3134,6 +3135,78 @@ void invalidFunctionArg_strchr(char *cs, int c)
(void)strchr(cs, 256);
}
void invalidFunctionArg_log10(float f, double d, const long double ld)
{
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress wrongmathcall
(void)log10f(0.0f);
(void)log10f(1.4013e-45f); // note: calculated by nextafterf(0.0f, 1.0f);
(void)log10f(f);
(void)log10f(FLT_MAX);
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress wrongmathcall
(void)log10(0.0);
(void)log10(4.94066e-324); // note: calculated by nextafterf(0.0, 1.0);
(void)log10(d);
(void)log10(DBL_MAX);
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress wrongmathcall
(void)log10l(0.0L);
(void)log10l(4.94066e-324L); // note: calculated by nextafterf(0.0L, 1.0L);
(void)log10l(ld);
(void)log10l(LDBL_MAX);
}
void invalidFunctionArg_log(float f, double d, const long double ld)
{
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress wrongmathcall
(void)logf(0.0f);
(void)logf(1.4013e-45f); // note: calculated by nextafterf(0.0f, 1.0f);
(void)logf(f);
(void)logf(FLT_MAX);
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress wrongmathcall
(void)log(0.0);
(void)log(4.94066e-324); // note: calculated by nextafterf(0.0, 1.0);
(void)log(d);
(void)log(DBL_MAX);
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress wrongmathcall
(void)logl(0.0L);
(void)logl(4.94066e-324L); // note: calculated by nextafterf(0.0L, 1.0L);
(void)logl(ld);
(void)logl(LDBL_MAX);
}
void invalidFunctionArg_log2(float f, double d, const long double ld)
{
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress wrongmathcall
(void)log2f(0.0f);
(void)log2f(1.4013e-45f); // note: calculated by nextafterf(0.0f, 1.0f);
(void)log2f(f);
(void)log2f(FLT_MAX);
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress wrongmathcall
(void)log2(0.0);
(void)log2(4.94066e-324); // note: calculated by nextafterf(0.0, 1.0);
(void)log2(d);
(void)log2(DBL_MAX);
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress wrongmathcall
(void)log2l(0.0L);
(void)log2l(4.94066e-324L); // note: calculated by nextafterf(0.0L, 1.0L);
(void)log2l(ld);
(void)log2l(LDBL_MAX);
}
void uninitvar_wcschr(void)
{
wchar_t *cs;