Cleanup some strcmps

This commit is contained in:
twinaphex 2015-06-14 19:42:25 +02:00
parent a7f1e43d81
commit ad5954862b
3 changed files with 24 additions and 12 deletions

View File

@ -555,7 +555,7 @@ static int android_input_get_id_index_from_name(android_input_t *android,
int i; int i;
for (i = 0; i < android->pads_connected; i++) for (i = 0; i < android->pads_connected; i++)
{ {
if (strcmp(name, android->pad_states[i].name) == 0) if (!strcmp(name, android->pad_states[i].name))
return i; return i;
} }

View File

@ -21,14 +21,12 @@
*/ */
#include <file/file_path.h> #include <file/file_path.h>
#include <stdlib.h> #include <stdlib.h>
#include <boolean.h> #include <boolean.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <errno.h> #include <errno.h>
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <retro_miscellaneous.h>
#ifdef __HAIKU__ #ifdef __HAIKU__
#include <kernel/image.h> #include <kernel/image.h>
@ -38,6 +36,12 @@
#include <unistd.h> /* stat() is defined here */ #include <unistd.h> /* stat() is defined here */
#endif #endif
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <retro_miscellaneous.h>
#include <rhash.h>
#if defined(__CELLOS_LV2__) #if defined(__CELLOS_LV2__)
#ifndef S_ISDIR #ifndef S_ISDIR
@ -122,6 +126,9 @@ bool path_contains_compressed_file(const char *path)
return (strchr(path,'#') != NULL); return (strchr(path,'#') != NULL);
} }
#define FILE_EXT_7Z 0x005971d6U
#define FILE_EXT_ZIP 0x0b88c7d8U
/** /**
* path_is_compressed_file: * path_is_compressed_file:
* @path : path * @path : path
@ -133,15 +140,20 @@ bool path_contains_compressed_file(const char *path)
bool path_is_compressed_file(const char* path) bool path_is_compressed_file(const char* path)
{ {
#ifdef HAVE_COMPRESSION #ifdef HAVE_COMPRESSION
const char* file_ext = path_get_extension(path); const char* file_ext = path_get_extension(path);
uint32_t file_ext_hash = djb2_calculate(file_ext);
switch (file_ext_hash)
{
#ifdef HAVE_7ZIP #ifdef HAVE_7ZIP
if (strcmp(file_ext,"7z") == 0) case FILE_EXT_7Z:
return true; return true;
#endif #endif
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
if (strcmp(file_ext,"zip") == 0) case FILE_EXT_ZIP:
return true; return true;
#endif #endif
}
#endif #endif
return false; return false;

View File

@ -31,7 +31,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));
return 1; return 1;
} }
else if (strcmp(command, "list") == 0) else if (!strcmp(command, "list"))
{ {
if ((rv = libretrodb_cursor_open(&db, &cur, NULL)) != 0) if ((rv = libretrodb_cursor_open(&db, &cur, NULL)) != 0)
{ {
@ -52,7 +52,7 @@ int main(int argc, char ** argv)
rmsgpack_dom_value_free(&item); rmsgpack_dom_value_free(&item);
} }
} }
else if (strcmp(command, "find") == 0) else if (!strcmp(command, "find"))
{ {
if (argc != 4) if (argc != 4)
{ {
@ -83,7 +83,7 @@ int main(int argc, char ** argv)
rmsgpack_dom_value_free(&item); rmsgpack_dom_value_free(&item);
} }
} }
else if (strcmp(command, "create-index") == 0) else if (!strcmp(command, "create-index"))
{ {
const char * index_name, * field_name; const char * index_name, * field_name;