This commit is contained in:
LibretroAdmin 2022-09-18 19:25:37 +02:00
parent 127ad8868b
commit 0fb7c411a3
2 changed files with 22 additions and 6 deletions

View file

@ -728,10 +728,16 @@ bool socket_connect_with_timeout(int fd, void *data, int timeout)
return false;
}
/* Excluded platforms do not have getsockopt implemented [GEKKO],
* or it's returned values are unreliable [3DS].
*/
#if !defined(GEKKO) && !defined(_3DS) && defined(SO_ERROR)
#if defined(GEKKO)
/* libogc does not have getsockopt implemented */
res = connect(fd, addr->ai_addr, addr->ai_addrlen);
if (res < 0 && -res != EISCONN)
return false;
#elif defined(_3DS)
/* libctru getsockopt does not return expected value */
if (connect(fd, addr->ai_addr, addr->ai_addrlen) < 0 && errno != EISCONN)
return false;
#else
{
int error = -1;
socklen_t errsz = sizeof(error);

View file

@ -81,13 +81,23 @@ void label_sanitize(char *label, bool (*left)(char*), bool (*right)(char*))
if ((*left)(&label[lindex]))
copy = false;
else
new_label[rindex++] = label[lindex];
{
const bool whitespace = label[lindex] == ' ' && (rindex == 0 || new_label[rindex - 1] == ' ');
/* Simplify consecutive whitespaces */
if (!whitespace)
new_label[rindex++] = label[lindex];
}
}
else if ((*right)(&label[lindex]))
copy = true;
}
new_label[rindex] = '\0';
/* Trim trailing whitespace */
if (rindex > 0 && new_label[rindex - 1] == ' ')
new_label[rindex - 1] = '\0';
else
new_label[rindex] = '\0';
strlcpy(label, new_label, PATH_MAX_LENGTH);
}