Don't use string_trim_whitespace

This commit is contained in:
libretroadmin 2024-12-23 00:51:01 +01:00
parent ca7e53e3ca
commit 99c7e08445
7 changed files with 31 additions and 17 deletions

View File

@ -229,7 +229,8 @@ static void logiqx_dat_sanitise_element_data(
/* Element data includes leading/trailing
* newline characters - trim them away */
string_trim_whitespace(sanitised_data);
string_trim_whitespace_right(sanitised_data);
string_trim_whitespace_left(sanitised_data);
if (string_is_empty(sanitised_data))
return;

View File

@ -145,7 +145,8 @@ static bool m3u_file_load(m3u_file_t *m3u_file)
strlcpy(
entry_label, line + STRLEN_CONST(M3U_FILE_NONSTD_LABEL),
sizeof(entry_label));
string_trim_whitespace(entry_label);
string_trim_whitespace_right(entry_label);
string_trim_whitespace_left(entry_label);
}
}
/* > '#EXTINF:' */
@ -164,7 +165,8 @@ static bool m3u_file_load(m3u_file_t *m3u_file)
if (!string_is_empty(label_ptr))
{
strlcpy(entry_label, label_ptr, sizeof(entry_label));
string_trim_whitespace(entry_label);
string_trim_whitespace_right(entry_label);
string_trim_whitespace_left(entry_label);
}
}
}
@ -190,7 +192,8 @@ static bool m3u_file_load(m3u_file_t *m3u_file)
entry_path, line,
((len < PATH_MAX_LENGTH ?
len : PATH_MAX_LENGTH) * sizeof(char)));
string_trim_whitespace(entry_path);
string_trim_whitespace_right(entry_path);
string_trim_whitespace_left(entry_path);
}
/* Get entry_label segment */
@ -198,14 +201,16 @@ static bool m3u_file_load(m3u_file_t *m3u_file)
if (*token_ptr != '\0')
{
strlcpy(entry_label, token_ptr, sizeof(entry_label));
string_trim_whitespace(entry_label);
string_trim_whitespace_right(entry_label);
string_trim_whitespace_left(entry_label);
}
}
else
{
/* Just a normal file name/path */
strlcpy(entry_path, line, sizeof(entry_path));
string_trim_whitespace(entry_path);
string_trim_whitespace_right(entry_path);
string_trim_whitespace_left(entry_path);
}
/* Add entry to file

View File

@ -191,7 +191,8 @@ static void manual_content_scan_scrub_file_exts(char *file_exts)
string_remove_all_chars(file_exts, '.');
string_to_lower(file_exts);
string_trim_whitespace(file_exts);
string_trim_whitespace_right(file_exts);
string_trim_whitespace_left(file_exts);
}
/* Removes invalid characters from

View File

@ -7176,12 +7176,13 @@ static void rgui_update_menu_sublabel(rgui_t *rgui, size_t selection)
while (tok)
{
const char *line = string_trim_whitespace(tok);
if (!string_is_empty(line))
string_trim_whitespace_right(tok);
string_trim_whitespace_left(tok);
if (!string_is_empty(tok))
{
if (!prev_line_empty)
strlcat(rgui->menu_sublabel, sublabel_spacer, sizeof(rgui->menu_sublabel));
strlcat(rgui->menu_sublabel, line, sizeof(rgui->menu_sublabel));
strlcat(rgui->menu_sublabel, tok, sizeof(rgui->menu_sublabel));
prev_line_empty = false;
}
tok = strtok_r(NULL, "\n", &save);

View File

@ -110,7 +110,8 @@ static void nmcli_scan(void *data)
wifi_network_info_t entry;
memset(&entry, 0, sizeof(entry));
string_trim_whitespace(line);
string_trim_whitespace_right(line);
string_trim_whitespace_left(line);
if (!line || line[0] == '\0')
continue;
@ -118,7 +119,8 @@ static void nmcli_scan(void *data)
{
entry.connected = true;
line[0] = ' ';
string_trim_whitespace(line);
string_trim_whitespace_right(line);
string_trim_whitespace_left(line);
}
strlcpy(entry.ssid, line, sizeof(entry.ssid));

View File

@ -184,7 +184,8 @@ bool natt_device_next(struct natt_discovery *discovery,
*lnbreak++ = '\0';
/* This also gets rid of any trailing carriage return. */
string_trim_whitespace(data);
string_trim_whitespace_right(data);
string_trim_whitespace_left(data);
if (string_starts_with_case_insensitive(data, "Location:"))
{

View File

@ -697,7 +697,8 @@ int detect_scd_game(intfstream_t *fd, char *s, size_t len, const char *filename)
}
else
{
string_trim_whitespace(raw_game_id);
string_trim_whitespace_right(raw_game_id);
string_trim_whitespace_left(raw_game_id);
strlcpy(s, raw_game_id, len);
return true;
}
@ -742,7 +743,8 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename)
return false;
}
string_trim_whitespace(raw_game_id);
string_trim_whitespace_right(raw_game_id);
string_trim_whitespace_left(raw_game_id);
/** Dissect this raw serial into parts **/
length = strlen(raw_game_id);
@ -832,7 +834,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
return false;
}
string_trim_whitespace(raw_game_id);
string_trim_whitespace_right(raw_game_id);
string_trim_whitespace_left(raw_game_id);
string_replace_multi_space_with_single_space(raw_game_id);
string_replace_whitespace_with_single_character(raw_game_id, '-');
length = strlen(raw_game_id);