From 791e19cfc45773d0ec4ab2ef7d7fe32cf4e33ace Mon Sep 17 00:00:00 2001 From: Li Bo Date: Tue, 20 Jun 2023 15:07:07 +0800 Subject: [PATCH] 0.0.2: fix linux test error --- CHANGELOG.md | 4 ++++ idf_component.yml | 2 +- ini_config.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++ tests/unittest.c | 23 +++++++++---------- 4 files changed, 73 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38653ca..035f258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # ChangeLog +## v0.0.2 - 2023-06-20 + +* Fix test + ## v0.0.1 - 2023-06-20 * Initial version (base version [d6e9d1](https://github.com/benhoyt/inih/commit/d6e9d1ba68148060d5614145eb566b94fc0d532f)), test pass on ESP32S3 diff --git a/idf_component.yml b/idf_component.yml index 45d10f1..c1d964c 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -1,4 +1,4 @@ -version: "0.0.1" +version: "0.0.2" description: Simple .INI file parser written in C, portting for ESP-IDF url: https://github.com/leeebo/esp-inih repository: https://github.com/leeebo/esp-inih.git diff --git a/ini_config.h b/ini_config.h index db2c95c..f7b928d 100644 --- a/ini_config.h +++ b/ini_config.h @@ -9,59 +9,115 @@ #include "sdkconfig.h" /* Nonzero if ini_handler callback should accept lineno parameter. */ +#ifdef CONFIG_INI_HANDLER_LINENO #define INI_HANDLER_LINENO CONFIG_INI_HANDLER_LINENO +#else +#define INI_HANDLER_LINENO 0 +#endif /* Nonzero to allow multi-line value parsing, in the style of Python's configparser. If allowed, ini_parse() will call the handler with the same name for each subsequent line parsed. */ +#ifdef CONFIG_INI_ALLOW_MULTILINE #define INI_ALLOW_MULTILINE CONFIG_INI_ALLOW_MULTILINE +#else +#define INI_ALLOW_MULTILINE 0 +#endif /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of the file. See https://github.com/benhoyt/inih/issues/21 */ +#ifdef CONFIG_INI_ALLOW_BOM #define INI_ALLOW_BOM CONFIG_INI_ALLOW_BOM +#else +#define INI_ALLOW_BOM 0 +#endif /* Chars that begin a start-of-line comment. Per Python configparser, allow both ; and # comments at the start of a line by default. */ +#ifdef CONFIG_INI_START_COMMENT_PREFIXES #define INI_START_COMMENT_PREFIXES CONFIG_INI_START_COMMENT_PREFIXES +#else +#define INI_START_COMMENT_PREFIXES ";#" +#endif /* Nonzero to allow inline comments (with valid inline comment characters specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match Python 3.2+ configparser behaviour. */ +#ifdef CONFIG_INI_ALLOW_INLINE_COMMENTS #define INI_ALLOW_INLINE_COMMENTS CONFIG_INI_ALLOW_INLINE_COMMENTS +#else +#define INI_ALLOW_INLINE_COMMENTS 0 +#endif +#ifdef CONFIG_INI_INLINE_COMMENT_PREFIXES #define INI_INLINE_COMMENT_PREFIXES CONFIG_INI_INLINE_COMMENT_PREFIXES +#else +#define INI_INLINE_COMMENT_PREFIXES ";" +#endif /* Nonzero to use stack for line buffer, zero to use heap (malloc/free). */ +#ifdef CONFIG_INI_USE_STACK #define INI_USE_STACK CONFIG_INI_USE_STACK +#else +#define INI_USE_STACK 0 +#endif /* Maximum line length for any line in INI file (stack or heap). Note that this must be 3 more than the longest line (due to '\r', '\n', and '\0'). */ +#ifdef CONFIG_INI_MAX_LINE #define INI_MAX_LINE CONFIG_INI_MAX_LINE +#else +#define INI_MAX_LINE 200 +#endif /* Nonzero to allow heap line buffer to grow via realloc(), zero for a fixed-size buffer of INI_MAX_LINE bytes. Only applies if INI_USE_STACK is zero. */ +#ifdef CONFIG_INI_ALLOW_REALLOC #define INI_ALLOW_REALLOC CONFIG_INI_ALLOW_REALLOC +#else +#define INI_ALLOW_REALLOC 0 +#endif /* Initial size in bytes for heap line buffer. Only applies if INI_USE_STACK is zero. */ +#ifdef CONFIG_INI_INITIAL_ALLOC #define INI_INITIAL_ALLOC CONFIG_INI_INITIAL_ALLOC +#else +#define INI_INITIAL_ALLOC 200 +#endif /* Stop parsing on first error (default is to keep parsing). */ +#ifdef CONFIG_INI_STOP_ON_FIRST_ERROR #define INI_STOP_ON_FIRST_ERROR CONFIG_INI_STOP_ON_FIRST_ERROR +#else +#define INI_STOP_ON_FIRST_ERROR 0 +#endif /* Nonzero to call the handler at the start of each new section (with name and value NULL). Default is to only call the handler on each name=value pair. */ +#ifdef CONFIG_INI_CALL_HANDLER_ON_NEW_SECTION #define INI_CALL_HANDLER_ON_NEW_SECTION CONFIG_INI_CALL_HANDLER_ON_NEW_SECTION +#else +#define INI_CALL_HANDLER_ON_NEW_SECTION 0 +#endif /* Nonzero to allow a name without a value (no '=' or ':' on the line) and call the handler with value NULL in this case. Default is to treat no-value lines as an error. */ +#ifdef CONFIG_INI_ALLOW_NO_VALUE #define INI_ALLOW_NO_VALUE CONFIG_INI_ALLOW_NO_VALUE +#else +#define INI_ALLOW_NO_VALUE 0 +#endif /* Nonzero to use custom ini_malloc, ini_free, and ini_realloc memory allocation functions (INI_USE_STACK must also be 0). These functions must have the same signatures as malloc/free/realloc and behave in a similar way. ini_realloc is only needed if INI_ALLOW_REALLOC is set. */ +#ifdef CONFIG_INI_CUSTOM_ALLOCATOR #define INI_CUSTOM_ALLOCATOR CONFIG_INI_CUSTOM_ALLOCATOR +#else +#define INI_CUSTOM_ALLOCATOR 0 +#endif #endif \ No newline at end of file diff --git a/tests/unittest.c b/tests/unittest.c index c0dd0f7..52ffde6 100644 --- a/tests/unittest.c +++ b/tests/unittest.c @@ -101,23 +101,24 @@ void spiffs_init(void) { void app_main(void) #else -#define BASE_PATH "." +#define FOLDER_PATH int main(void) #endif { #ifdef CONFIG_IDF_TARGET +#define FOLDER_PATH BASE_PATH "/" spiffs_init(); #endif - parse(BASE_PATH "/" "no_file.ini"); - parse(BASE_PATH "/" "normal.ini"); - parse(BASE_PATH "/" "bad_section.ini"); - parse(BASE_PATH "/" "bad_comment.ini"); - parse(BASE_PATH "/" "user_error.ini"); - parse(BASE_PATH "/" "multi_line.ini"); - parse(BASE_PATH "/" "bad_multi.ini"); - parse(BASE_PATH "/" "bom.ini"); - parse(BASE_PATH "/" "duplicate_sections.ini"); - parse(BASE_PATH "/" "no_value.ini"); + parse(FOLDER_PATH "no_file.ini"); + parse(FOLDER_PATH "normal.ini"); + parse(FOLDER_PATH "bad_section.ini"); + parse(FOLDER_PATH "bad_comment.ini"); + parse(FOLDER_PATH "user_error.ini"); + parse(FOLDER_PATH "multi_line.ini"); + parse(FOLDER_PATH "bad_multi.ini"); + parse(FOLDER_PATH "bom.ini"); + parse(FOLDER_PATH "duplicate_sections.ini"); + parse(FOLDER_PATH "no_value.ini"); #ifndef CONFIG_IDF_TARGET return 0; #endif