From 2e79881af2279eb241c32b44feea17cf7455408d Mon Sep 17 00:00:00 2001 From: Dirk Vanden Boer Date: Wed, 21 Aug 2024 17:50:54 +0200 Subject: [PATCH] Fix gcc warning --- inireader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inireader.cpp b/inireader.cpp index d4043dfd..f576ca4d 100644 --- a/inireader.cpp +++ b/inireader.cpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace inf { @@ -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; @@ -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; @@ -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) {