pw: fix const qualification in unquote()

The unquote() function took a const char * parameter but modified the
string in-place (removing quote characters). Change the parameter to
char * and update callers that passed const char * to cast explicitly.
This commit is contained in:
Baptiste Daroussin
2026-06-05 00:13:23 +02:00
parent 4fd8a69ec6
commit 5f9c8f142d
+6 -6
View File
@@ -156,22 +156,22 @@ static char const *kwds[] =
};
static char *
unquote(char const * str)
unquote(char * str)
{
if (str && (*str == '"' || *str == '\'')) {
char *p = strchr(str + 1, *str);
if (p != NULL)
*p = '\0';
return (char *) (*++str ? str : NULL);
return (*++str ? str : NULL);
}
return (char *) str;
return (str);
}
int
boolean_val(char const * str, int dflt)
{
if ((str = unquote(str)) != NULL) {
if ((str = unquote((char *)str)) != NULL) {
int i;
for (i = 0; booltrue[i]; i++)
@@ -187,7 +187,7 @@ boolean_val(char const * str, int dflt)
int
passwd_val(char const * str, int dflt)
{
if ((str = unquote(str)) != NULL) {
if ((str = unquote((char *)str)) != NULL) {
int i;
for (i = 0; booltrue[i]; i++)
@@ -228,7 +228,7 @@ newstr(char const * p)
{
char *q;
if ((p = unquote(p)) == NULL)
if ((p = unquote((char *)p)) == NULL)
return (NULL);
if ((q = strdup(p)) == NULL)