Skip to content

Commit ee1fdd2

Browse files
authored
Add preprocessor exclusions when INI_ALLOW_MULTILINE=0 (#178)
Exclude the `prev_name` variable and the ini_strncpy0() call
1 parent cd5f939 commit ee1fdd2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ini.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
110110
size_t offset;
111111
#endif
112112
char section[MAX_SECTION] = "";
113+
#if INI_ALLOW_MULTILINE
113114
char prev_name[MAX_NAME] = "";
115+
#endif
114116

115117
char* start;
116118
char* end;
@@ -189,7 +191,9 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
189191
if (*end == ']') {
190192
*end = '\0';
191193
ini_strncpy0(section, start + 1, sizeof(section));
194+
#if INI_ALLOW_MULTILINE
192195
*prev_name = '\0';
196+
#endif
193197
#if INI_CALL_HANDLER_ON_NEW_SECTION
194198
if (!HANDLER(user, section, NULL, NULL) && !error)
195199
error = lineno;
@@ -215,8 +219,10 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
215219
value = ini_lskip(value);
216220
ini_rstrip(value);
217221

218-
/* Valid name[=:]value pair found, call handler */
222+
#if INI_ALLOW_MULTILINE
219223
ini_strncpy0(prev_name, name, sizeof(prev_name));
224+
#endif
225+
/* Valid name[=:]value pair found, call handler */
220226
if (!HANDLER(user, section, name, value) && !error)
221227
error = lineno;
222228
}

0 commit comments

Comments
 (0)