Skip to content

Commit

Permalink
Fix gcc warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkvdb committed Aug 21, 2024
1 parent bef87a2 commit 2e79881
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions inireader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>

namespace inf {

Expand Down Expand Up @@ -114,7 +115,7 @@ inline int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler
char* line;
#endif
char section[MAX_SECTION] = "";
char prev_name[MAX_NAME] = "";
std::string prev_name;

char* start;
char* end;
Expand Down Expand Up @@ -153,7 +154,7 @@ inline int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler
if (*end == ']') {
*end = '\0';
strncpy0(section, start + 1, sizeof(section) - 1);
*prev_name = '\0';
prev_name.clear();
} else if (!error) {
/* No ']' found on section line */
error = lineno;
Expand All @@ -173,7 +174,7 @@ inline int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler
rstrip(value);

/* Valid name[=:]value pair found, call handler */
strncpy0(prev_name, name, sizeof(prev_name) - 1);
prev_name = name;
if (!handler(user, section, name, value) && !error)
error = lineno;
} else if (!error) {
Expand Down

0 comments on commit 2e79881

Please sign in to comment.