Skip to content

Commit

Permalink
Don't use string_trim_whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Dec 22, 2024
1 parent ca7e53e commit 99c7e08
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 17 deletions.
3 changes: 2 additions & 1 deletion libretro-common/formats/logiqx_dat/logiqx_dat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 10 additions & 5 deletions libretro-common/formats/m3u/m3u_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:' */
Expand All @@ -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);
}
}
}
Expand All @@ -190,22 +192,25 @@ 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 */
token_ptr++;
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
Expand Down
3 changes: 2 additions & 1 deletion manual_content_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions menu/drivers/rgui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions network/drivers_wifi/nmcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,17 @@ 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;

if (line[0] == '*')
{
entry.connected = true;
line[0] = ' ';
string_trim_whitespace(line);
line[0] = ' ';
string_trim_whitespace_right(line);
string_trim_whitespace_left(line);
}

strlcpy(entry.ssid, line, sizeof(entry.ssid));
Expand Down
3 changes: 2 additions & 1 deletion network/natt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:"))
{
Expand Down
9 changes: 6 additions & 3 deletions tasks/task_database_cue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 99c7e08

Please sign in to comment.