Skip to content

Commit

Permalink
Add preprocessor exclusions when INI_ALLOW_MULTILINE=0 (#178)
Browse files Browse the repository at this point in the history
Exclude the `prev_name` variable and the ini_strncpy0() call
  • Loading branch information
isidroas authored Oct 24, 2024
1 parent cd5f939 commit ee1fdd2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
size_t offset;
#endif
char section[MAX_SECTION] = "";
#if INI_ALLOW_MULTILINE
char prev_name[MAX_NAME] = "";
#endif

char* start;
char* end;
Expand Down Expand Up @@ -189,7 +191,9 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
if (*end == ']') {
*end = '\0';
ini_strncpy0(section, start + 1, sizeof(section));
#if INI_ALLOW_MULTILINE
*prev_name = '\0';
#endif
#if INI_CALL_HANDLER_ON_NEW_SECTION
if (!HANDLER(user, section, NULL, NULL) && !error)
error = lineno;
Expand All @@ -215,8 +219,10 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
value = ini_lskip(value);
ini_rstrip(value);

/* Valid name[=:]value pair found, call handler */
#if INI_ALLOW_MULTILINE
ini_strncpy0(prev_name, name, sizeof(prev_name));
#endif
/* Valid name[=:]value pair found, call handler */
if (!HANDLER(user, section, name, value) && !error)
error = lineno;
}
Expand Down

0 comments on commit ee1fdd2

Please sign in to comment.