Start using string_is_empty

This commit is contained in:
twinaphex 2015-12-26 07:07:01 +01:00
parent 7f6b47ae9e
commit 91f61afa16
3 changed files with 18 additions and 11 deletions

View File

@ -15,6 +15,7 @@
*/ */
#include <compat/posix_string.h> #include <compat/posix_string.h>
#include <string/stdstring.h>
#include "general.h" #include "general.h"
#include "msg_hash.h" #include "msg_hash.h"
@ -139,7 +140,7 @@ int find_driver_index(const char * label, const char *drv)
{ {
if (!obj) if (!obj)
return -1; return -1;
if (str[0] == '\0') if (string_is_empty(str))
break; break;
if (!strcasecmp(drv, str)) if (!strcasecmp(drv, str))
return i; return i;

View File

@ -24,6 +24,7 @@
#include <setjmp.h> #include <setjmp.h>
#include <boolean.h> #include <boolean.h>
#include <string/stdstring.h>
#ifdef _WIN32 #ifdef _WIN32
#ifdef _XBOX #ifdef _XBOX
@ -333,7 +334,7 @@ static void set_special_paths(char **argv, unsigned num_content)
/* If this is already set, /* If this is already set,
* do not overwrite it as this was initialized before in * do not overwrite it as this was initialized before in
* a menu or otherwise. */ * a menu or otherwise. */
if (settings->system_directory[0] == '\0') if (string_is_empty(settings->system_directory))
{ {
RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n",argv[0]); RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n",argv[0]);
/*fill_pathname_basedir(settings->system_directory, argv[0], /*fill_pathname_basedir(settings->system_directory, argv[0],
@ -365,7 +366,7 @@ static void set_paths_redirect(const char *path)
return; return;
} }
if (info->info.library_name && if (info->info.library_name &&
(info->info.library_name[0] != '\0')) !string_is_empty(info->info.library_name))
global_library_name_hash = msg_hash_calculate(info->info.library_name); global_library_name_hash = msg_hash_calculate(info->info.library_name);
/* Initialize current save directories with the values from the config */ /* Initialize current save directories with the values from the config */
@ -385,7 +386,8 @@ static void set_paths_redirect(const char *path)
if (check_global_library_name_hash) if (check_global_library_name_hash)
{ {
/* per-core saves: append the library_name to the save location */ /* per-core saves: append the library_name to the save location */
if (settings->sort_savefiles_enable && global->dir.savefile[0] != '\0') if (settings->sort_savefiles_enable
&& !string_is_empty(global->dir.savefile))
{ {
fill_pathname_join( fill_pathname_join(
current_savefile_dir, current_savefile_dir,
@ -395,7 +397,8 @@ static void set_paths_redirect(const char *path)
/* If path doesn't exist, try to create it, /* If path doesn't exist, try to create it,
* if everything fails revert to the original path. */ * if everything fails revert to the original path. */
if(!path_is_directory(current_savefile_dir) && current_savefile_dir[0] != '\0') if(!path_is_directory(current_savefile_dir)
&& !string_is_empty(current_savefile_dir))
{ {
path_mkdir(current_savefile_dir); path_mkdir(current_savefile_dir);
if(!path_is_directory(current_savefile_dir)) if(!path_is_directory(current_savefile_dir))
@ -409,7 +412,8 @@ static void set_paths_redirect(const char *path)
} }
/* per-core states: append the library_name to the save location */ /* per-core states: append the library_name to the save location */
if (settings->sort_savestates_enable && global->dir.savestate[0] != '\0') if (settings->sort_savestates_enable
&& !string_is_empty(global->dir.savestate))
{ {
fill_pathname_join( fill_pathname_join(
current_savestate_dir, current_savestate_dir,
@ -419,7 +423,8 @@ static void set_paths_redirect(const char *path)
/* If path doesn't exist, try to create it. /* If path doesn't exist, try to create it.
* If everything fails, revert to the original path. */ * If everything fails, revert to the original path. */
if(!path_is_directory(current_savestate_dir) && current_savestate_dir[0] != '\0') if(!path_is_directory(current_savestate_dir) &&
!string_is_empty(current_savestate_dir))
{ {
path_mkdir(current_savestate_dir); path_mkdir(current_savestate_dir);
if(!path_is_directory(current_savestate_dir)) if(!path_is_directory(current_savestate_dir))
@ -1539,7 +1544,7 @@ void rarch_playlist_load_content(void *data, unsigned idx)
content_playlist_get_index(playlist, content_playlist_get_index(playlist,
idx, &path, NULL, &core_path, NULL, NULL, NULL); idx, &path, NULL, &core_path, NULL, NULL, NULL);
if (path && path[0] != '\0') if (path && !string_is_empty(path))
{ {
unsigned i; unsigned i;
RFILE *fp = NULL; RFILE *fp = NULL;

View File

@ -26,6 +26,7 @@
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
#include <rthreads/rthreads.h> #include <rthreads/rthreads.h>
#endif #endif
#include <string/stdstring.h>
#include <compat/strl.h> #include <compat/strl.h>
@ -420,7 +421,7 @@ static bool rarch_game_specific_options(char **output)
if (!core_name || !game_name) if (!core_name || !game_name)
return false; return false;
if (core_name[0] == '\0' || game_name[0] == '\0') if (string_is_empty(core_name) || string_is_empty(game_name))
return false; return false;
RARCH_LOG("Per-Game Options: core name: %s\n", core_name); RARCH_LOG("Per-Game Options: core name: %s\n", core_name);
@ -429,9 +430,9 @@ static bool rarch_game_specific_options(char **output)
/* Config directory: config_directory. /* Config directory: config_directory.
* Try config directory setting first, * Try config directory setting first,
* fallback to the location of the current configuration file. */ * fallback to the location of the current configuration file. */
if (settings->menu_config_directory[0] != '\0') if (!string_is_empty(settings->menu_config_directory))
strlcpy(config_directory, settings->menu_config_directory, sizeof(config_directory)); strlcpy(config_directory, settings->menu_config_directory, sizeof(config_directory));
else if (global->path.config[0] != '\0') else if (!string_is_empty(global->path.config))
fill_pathname_basedir(config_directory, global->path.config, sizeof(config_directory)); fill_pathname_basedir(config_directory, global->path.config, sizeof(config_directory));
else else
{ {