lib: cbprintf: ignore l length modifier on float values
%lf is specified to be the same as %f, and should not be marked as invalid. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
18d7058ac8
commit
a9e2b10a86
2 changed files with 21 additions and 3 deletions
|
@ -538,9 +538,13 @@ int_conv:
|
|||
break;
|
||||
}
|
||||
|
||||
/* Length modifiers other than L are invalid. */
|
||||
if ((conv->length_mod != LENGTH_NONE)
|
||||
&& (conv->length_mod != LENGTH_UPPER_L)) {
|
||||
/* The l specifier has no effect. Otherwise length
|
||||
* modifiers other than L are invalid.
|
||||
*/
|
||||
if (conv->length_mod == LENGTH_L) {
|
||||
conv->length_mod = LENGTH_NONE;
|
||||
} else if ((conv->length_mod != LENGTH_NONE)
|
||||
&& (conv->length_mod != LENGTH_UPPER_L)) {
|
||||
conv->invalid = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -731,6 +731,20 @@ static void test_fp_length(void)
|
|||
double dv = 1.2345;
|
||||
int rc;
|
||||
|
||||
rc = TEST_PRF("/%g/", dv);
|
||||
if (IS_ENABLED(CONFIG_CBPRINTF_FP_SUPPORT)) {
|
||||
PRF_CHECK("/1.2345/", rc);
|
||||
} else {
|
||||
PRF_CHECK("/%g/", rc);
|
||||
}
|
||||
|
||||
rc = TEST_PRF("/%lg/", dv);
|
||||
if (IS_ENABLED(CONFIG_CBPRINTF_FP_SUPPORT)) {
|
||||
PRF_CHECK("/1.2345/", rc);
|
||||
} else {
|
||||
PRF_CHECK("/%lg/", rc);
|
||||
}
|
||||
|
||||
rc = TEST_PRF("/%Lg/", (long double)dv);
|
||||
if (IS_ENABLED(USE_LIBC)) {
|
||||
PRF_CHECK("/1.2345/", rc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue