Use string_is_equal/stdstring.h

This commit is contained in:
twinaphex 2016-09-16 17:33:18 +02:00
parent f395e851c4
commit 99aae8537b
5 changed files with 29 additions and 23 deletions

View File

@ -19,10 +19,11 @@
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include <retro_miscellaneous.h>
#include <file/file_path.h> #include <file/file_path.h>
#include <streams/file_stream.h> #include <streams/file_stream.h>
#include <lists/string_list.h> #include <lists/string_list.h>
#include <retro_miscellaneous.h> #include <string/stdstring.h>
#include "glslang_util.hpp" #include "glslang_util.hpp"
#include "glslang.hpp" #include "glslang.hpp"
@ -227,7 +228,7 @@ const char *glslang_format_to_string(enum glslang_format fmt)
static glslang_format glslang_find_format(const char *fmt) static glslang_format glslang_find_format(const char *fmt)
{ {
#undef FMT #undef FMT
#define FMT(x) if (!strcmp(fmt, #x)) return SLANG_FORMAT_ ## x #define FMT(x) if (string_is_equal(fmt, #x)) return SLANG_FORMAT_ ## x
FMT(R8_UNORM); FMT(R8_UNORM);
FMT(R8_UINT); FMT(R8_UINT);
FMT(R8_SINT); FMT(R8_SINT);
@ -309,7 +310,7 @@ static bool glslang_parse_meta(const vector<string> &lines, glslang_meta *meta)
* if they are exactly the same. */ * if they are exactly the same. */
if (itr != end(meta->parameters)) if (itr != end(meta->parameters))
{ {
if (itr->desc != desc || if ( itr->desc != desc ||
itr->initial != initial || itr->initial != initial ||
itr->minimum != minimum || itr->minimum != minimum ||
itr->maximum != maximum || itr->maximum != maximum ||

View File

@ -44,7 +44,7 @@ static const uint32_t opaque_frag[] =
static unsigned num_miplevels(unsigned width, unsigned height) static unsigned num_miplevels(unsigned width, unsigned height)
{ {
unsigned size = std::max(width, height); unsigned size = std::max(width, height);
unsigned levels = 0; unsigned levels = 0;
while (size) while (size)
{ {
@ -60,7 +60,7 @@ static void image_layout_transition_levels(
VkAccessFlags src_access, VkAccessFlags dst_access, VkAccessFlags src_access, VkAccessFlags dst_access,
VkPipelineStageFlags src_stages, VkPipelineStageFlags dst_stages) VkPipelineStageFlags src_stages, VkPipelineStageFlags dst_stages)
{ {
VkImageMemoryBarrier barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER }; VkImageMemoryBarrier barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
barrier.srcAccessMask = src_access; barrier.srcAccessMask = src_access;
barrier.dstAccessMask = dst_access; barrier.dstAccessMask = dst_access;

View File

@ -1,7 +1,7 @@
DEBUG = 0 DEBUG = 0
LIBRETRODB_DIR := . LIBRETRODB_DIR := .
LIBRETRO_COMMON_DIR := ../libretro-common LIBRETRO_COMM_DIR := ../libretro-common
INCFLAGS = -I. -I$(LIBRETRO_COMMON_DIR)/include INCFLAGS = -I. -I$(LIBRETRO_COMM_DIR)/include
TARGETS = rmsgpack_test libretrodb_tool c_converter TARGETS = rmsgpack_test libretrodb_tool c_converter
@ -12,7 +12,7 @@ CFLAGS = -g -O2 -Wall -DNDEBUG
endif endif
LIBRETRO_COMMON_C = \ LIBRETRO_COMMON_C = \
$(LIBRETRO_COMMON_DIR)/streams/file_stream.c $(LIBRETRO_COMM_DIR)/streams/file_stream.c
C_CONVERTER_C = \ C_CONVERTER_C = \
$(LIBRETRODB_DIR)/rmsgpack.c \ $(LIBRETRODB_DIR)/rmsgpack.c \
@ -21,10 +21,11 @@ C_CONVERTER_C = \
$(LIBRETRODB_DIR)/bintree.c \ $(LIBRETRODB_DIR)/bintree.c \
$(LIBRETRODB_DIR)/query.c \ $(LIBRETRODB_DIR)/query.c \
$(LIBRETRODB_DIR)/c_converter.c \ $(LIBRETRODB_DIR)/c_converter.c \
$(LIBRETRO_COMMON_DIR)/hash/rhash.c \ $(LIBRETRO_COMM_DIR)/hash/rhash.c \
$(LIBRETRO_COMMON_DIR)/compat/compat_fnmatch.c \ $(LIBRETRO_COMM_DIR)/compat/compat_fnmatch.c \
$(LIBRETRO_COMM_DIR)/string/stdstring.c
$(LIBRETRO_COMMON_C) \ $(LIBRETRO_COMMON_C) \
$(LIBRETRO_COMMON_DIR)/compat/compat_strl.c $(LIBRETRO_COMM_DIR)/compat/compat_strl.c
C_CONVERTER_OBJS := $(C_CONVERTER_C:.c=.o) C_CONVERTER_OBJS := $(C_CONVERTER_C:.c=.o)
@ -35,9 +36,10 @@ RARCHDB_TOOL_C = \
$(LIBRETRODB_DIR)/bintree.c \ $(LIBRETRODB_DIR)/bintree.c \
$(LIBRETRODB_DIR)/query.c \ $(LIBRETRODB_DIR)/query.c \
$(LIBRETRODB_DIR)/libretrodb.c \ $(LIBRETRODB_DIR)/libretrodb.c \
$(LIBRETRO_COMMON_DIR)/compat/compat_fnmatch.c \ $(LIBRETRO_COMM_DIR)/compat/compat_fnmatch.c \
$(LIBRETRO_COMM_DIR)/string/stdstring.c
$(LIBRETRO_COMMON_C) \ $(LIBRETRO_COMMON_C) \
$(LIBRETRO_COMMON_DIR)/compat/compat_strl.c $(LIBRETRO_COMM_DIR)/compat/compat_strl.c
RARCHDB_TOOL_OBJS := $(RARCHDB_TOOL_C:.c=.o) RARCHDB_TOOL_OBJS := $(RARCHDB_TOOL_C:.c=.o)

View File

@ -31,6 +31,7 @@
#include <rhash.h> #include <rhash.h>
#include <retro_assert.h> #include <retro_assert.h>
#include <string/stdstring.h>
#include "libretrodb.h" #include "libretrodb.h"
@ -341,13 +342,13 @@ static dat_converter_list_t* dat_parser_table(
if (!map.key) if (!map.key)
{ {
if (!strcmp(current->token.label, ")")) if (string_is_equal(current->token.label, ")"))
{ {
current++; current++;
*start_token = current; *start_token = current;
return parsed_table; return parsed_table;
} }
else if (!strcmp(current->token.label, "(")) else if (string_is_equal(current->token.label, "("))
{ {
printf("%s:%d:%d: fatal error: Unexpected '(' instead of key\n", printf("%s:%d:%d: fatal error: Unexpected '(' instead of key\n",
current->token.fname, current->token.fname,
@ -363,14 +364,14 @@ static dat_converter_list_t* dat_parser_table(
} }
else else
{ {
if (!strcmp(current->token.label, "(")) if (string_is_equal(current->token.label, "("))
{ {
current++; current++;
map.type = DAT_CONVERTER_LIST_MAP; map.type = DAT_CONVERTER_LIST_MAP;
map.value.list = dat_parser_table(&current); map.value.list = dat_parser_table(&current);
dat_converter_list_append(parsed_table, &map); dat_converter_list_append(parsed_table, &map);
} }
else if (!strcmp(current->token.label, ")")) else if (string_is_equal(current->token.label, ")"))
{ {
printf("%s:%d:%d: fatal error: Unexpected ')' instead of value\n", printf("%s:%d:%d: fatal error: Unexpected ')' instead of value\n",
current->token.fname, current->token.fname,
@ -468,7 +469,7 @@ static const char* dat_converter_get_match(
{ {
if (list->values[i].map.hash == match_key->hash) if (list->values[i].map.hash == match_key->hash)
{ {
retro_assert(!strcmp(list->values[i].map.key, match_key->value)); retro_assert(string_is_equal(list->values[i].map.key, match_key->value));
if (match_key->next) if (match_key->next)
return dat_converter_get_match( return dat_converter_get_match(
@ -510,14 +511,14 @@ static dat_converter_list_t* dat_converter_parser(
{ {
if (!map.key) if (!map.key)
{ {
if (!strcmp(current->token.label, "game")) if (string_is_equal(current->token.label, "game"))
skip = false; skip = false;
map.key = current->token.label; map.key = current->token.label;
current++; current++;
} }
else else
{ {
if (!strcmp(current->token.label, "(")) if (string_is_equal(current->token.label, "("))
{ {
current++; current++;
map.value.list = dat_parser_table(&current); map.value.list = dat_parser_table(&current);

View File

@ -23,6 +23,8 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <string/stdstring.h>
#include "libretrodb.h" #include "libretrodb.h"
#include "rmsgpack_dom.h" #include "rmsgpack_dom.h"
@ -59,7 +61,7 @@ int main(int argc, char ** argv)
printf("Could not open db file '%s': %s\n", path, strerror(-rv)); printf("Could not open db file '%s': %s\n", path, strerror(-rv));
goto error; goto error;
} }
else if (!strcmp(command, "list")) else if (string_is_equal(command, "list"))
{ {
if ((rv = libretrodb_cursor_open(db, cur, NULL)) != 0) if ((rv = libretrodb_cursor_open(db, cur, NULL)) != 0)
{ {
@ -80,7 +82,7 @@ int main(int argc, char ** argv)
rmsgpack_dom_value_free(&item); rmsgpack_dom_value_free(&item);
} }
} }
else if (!strcmp(command, "find")) else if (string_is_equal(command, "find"))
{ {
if (argc != 4) if (argc != 4)
{ {
@ -111,7 +113,7 @@ int main(int argc, char ** argv)
rmsgpack_dom_value_free(&item); rmsgpack_dom_value_free(&item);
} }
} }
else if (!strcmp(command, "create-index")) else if (string_is_equal(command, "create-index"))
{ {
const char * index_name, * field_name; const char * index_name, * field_name;