1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

fix(printf): fix built-in snprintf cannot be disabled (#3776)

Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
_VIFEXTech 2022-10-30 15:41:57 +08:00 committed by GitHub
parent 532a3ebbc7
commit 39db14d75e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View File

@ -33,6 +33,9 @@
/*Original repository: https://github.com/mpaland/printf*/
#include "lv_printf.h"
#if LV_USE_BUILTIN_SNPRINTF
#include <stdbool.h>
#define PRINTF_DISABLE_SUPPORT_FLOAT (!LV_SPRINTF_USE_FLOAT)
@ -872,3 +875,5 @@ int lv_vsnprintf_builtin(char * buffer, size_t count, const char * format, va_li
{
return _vsnprintf(_out_buffer, buffer, count, format, va);
}
#endif /*LV_USE_BUILTIN_SNPRINTF*/

View File

@ -62,9 +62,14 @@ extern "C" {
#include "../lv_conf_internal.h"
#include LV_STDIO_INCLUDE
#define lv_snprintf LV_SNPRINTF
#define lv_vsnprintf LV_VSNPRINTF
#if LV_USE_BUILTIN_SNPRINTF
#include <stdarg.h>
#include <stddef.h>
#include "lv_types.h"
typedef struct {
@ -75,9 +80,7 @@ typedef struct {
int lv_snprintf_builtin(char * buffer, size_t count, const char * format, ...);
int lv_vsnprintf_builtin(char * buffer, size_t count, const char * format, va_list va);
#define lv_snprintf LV_SNPRINTF
#define lv_vsnprintf LV_VSNPRINTF
#endif /*LV_USE_BUILTIN_SNPRINTF*/
#ifdef __cplusplus
} /*extern "C"*/

View File

@ -502,11 +502,11 @@ static void browser_file_event_handler(lv_event_t * e)
strip_ext(explorer->current_path);
/*Remove the last '/' character*/
strip_ext(explorer->current_path);
lv_snprintf_builtin((char *)file_name, sizeof(file_name), "%s", explorer->current_path);
lv_snprintf((char *)file_name, sizeof(file_name), "%s", explorer->current_path);
}
else {
if(strcmp(str_fn, "..") != 0) {
lv_snprintf_builtin((char *)file_name, sizeof(file_name), "%s%s", explorer->current_path, str_fn);
lv_snprintf((char *)file_name, sizeof(file_name), "%s%s", explorer->current_path, str_fn);
}
}