This commit is contained in:
twinaphex 2017-04-21 14:39:25 +02:00
parent adb2fb177f
commit 94184c262d
12 changed files with 73 additions and 51 deletions

View file

@ -26,6 +26,7 @@
#include <retro_miscellaneous.h>
#include <libretro_dspfilter.h>
#include <string/stdstring.h>
#define sqr(a) ((a) * (a))
@ -123,7 +124,7 @@ static void iir_process(void *data, struct dspfilter_output *output,
iir->r.yn2 = yn2_r;
}
#define CHECK(x) if (!strcmp(str, #x)) return x
#define CHECK(x) if (string_is_equal(str, #x)) return x
static enum IIRFilter str_to_type(const char *str)
{
CHECK(LPF);

View file

@ -579,7 +579,7 @@ static struct config_entry_list *config_get_entry(const config_file_t *conf,
for (entry = conf->entries; entry; entry = entry->next)
{
if (hash == entry->key_hash && !strcmp(key, entry->key))
if (hash == entry->key_hash && string_is_equal(key, entry->key))
return entry;
previous = entry;
@ -745,13 +745,13 @@ bool config_get_bool(config_file_t *conf, const char *key, bool *in)
if (entry)
{
if (strcasecmp(entry->value, "true") == 0)
if (string_is_equal(entry->value, "true"))
*in = true;
else if (strcasecmp(entry->value, "1") == 0)
else if (string_is_equal(entry->value, "1"))
*in = true;
else if (strcasecmp(entry->value, "false") == 0)
else if (string_is_equal(entry->value, "false"))
*in = false;
else if (strcasecmp(entry->value, "0") == 0)
else if (string_is_equal(entry->value, "0"))
*in = false;
else
return false;
@ -931,7 +931,7 @@ bool config_entry_exists(config_file_t *conf, const char *entry)
while (list)
{
if (!strcmp(entry, list->key))
if (string_is_equal(entry, list->key))
return true;
list = list->next;
}

View file

@ -59,7 +59,7 @@ bool path_mkdir(const char *dir)
return false;
path_parent_dir(basedir);
if (!*basedir || !strcmp(basedir, dir))
if (!*basedir || string_is_equal(basedir, dir))
goto end;
if (path_is_directory(basedir))

View file

@ -31,6 +31,7 @@
#include <boolean.h>
#include <streams/file_stream.h>
#include <compat/posix_string.h>
#include <string/stdstring.h>
#include <formats/rxml.h>
@ -483,7 +484,7 @@ char *rxml_node_attrib(struct rxml_node *node, const char *attrib)
struct rxml_attrib_node *attribs = NULL;
for (attribs = node->attrib; attribs; attribs = attribs->next)
{
if (!strcmp(attrib, attribs->attrib))
if (string_is_equal(attrib, attribs->attrib))
return attribs->value;
}

View file

@ -25,18 +25,53 @@
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
#include <string.h>
#include <boolean.h>
#include <retro_common_api.h>
#include <retro_inline.h>
RETRO_BEGIN_DECLS
bool string_is_empty(const char *data);
static INLINE bool string_is_empty(const char *data)
{
return (data == NULL) || (*data == '\0');
}
bool string_is_equal(const char *a, const char *b);
static INLINE bool string_is_equal(const char *a, const char *b)
{
if (!a || !b)
return false;
while(*a && (*a == *b))
a++, b++;
return (*(const unsigned char*)a - *(const unsigned char*)b) == 0;
}
bool string_is_equal_noncase(const char *a, const char *b);
static INLINE bool string_is_equal_noncase(const char *a, const char *b)
{
bool ret;
int i;
char *cp1, *cp2;
if (!a || !b)
return false;
cp1 = (char*)malloc(strlen(a) + 1);
cp2 = (char*)malloc(strlen(b) + 1);
for (i = 0; i < strlen(a) + 1; i++)
cp1[i] = tolower((int) (unsigned char) a[i]);
for (i = 0; i < strlen(b) + 1; i++)
cp2[i] = tolower((int) (unsigned char) b[i]);
ret = string_is_equal(cp1, cp2);
free(cp1);
free(cp2);
return ret;
}
char *string_to_upper(char *s);

View file

@ -35,6 +35,7 @@
#include <compat/strl.h>
#include <retro_dirent.h>
#include <string/stdstring.h>
#include <retro_miscellaneous.h>
static int qstrcmp_plain(const void *a_, const void *b_)
@ -123,7 +124,7 @@ static int parse_dir_entry(const char *name, char *file_path,
if (!include_dirs && is_dir)
return 1;
if (!strcmp(name, ".") || !strcmp(name, ".."))
if (string_is_equal(name, ".") || string_is_equal(name, ".."))
return 1;
if (!is_dir && ext_list &&

View file

@ -27,6 +27,7 @@
#include <retro_assert.h>
#include <retro_common.h>
#include <lists/file_list.h>
#include <string/stdstring.h>
#include <compat/strcasestr.h>
/**

View file

@ -28,6 +28,7 @@
#include <retro_assert.h>
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <string/stdstring.h>
/**
* string_list_free
@ -268,7 +269,7 @@ int string_list_find_elem(const struct string_list *list, const char *elem)
for (i = 0; i < list->size; i++)
{
if (strcasecmp(list->elems[i].data, elem) == 0)
if (string_is_equal_noncase(list->elems[i].data, elem))
return (int)(i + 1);
}
@ -302,8 +303,8 @@ bool string_list_find_elem_prefix(const struct string_list *list,
for (i = 0; i < list->size; i++)
{
if (strcasecmp(list->elems[i].data, elem) == 0 ||
strcasecmp(list->elems[i].data, prefixed) == 0)
if (string_is_equal_noncase(list->elems[i].data, elem) ||
string_is_equal_noncase(list->elems[i].data, prefixed) == 0)
return true;
}

View file

@ -29,6 +29,7 @@
#include <net/net_ifinfo.h>
#include <retro_miscellaneous.h>
#include <string/stdstring.h>
#include <net/net_natt.h>
#if HAVE_MINIUPNPC
@ -189,7 +190,7 @@ bool natt_open_port_any(struct natt_status *status, uint16_t port, enum socket_p
struct net_ifinfo_entry *entry = list.entries + i;
/* ignore localhost */
if (!strcmp(entry->host, "127.0.0.1") || !strcmp(entry->host, "::1"))
if (string_is_equal(entry->host, "127.0.0.1") || string_is_equal(entry->host, "::1"))
continue;
/* make a request for this host */

View file

@ -24,6 +24,7 @@
#include <string.h>
#include <compat/zlib.h>
#include <string/stdstring.h>
#include <streams/trans_stream.h>
struct zlib_trans_stream
@ -70,7 +71,7 @@ static void zlib_inflate_stream_free(void *data)
static bool zlib_deflate_define(void *data, const char *prop, uint32_t val)
{
struct zlib_trans_stream *z = (struct zlib_trans_stream *) data;
if (!strcmp(prop, "level"))
if (string_is_equal(prop, "level"))
{
z->ex = (int) val;
return true;
@ -81,7 +82,7 @@ static bool zlib_deflate_define(void *data, const char *prop, uint32_t val)
static bool zlib_inflate_define(void *data, const char *prop, uint32_t val)
{
struct zlib_trans_stream *z = (struct zlib_trans_stream *) data;
if (!strcmp(prop, "window_bits"))
if (string_is_equal(prop, "window_bits"))
{
z->ex = (int) val;
return true;

View file

@ -25,25 +25,6 @@
#include <string/stdstring.h>
bool string_is_empty(const char *data)
{
return (data == NULL) || (*data == '\0');
}
bool string_is_equal(const char *a, const char *b)
{
if (!a || !b)
return false;
return (strcmp(a, b) == 0);
}
bool string_is_equal_noncase(const char *a, const char *b)
{
if (!a || !b)
return false;
return (strcasecmp(a, b) == 0);
}
char *string_to_upper(char *s)
{
char *cs = (char *)s;
@ -62,17 +43,15 @@ char *string_to_lower(char *s)
char *string_ucwords(char *s)
{
char *cs = (char *)s;
for ( ; *cs != '\0'; cs++)
{
if (*cs == ' ')
{
*(cs+1) = toupper(*(cs+1));
}
}
char *cs = (char *)s;
for ( ; *cs != '\0'; cs++)
{
if (*cs == ' ')
*(cs+1) = toupper(*(cs+1));
}
s[0] = toupper(s[0]);
return s;
s[0] = toupper(s[0]);
return s;
}
char *string_replace_substring(const char *in,

View file

@ -437,6 +437,7 @@ void SHA1PadMessage(SHA1Context *context)
#include <io.h>
#endif
#include <fcntl.h>
#include <string/stdstring.h>
/*#include "sha1.h"*/
/*
@ -477,8 +478,8 @@ int main(int argc, char *argv[])
* Check the program arguments and print usage information if -?
* or --help is passed as the first argument.
*/
if (argc > 1 && (!strcmp(argv[1],"-?") ||
!strcmp(argv[1],"--help")))
if (argc > 1 && (string_is_equal(argv[1],"-?") ||
string_is_equal(argv[1],"--help")))
{
usage();
return 1;
@ -498,7 +499,7 @@ int main(int argc, char *argv[])
if (i == 0)
i++;
if (argc == 1 || !strcmp(argv[i],"-"))
if (argc == 1 || string_is_equal(argv[i],"-"))
{
#ifdef WIN32
setmode(fileno(stdin), _O_BINARY);