Skip to content

Commit 80d7a25

Browse files
committed
Resync
1 parent bf52f8b commit 80d7a25

7 files changed

Lines changed: 45 additions & 41 deletions

File tree

file/file_path.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,8 @@ const char *path_basename(const char *path)
672672
const char *slash = strrchr(path, '/');
673673
const char *backslash = strrchr(path, '\\');
674674
char *last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash;
675-
if ( (ptr = path_get_archive_delim(path))
676-
|| (ptr = last_slash))
677-
return ptr + 1;
678-
return path;
675+
return ((ptr = path_get_archive_delim(path)) || (ptr = last_slash))
676+
? (ptr + 1) : path;
679677
}
680678

681679
/* Specialized version */

formats/logiqx_dat/logiqx_dat.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ struct logiqx_dat
3535

3636
/* List of HTML formatting codes that must
3737
* be replaced when parsing XML data */
38-
const char *logiqx_dat_html_code_list[][2] = {
38+
const char *logiqx_dat_html_code_list[][2] = {
3939
{"&", "&"},
4040
{"'", "'"},
41-
{">", ">"},
41+
{">", ">"},
4242
{"&lt;", "<"},
43-
{"&quot;", "\""}
43+
{"&quot;", "\""}
4444
};
4545

4646
#define LOGIQX_DAT_HTML_CODE_LIST_SIZE 5
@@ -53,7 +53,7 @@ const char *logiqx_dat_html_code_list[][2] = {
5353
* Also provides access to file size (DAT files can
5454
* be very large, so it is useful to have this information
5555
* on hand - i.e. so we can check that the system has
56-
* enough free memory to load the file). */
56+
* enough free memory to load the file). */
5757
bool logiqx_dat_path_is_valid(const char *path, uint64_t *file_size)
5858
{
5959
const char *file_ext = NULL;
@@ -229,7 +229,8 @@ static void logiqx_dat_sanitise_element_data(
229229

230230
/* Element data includes leading/trailing
231231
* newline characters - trim them away */
232-
string_trim_whitespace(sanitised_data);
232+
string_trim_whitespace_right(sanitised_data);
233+
string_trim_whitespace_left(sanitised_data);
233234

234235
if (string_is_empty(sanitised_data))
235236
return;
@@ -254,7 +255,7 @@ static void logiqx_dat_sanitise_element_data(
254255
if (strstr(sanitised_data, find_string))
255256
{
256257
char *tmp = string_replace_substring(
257-
sanitised_data,
258+
sanitised_data, strlen(sanitised_data),
258259
find_string, strlen(find_string),
259260
replace_string, strlen(replace_string));
260261

formats/m3u/m3u_file.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ static bool m3u_file_load(m3u_file_t *m3u_file)
145145
strlcpy(
146146
entry_label, line + STRLEN_CONST(M3U_FILE_NONSTD_LABEL),
147147
sizeof(entry_label));
148-
string_trim_whitespace(entry_label);
148+
string_trim_whitespace_right(entry_label);
149+
string_trim_whitespace_left(entry_label);
149150
}
150151
}
151152
/* > '#EXTINF:' */
@@ -164,7 +165,8 @@ static bool m3u_file_load(m3u_file_t *m3u_file)
164165
if (!string_is_empty(label_ptr))
165166
{
166167
strlcpy(entry_label, label_ptr, sizeof(entry_label));
167-
string_trim_whitespace(entry_label);
168+
string_trim_whitespace_right(entry_label);
169+
string_trim_whitespace_left(entry_label);
168170
}
169171
}
170172
}
@@ -190,22 +192,25 @@ static bool m3u_file_load(m3u_file_t *m3u_file)
190192
entry_path, line,
191193
((len < PATH_MAX_LENGTH ?
192194
len : PATH_MAX_LENGTH) * sizeof(char)));
193-
string_trim_whitespace(entry_path);
195+
string_trim_whitespace_right(entry_path);
196+
string_trim_whitespace_left(entry_path);
194197
}
195198

196199
/* Get entry_label segment */
197200
token_ptr++;
198201
if (*token_ptr != '\0')
199202
{
200203
strlcpy(entry_label, token_ptr, sizeof(entry_label));
201-
string_trim_whitespace(entry_label);
204+
string_trim_whitespace_right(entry_label);
205+
string_trim_whitespace_left(entry_label);
202206
}
203207
}
204208
else
205209
{
206210
/* Just a normal file name/path */
207211
strlcpy(entry_path, line, sizeof(entry_path));
208-
string_trim_whitespace(entry_path);
212+
string_trim_whitespace_right(entry_path);
213+
string_trim_whitespace_left(entry_path);
209214
}
210215

