mirror of
https://github.com/libretro/libretro-common.git
synced 2024-05-11 17:15:29 -04:00
Resync
This commit is contained in:
parent
2add8dbbb4
commit
86b8dcf0ea
|
@ -254,7 +254,9 @@ static void logiqx_dat_sanitise_element_data(
|
|||
if (strstr(sanitised_data, find_string))
|
||||
{
|
||||
char *tmp = string_replace_substring(
|
||||
sanitised_data, find_string, replace_string);
|
||||
sanitised_data,
|
||||
find_string, strlen(find_string),
|
||||
replace_string, strlen(replace_string));
|
||||
|
||||
if (!string_is_empty(tmp))
|
||||
strlcpy(sanitised_data, tmp, sizeof(sanitised_data));
|
||||
|
|
|
@ -108,6 +108,17 @@ bool netstream_truncate(netstream_t *stream, size_t used);
|
|||
*/
|
||||
void netstream_data(netstream_t *stream, void **data, size_t *len);
|
||||
|
||||
/**
|
||||
* netstream_eof:
|
||||
*
|
||||
* @stream : Pointer to a network stream object.
|
||||
*
|
||||
* Checks whether the network stream is at EOF or not.
|
||||
*
|
||||
* Returns: true if the stream is at EOF, false otherwise.
|
||||
*/
|
||||
bool netstream_eof(netstream_t *stream);
|
||||
|
||||
/**
|
||||
* netstream_tell:
|
||||
*
|
||||
|
|
|
@ -159,8 +159,9 @@ char *string_to_lower(char *s);
|
|||
|
||||
char *string_ucwords(char *s);
|
||||
|
||||
char *string_replace_substring(const char *in, const char *pattern,
|
||||
const char *by);
|
||||
char *string_replace_substring(const char *in,
|
||||
const char *pattern, size_t pattern_len,
|
||||
const char *replacement, size_t replacement_len);
|
||||
|
||||
/**
|
||||
* string_trim_whitespace_left:
|
||||
|
@ -188,6 +189,7 @@ char *string_trim_whitespace(char *const s);
|
|||
* @dst : pointer to destination buffer.
|
||||
* @dst_size : size of destination buffer.
|
||||
* @src : pointer to input string.
|
||||
* @src_len : length of @src
|
||||
* @line_width : max number of characters per line.
|
||||
* @wideglyph_width : not used, but is necessary to keep
|
||||
* compatibility with word_wrap_wideglyph().
|
||||
|
@ -202,7 +204,7 @@ char *string_trim_whitespace(char *const s);
|
|||
* correctly any text containing so-called 'wide' Unicode
|
||||
* characters (e.g. CJK languages, emojis, etc.).
|
||||
**/
|
||||
void word_wrap(char *dst, size_t dst_size, const char *src,
|
||||
void word_wrap(char *dst, size_t dst_size, const char *src, size_t src_len,
|
||||
int line_width, int wideglyph_width, unsigned max_lines);
|
||||
|
||||
/**
|
||||
|
@ -210,6 +212,7 @@ void word_wrap(char *dst, size_t dst_size, const char *src,
|
|||
* @dst : pointer to destination buffer.
|
||||
* @dst_size : size of destination buffer.
|
||||
* @src : pointer to input string.
|
||||
* @src_len : length of @src
|
||||
* @line_width : max number of characters per line.
|
||||
* @wideglyph_width : effective width of 'wide' Unicode glyphs.
|
||||
* the value here is normalised relative to the
|
||||
|
@ -238,8 +241,11 @@ void word_wrap(char *dst, size_t dst_size, const char *src,
|
|||
* on-screen pixel width deviates greatly from the set
|
||||
* @wideglyph_width value.
|
||||
**/
|
||||
void word_wrap_wideglyph(char *dst, size_t dst_size, const char *src,
|
||||
int line_width, int wideglyph_width, unsigned max_lines);
|
||||
void word_wrap_wideglyph(
|
||||
char *dst, size_t dst_size,
|
||||
const char *src, size_t src_len,
|
||||
int line_width, int wideglyph_width,
|
||||
unsigned max_lines);
|
||||
|
||||
/**
|
||||
* string_tokenize:
|
||||
|
|
|
@ -344,9 +344,6 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
{
|
||||
const char *title_pos = NULL;
|
||||
const char *serial_pos = NULL;
|
||||
#if 0
|
||||
bool title_found = false;
|
||||
#endif
|
||||
|
||||
/* All discs currently in Redump for MCD start with SEGADISCSYSTEM. There are other strings mentioned elsewhere online,
|
||||
* but I have not seen any real examples of them. */
|
||||
|
@ -362,7 +359,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->title, sizeof(info->title));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->title, "N/A");
|
||||
{
|
||||
info->title[0] = 'N';
|
||||
info->title[1] = '/';
|
||||
info->title[2] = 'A';
|
||||
info->title[3] = '\0';
|
||||
}
|
||||
|
||||
serial_pos = buf + offset + 0x183;
|
||||
|
||||
|
@ -372,7 +374,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->serial, sizeof(info->serial));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->serial, "N/A");
|
||||
{
|
||||
info->serial[0] = 'N';
|
||||
info->serial[1] = '/';
|
||||
info->serial[2] = 'A';
|
||||
info->serial[3] = '\0';
|
||||
}
|
||||
}
|
||||
else if (!memcmp(buf + offset, "SEGA SEGASATURN",
|
||||
STRLEN_CONST("SEGA SEGASATURN")))
|
||||
|
@ -381,9 +388,6 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
const char *serial_pos = NULL;
|
||||
const char *version_pos = NULL;
|
||||
const char *release_date_pos = NULL;
|
||||
#if 0
|
||||
bool title_found = false;
|
||||
#endif
|
||||
|
||||
info->system_id = MEDIA_CD_SYSTEM_SATURN;
|
||||
|
||||
|
@ -397,7 +401,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->title, sizeof(info->title));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->title, "N/A");
|
||||
{
|
||||
info->title [0] = 'N';
|
||||
info->title [1] = '/';
|
||||
info->title [2] = 'A';
|
||||
info->title [3] = '\0';
|
||||
}
|
||||
|
||||
serial_pos = buf + offset + 0x20;
|
||||
|
||||
|
@ -407,7 +416,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->serial, sizeof(info->serial));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->serial, "N/A");
|
||||
{
|
||||
info->serial[0] = 'N';
|
||||
info->serial[1] = '/';
|
||||
info->serial[2] = 'A';
|
||||
info->serial[3] = '\0';
|
||||
}
|
||||
|
||||
version_pos = buf + offset + 0x2a;
|
||||
|
||||
|
@ -417,7 +431,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->version, sizeof(info->version));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->version, "N/A");
|
||||
{
|
||||
info->version[0] = 'N';
|
||||
info->version[1] = '/';
|
||||
info->version[2] = 'A';
|
||||
info->version[3] = '\0';
|
||||
}
|
||||
|
||||
release_date_pos = buf + offset + 0x30;
|
||||
|
||||
|
@ -427,7 +446,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->release_date, sizeof(info->release_date));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->release_date, "N/A");
|
||||
{
|
||||
info->release_date[0] = 'N';
|
||||
info->release_date[1] = '/';
|
||||
info->release_date[2] = 'A';
|
||||
info->release_date[3] = '\0';
|
||||
}
|
||||
}
|
||||
else if (!memcmp(buf + offset, "SEGA SEGAKATANA", STRLEN_CONST("SEGA SEGAKATANA")))
|
||||
{
|
||||
|
@ -435,9 +459,6 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
const char *serial_pos = NULL;
|
||||
const char *version_pos = NULL;
|
||||
const char *release_date_pos = NULL;
|
||||
#if 0
|
||||
bool title_found = false;
|
||||
#endif
|
||||
|
||||
info->system_id = MEDIA_CD_SYSTEM_DREAMCAST;
|
||||
|
||||
|
@ -451,7 +472,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->title, sizeof(info->title));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->title, "N/A");
|
||||
{
|
||||
info->title [0] = 'N';
|
||||
info->title [1] = '/';
|
||||
info->title [2] = 'A';
|
||||
info->title [3] = '\0';
|
||||
}
|
||||
|
||||
serial_pos = buf + offset + 0x40;
|
||||
|
||||
|
@ -461,7 +487,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->serial, sizeof(info->serial));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->serial, "N/A");
|
||||
{
|
||||
info->serial [0] = 'N';
|
||||
info->serial [1] = '/';
|
||||
info->serial [2] = 'A';
|
||||
info->serial [3] = '\0';
|
||||
}
|
||||
|
||||
version_pos = buf + offset + 0x4a;
|
||||
|
||||
|
@ -471,7 +502,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->version, sizeof(info->version));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->version, "N/A");
|
||||
{
|
||||
info->version [0] = 'N';
|
||||
info->version [1] = '/';
|
||||
info->version [2] = 'A';
|
||||
info->version [3] = '\0';
|
||||
}
|
||||
|
||||
release_date_pos = buf + offset + 0x50;
|
||||
|
||||
|
@ -481,15 +517,17 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->release_date, sizeof(info->release_date));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->release_date, "N/A");
|
||||
{
|
||||
info->release_date[0] = 'N';
|
||||
info->release_date[1] = '/';
|
||||
info->release_date[2] = 'A';
|
||||
info->release_date[3] = '\0';
|
||||
}
|
||||
}
|
||||
/* Primary Volume Descriptor fields of ISO9660 */
|
||||
else if (!memcmp(buf + offset + (16 * sector_size), "\1CD001\1\0PLAYSTATION", 19))
|
||||
{
|
||||
const char *title_pos = NULL;
|
||||
#if 0
|
||||
bool title_found = false;
|
||||
#endif
|
||||
|
||||
info->system_id = MEDIA_CD_SYSTEM_PSX;
|
||||
|
||||
|
@ -503,7 +541,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
|||
media_zero_trailing_spaces(info->title, sizeof(info->title));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->title, "N/A");
|
||||
{
|
||||
info->title [0] = 'N';
|
||||
info->title [1] = '/';
|
||||
info->title [2] = 'A';
|
||||
info->title [3] = '\0';
|
||||
}
|
||||
}
|
||||
else if (!memcmp(buf + offset, "\x01\x5a\x5a\x5a\x5a\x5a\x01\x00\x00\x00\x00\x00", 12))
|
||||
{
|
||||
|
|
|
@ -91,6 +91,13 @@ static void task_queue_msg_push(retro_task_t *task,
|
|||
|
||||
static void task_queue_push_progress(retro_task_t *task)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
/* msg_push callback interacts directly with the task properties (particularly title).
|
||||
* make sure another thread doesn't modify them while rendering
|
||||
*/
|
||||
slock_lock(property_lock);
|
||||
#endif
|
||||
|
||||
if (task->title && !task->mute)
|
||||
{
|
||||
if (task->finished)
|
||||
|
@ -113,6 +120,10 @@ static void task_queue_push_progress(retro_task_t *task)
|
|||
if (task->progress_cb)
|
||||
task->progress_cb(task);
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
slock_unlock(property_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void task_queue_put(task_queue_t *queue, retro_task_t *task)
|
||||
|
|
|
@ -89,6 +89,11 @@ void netstream_data(netstream_t *stream, void **data, size_t *len)
|
|||
*len = stream->used;
|
||||
}
|
||||
|
||||
bool netstream_eof(netstream_t *stream)
|
||||
{
|
||||
return stream->pos >= stream->used;
|
||||
}
|
||||
|
||||
size_t netstream_tell(netstream_t *stream)
|
||||
{
|
||||
return stream->pos;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <compat/strl.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <encodings/utf.h>
|
||||
|
||||
|
@ -89,9 +90,11 @@ char *string_ucwords(char *s)
|
|||
}
|
||||
|
||||
char *string_replace_substring(const char *in,
|
||||
const char *pattern, const char *replacement)
|
||||
const char *pattern, size_t pattern_len,
|
||||
const char *replacement, size_t replacement_len)
|
||||
{
|
||||
size_t numhits, pattern_len, replacement_len, outlen;
|
||||
size_t outlen;
|
||||
size_t numhits = 0;
|
||||
const char *inat = NULL;
|
||||
const char *inprev = NULL;
|
||||
char *out = NULL;
|
||||
|
@ -102,9 +105,6 @@ char *string_replace_substring(const char *in,
|
|||
if (!pattern || !replacement)
|
||||
return strdup(in);
|
||||
|
||||
pattern_len = strlen(pattern);
|
||||
replacement_len = strlen(replacement);
|
||||
numhits = 0;
|
||||
inat = in;
|
||||
|
||||
while ((inat = strstr(inat, pattern)))
|
||||
|
@ -128,7 +128,7 @@ char *string_replace_substring(const char *in,
|
|||
outat += inat-inprev;
|
||||
memcpy(outat, replacement, replacement_len);
|
||||
outat += replacement_len;
|
||||
inat += pattern_len;
|
||||
inat += pattern_len;
|
||||
inprev = inat;
|
||||
}
|
||||
strcpy(outat, inprev);
|
||||
|
@ -217,13 +217,14 @@ char *string_trim_whitespace(char *const s)
|
|||
* correctly any text containing so-called 'wide' Unicode
|
||||
* characters (e.g. CJK languages, emojis, etc.).
|
||||
**/
|
||||
void word_wrap(char *dst, size_t dst_size, const char *src,
|
||||
int line_width, int wideglyph_width, unsigned max_lines)
|
||||
void word_wrap(
|
||||
char *dst, size_t dst_size,
|
||||
const char *src, size_t src_len,
|
||||
int line_width, int wideglyph_width, unsigned max_lines)
|
||||
{
|
||||
char *lastspace = NULL;
|
||||
unsigned counter = 0;
|
||||
unsigned lines = 1;
|
||||
size_t src_len = strlen(src);
|
||||
const char *src_end = src + src_len;
|
||||
|
||||
/* Prevent buffer overflow */
|
||||
|
@ -234,7 +235,7 @@ void word_wrap(char *dst, size_t dst_size, const char *src,
|
|||
* than line width */
|
||||
if (src_len < line_width)
|
||||
{
|
||||
strcpy(dst, src);
|
||||
strlcpy(dst, src, dst_size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -256,7 +257,7 @@ void word_wrap(char *dst, size_t dst_size, const char *src,
|
|||
* length is less than line width */
|
||||
if (src_end - src <= line_width)
|
||||
{
|
||||
strcpy(dst, src);
|
||||
strlcpy(dst, src, dst_size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +284,7 @@ void word_wrap(char *dst, size_t dst_size, const char *src,
|
|||
* length is less than line width */
|
||||
if (src_end - src < line_width)
|
||||
{
|
||||
strcpy(dst, src);
|
||||
strlcpy(dst, src, dst_size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -327,12 +328,12 @@ void word_wrap(char *dst, size_t dst_size, const char *src,
|
|||
* @wideglyph_width value.
|
||||
**/
|
||||
void word_wrap_wideglyph(char *dst, size_t dst_size,
|
||||
const char *src, int line_width,
|
||||
const char *src, size_t src_len, int line_width,
|
||||
int wideglyph_width, unsigned max_lines)
|
||||
{
|
||||
char *lastspace = NULL;
|
||||
char *lastwideglyph = NULL;
|
||||
const char *src_end = src + strlen(src);
|
||||
const char *src_end = src + src_len;
|
||||
unsigned lines = 1;
|
||||
/* 'line_width' means max numbers of characters per line,
|
||||
* but this metric is only meaningful when dealing with
|
||||
|
|
|
@ -196,7 +196,7 @@ START_TEST (test_word_wrap)
|
|||
|
||||
char output[1024];
|
||||
|
||||
word_wrap(output, sizeof(output), testtxt, 40, 100, 10);
|
||||
word_wrap(output, sizeof(output), testtxt, strlen(testtxt), 40, 100, 10);
|
||||
ck_assert(!strcmp(output, expected));
|
||||
}
|
||||
END_TEST
|
||||
|
|
Loading…
Reference in a new issue