util: Replace use of strcasecmp in boolstr_or_default

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2026-08-04 10:47:56 +02:00
parent 44a4d1e6cd
commit 049f38659a
1 changed files with 6 additions and 4 deletions

View File

@ -20,9 +20,11 @@
#ifndef UTIL_H #ifndef UTIL_H
#define UTIL_H #define UTIL_H
#include <boost/algorithm/string/predicate.hpp>
#include <map> #include <map>
#include <set> #include <set>
#include <string> #include <string>
#include "nextpnr.h" #include "nextpnr.h"
#include "log.h" #include "log.h"
@ -112,13 +114,13 @@ bool boolstr_or_default(const dict<KeyType, Property> &ct, const KeyType &key, b
return def; return def;
if (!found->second.is_string) if (!found->second.is_string)
bool(found->second.as_int64()); bool(found->second.as_int64());
const char *str = found->second.as_string().c_str(); auto str = found->second.as_string();
if (!strcmp(str, "0") || !strcasecmp(str, "false")) if (str == "0" || boost::iequals(str, "false"))
return false; return false;
else if (!strcmp(str, "1") || !strcasecmp(str, "true")) if (str == "1" || boost::iequals(str, "true"))
return true; return true;
else else
log_error("Expecting bool-compatible value but got '%s'.\n", found->second.as_string().c_str()); log_error("Expecting bool-compatible value but got '%s'.\n", str.c_str());
return false; return false;
}; };