Skip to content

Commit

Permalink
0.0.2: fix linux test error
Browse files Browse the repository at this point in the history
  • Loading branch information
leeebo committed Jun 20, 2023
1 parent 066e424 commit 791e19c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion idf_component.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
56 changes: 56 additions & 0 deletions ini_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 12 additions & 11 deletions tests/unittest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 791e19c

Please sign in to comment.