211216
/* Add entry to file

include/file/file_path.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ char *path_remove_extension(char *path);
167167
*
168168
* Hidden non-leaf function cost:
169169
* - Calls path_get_archive_delim()
170-
* - can call find_last_slash() once if it returns NULL
171170
*
172171
* @return basename from path.
173172
**/
@@ -180,9 +179,6 @@ const char *path_basename(const char *path);
180179
* Specialized version of path_basename().
181180
* Get basename from @path.
182181
*
183-
* Hidden non-leaf function cost:
184-
* - Calls find_last_slash()
185-
*
186182
* @return basename from path.
187183
**/
188184
const char *path_basename_nocompression(const char *path);
@@ -417,7 +413,6 @@ void fill_pathname_basedir(char *out_path, const char *in_path, size_t size);
417413
*
418414
* Hidden non-leaf function cost:
419415
* - Calls strdup
420-
* - Calls find_last_slash() x times
421416
* - Can call strlcpy
422417
*
423418
* @return Length of the string copied into @s
@@ -499,7 +494,6 @@ size_t fill_pathname_join(char *out_path, const char *dir,
499494
*
500495
* Hidden non-leaf function cost:
501496
* - calls strlcpy 2x
502-
* - calls find_last_slash()
503497
*
504498
* @return Length of the string copied into @out_path
505499
**/
@@ -635,8 +629,7 @@ void path_basedir_wrapper(char *path);
635629
* if not already there.
636630
637631
* Hidden non-leaf function cost:
638-
* - calls find_last_slash()
639-
* - can call strlcat once if it returns false
632+
* - can call strlcat once if it returns false
640633
* - calls strlen
641634
**/
642635
size_t fill_pathname_slash(char *path, size_t size);

include/libretro.h

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* @file libretro.h
55
* @version 1
66
* @author libretro
7-
* @copyright Copyright (C) 2010-2023 The RetroArch team
7+
* @copyright Copyright (C) 2010-2024 The RetroArch team
88
*
99
* @paragraph LICENSE
1010
* The following license statement only applies to this libretro API header (libretro.h).
1111
*
12-
* Copyright (C) 2010-2023 The RetroArch team
12+
* Copyright (C) 2010-2024 The RetroArch team
1313
*
1414
* Permission is hereby granted, free of charge,
1515
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
@@ -272,7 +272,10 @@ extern "C" {
272272
* [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen,
273273
* and 0x7fff corresponds to the far right/bottom of the screen.
274274
* The "screen" is here defined as area that is passed to the frontend and
275-
* later displayed on the monitor.
275+
* later displayed on the monitor. If the pointer is outside this screen,
276+
* such as in the black surrounding areas when actual display is larger,
277+
* edge position is reported. An explicit edge detection is also provided,
278+
* that will return 1 if the pointer is near the screen edge or actually outside it.
276279
*
277280
* The frontend is free to scale/resize this screen as it sees fit, however,
278281
* (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the
@@ -406,7 +409,8 @@ extern "C" {
406409

407410
/* Id values for LIGHTGUN. */
408411
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X 13 /*Absolute Position*/
409-
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute*/
412+
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute Position*/
413+
/** Indicates if lightgun points off the screen or near the edge */
410414
#define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15 /*Status Check*/
411415
#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2
412416
#define RETRO_DEVICE_ID_LIGHTGUN_RELOAD 16 /*Forced off-screen shot*/
@@ -421,17 +425,18 @@ extern "C" {
421425
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT 12
422426
/* deprecated */
423427
#define RETRO_DEVICE_ID_LIGHTGUN_X 0 /*Relative Position*/
424-
#define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative*/
425-
#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A*/
426-
#define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B*/
427-
#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start*/
428+
#define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative Position*/
429+
#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A instead*/
430+
#define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B instead*/
431+
#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start instead*/
428432

429433
/* Id values for POINTER. */
430-
#define RETRO_DEVICE_ID_POINTER_X 0
431-
#define RETRO_DEVICE_ID_POINTER_Y 1
432-
#define RETRO_DEVICE_ID_POINTER_PRESSED 2
433-
#define RETRO_DEVICE_ID_POINTER_COUNT 3
434-
434+
#define RETRO_DEVICE_ID_POINTER_X 0
435+
#define RETRO_DEVICE_ID_POINTER_Y 1
436+
#define RETRO_DEVICE_ID_POINTER_PRESSED 2
437+
#define RETRO_DEVICE_ID_POINTER_COUNT 3
438+
/** Indicates if pointer is off the screen or near the edge */
439+
#define RETRO_DEVICE_ID_POINTER_IS_OFFSCREEN 15
435440
/** @} */
436441

437442
/* Returned from retro_get_region(). */

include/string/stdstring.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ char *string_to_lower(char *s);
159159

160160
char *string_ucwords(char *s);
161161

162-
char *string_replace_substring(const char *in,
163-
const char *pattern, size_t pattern_len,
162+
char *string_replace_substring(
163+
const char *in, size_t in_len,
164+
const char *pattern, size_t pattern_len,
164165
const char *replacement, size_t replacement_len);
165166

166167
/**

string/stdstring.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ char *string_ucwords(char *s)
7777
return s;
7878
}
7979

80-
char *string_replace_substring(const char *in,
81-
const char *pattern, size_t pattern_len,
80+
char *string_replace_substring(
81+
const char *in, size_t in_len,
82+
const char *pattern, size_t pattern_len,
8283
const char *replacement, size_t replacement_len)
8384
{
8485
size_t outlen;
@@ -101,7 +102,7 @@ char *string_replace_substring(const char *in,
101102
numhits++;
102103
}
103104

104-
outlen = strlen(in) - pattern_len*numhits + replacement_len*numhits;
105+
outlen = in_len - pattern_len * numhits + replacement_len*numhits;
105106

106107
if (!(out = (char *)malloc(outlen+1)))
107108
return NULL;

0 commit comments

Comments
 (0)