mirror of
https://github.com/benhoyt/inih.git
synced 2025-01-28 22:52:54 +08:00
Add preprocessor exclusions when INI_ALLOW_MULTILINE=0 (#178)
Exclude the `prev_name` variable and the ini_strncpy0() call
This commit is contained in:
parent
cd5f939740
commit
ee1fdd21ad
8
ini.c
8
ini.c
@ -110,7 +110,9 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
|||||||
size_t offset;
|
size_t offset;
|
||||||
#endif
|
#endif
|
||||||
char section[MAX_SECTION] = "";
|
char section[MAX_SECTION] = "";
|
||||||
|
#if INI_ALLOW_MULTILINE
|
||||||
char prev_name[MAX_NAME] = "";
|
char prev_name[MAX_NAME] = "";
|
||||||
|
#endif
|
||||||
|
|
||||||
char* start;
|
char* start;
|
||||||
char* end;
|
char* end;
|
||||||
@ -189,7 +191,9 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
|||||||
if (*end == ']') {
|
if (*end == ']') {
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
ini_strncpy0(section, start + 1, sizeof(section));
|
ini_strncpy0(section, start + 1, sizeof(section));
|
||||||
|
#if INI_ALLOW_MULTILINE
|
||||||
*prev_name = '\0';
|
*prev_name = '\0';
|
||||||
|
#endif
|
||||||
#if INI_CALL_HANDLER_ON_NEW_SECTION
|
#if INI_CALL_HANDLER_ON_NEW_SECTION
|
||||||
if (!HANDLER(user, section, NULL, NULL) && !error)
|
if (!HANDLER(user, section, NULL, NULL) && !error)
|
||||||
error = lineno;
|
error = lineno;
|
||||||
@ -215,8 +219,10 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
|||||||
value = ini_lskip(value);
|
value = ini_lskip(value);
|
||||||
ini_rstrip(value);
|
ini_rstrip(value);
|
||||||
|
|
||||||
/* Valid name[=:]value pair found, call handler */
|
#if INI_ALLOW_MULTILINE
|
||||||
ini_strncpy0(prev_name, name, sizeof(prev_name));
|
ini_strncpy0(prev_name, name, sizeof(prev_name));
|
||||||
|
#endif
|
||||||
|
/* Valid name[=:]value pair found, call handler */
|
||||||
if (!HANDLER(user, section, name, value) && !error)
|
if (!HANDLER(user, section, name, value) && !error)
|
||||||
error = lineno;
|
error = lineno;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user