Use string_is_empty

This commit is contained in:
twinaphex 2016-06-28 11:02:51 +02:00
parent 58b95752e8
commit 7a745c3f70
7 changed files with 24 additions and 22 deletions

View File

@ -222,11 +222,11 @@ static bool command_read_ram(const char *arg)
static bool command_write_ram(const char *arg) static bool command_write_ram(const char *arg)
{ {
cheevos_var_t var;
uint8_t * data;
unsigned nbytes;
int i; int i;
char reply[256]; char reply[256];
cheevos_var_t var;
unsigned nbytes;
uint8_t * data = NULL;
cheevos_parse_guest_addr(&var, strtoul(arg, (char**)&arg, 16)); cheevos_parse_guest_addr(&var, strtoul(arg, (char**)&arg, 16));
data = cheevos_get_memory(&var); data = cheevos_get_memory(&var);
@ -859,7 +859,7 @@ static void command_event_disk_control_set_eject(bool new_state, bool print_log)
msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY)); msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY));
} }
if (*msg) if (!string_is_empty(msg))
{ {
if (error) if (error)
RARCH_ERR("%s\n", msg); RARCH_ERR("%s\n", msg);
@ -918,7 +918,7 @@ static void command_event_disk_control_set_index(unsigned idx)
error = true; error = true;
} }
if (*msg) if (!string_is_empty(msg))
{ {
if (error) if (error)
RARCH_ERR("%s\n", msg); RARCH_ERR("%s\n", msg);
@ -1543,11 +1543,12 @@ void command_event_save_current_config(void)
*/ */
/* Flush out the core specific config. */ /* Flush out the core specific config. */
if (*global->path.core_specific_config && if (!string_is_empty(global->path.core_specific_config)
settings->core_specific_config) && settings->core_specific_config)
ret = config_save_file(global->path.core_specific_config); ret = config_save_file(global->path.core_specific_config);
else else
ret = config_save_file(global->path.config); ret = config_save_file(global->path.config);
if (ret) if (ret)
{ {
snprintf(msg, sizeof(msg), "Saved new config to \"%s\".", snprintf(msg, sizeof(msg), "Saved new config to \"%s\".",
@ -2092,7 +2093,7 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_CORE_INFO_INIT: case CMD_EVENT_CORE_INFO_INIT:
command_event(CMD_EVENT_CORE_INFO_DEINIT, NULL); command_event(CMD_EVENT_CORE_INFO_DEINIT, NULL);
if (*settings->directory.libretro) if (!string_is_empty(settings->directory.libretro))
core_info_init_list(); core_info_init_list();
break; break;
case CMD_EVENT_CORE_DEINIT: case CMD_EVENT_CORE_DEINIT:

View File

@ -901,7 +901,7 @@ static void config_set_defaults(void)
g_defaults.dir.content_history, g_defaults.dir.content_history,
sizeof(settings->directory.content_history)); sizeof(settings->directory.content_history));
if (*g_defaults.path.config) if (!string_is_empty(g_defaults.path.config))
fill_pathname_expand_special(global->path.config, fill_pathname_expand_special(global->path.config,
g_defaults.path.config, sizeof(global->path.config)); g_defaults.path.config, sizeof(global->path.config));
@ -1949,7 +1949,7 @@ static void config_load_core_specific(void)
#endif #endif
#ifdef HAVE_MENU #ifdef HAVE_MENU
if (*settings->directory.menu_config) if (!string_is_empty(settings->directory.menu_config))
{ {
path_resolve_realpath(settings->directory.menu_config, path_resolve_realpath(settings->directory.menu_config,
sizeof(settings->directory.menu_config)); sizeof(settings->directory.menu_config));
@ -2277,14 +2277,14 @@ static void parse_config_file(void)
bool ret = config_load_file((*global->path.config) bool ret = config_load_file((*global->path.config)
? global->path.config : NULL, false); ? global->path.config : NULL, false);
if (*global->path.config) if (!string_is_empty(global->path.config))
{ {
RARCH_LOG("Config: loading config from: %s.\n", global->path.config); RARCH_LOG("Config: loading config from: %s.\n", global->path.config);
} }
else else
{ {
RARCH_LOG("Loading default config.\n"); RARCH_LOG("Loading default config.\n");
if (*global->path.config) if (!string_is_empty(global->path.config))
RARCH_LOG("Config: found default config: %s.\n", global->path.config); RARCH_LOG("Config: found default config: %s.\n", global->path.config);
} }
@ -2466,7 +2466,7 @@ void config_load(void)
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
/* Flush out per-core configs before loading a new config. */ /* Flush out per-core configs before loading a new config. */
if (*global->path.core_specific_config && if (!string_is_empty(global->path.core_specific_config) &&
settings->config_save_on_exit && settings->core_specific_config) settings->config_save_on_exit && settings->core_specific_config)
config_save_file(global->path.core_specific_config); config_save_file(global->path.core_specific_config);

View File

@ -121,7 +121,7 @@ void fill_pathname_abbreviate_special(char *out_path,
for (i = 0; candidates[i]; i++) for (i = 0; candidates[i]; i++)
{ {
if (*candidates[i] && strstr(in_path, candidates[i]) == in_path) if (!string_is_empty(candidates[i]) && strstr(in_path, candidates[i]) == in_path)
{ {
size_t src_size = strlcpy(out_path, notations[i], size); size_t src_size = strlcpy(out_path, notations[i], size);

View File

@ -248,7 +248,7 @@ static void menu_action_setting_disp_set_label_shader_pass(
if (!shader) if (!shader)
return; return;
if (*shader->pass[pass].source.path) if (!string_is_empty(shader->pass[pass].source.path))
fill_pathname_base(s, fill_pathname_base(s,
shader->pass[pass].source.path, len); shader->pass[pass].source.path, len);
#endif #endif

View File

@ -19,6 +19,7 @@
#include <compat/strl.h> #include <compat/strl.h>
#include <retro_assert.h> #include <retro_assert.h>
#include <file/file_path.h> #include <file/file_path.h>
#include <string/stdstring.h>
#include "menu_driver.h" #include "menu_driver.h"
#include "menu_shader.h" #include "menu_shader.h"
@ -48,10 +49,10 @@ void menu_shader_manager_init(menu_handle_t *menu)
if (global) if (global)
{ {
if (*global->path.core_specific_config if (!string_is_empty(global->path.core_specific_config)
&& settings->core_specific_config) && settings->core_specific_config)
config_path = global->path.core_specific_config; config_path = global->path.core_specific_config;
else if (*global->path.config) else if (!string_is_empty(global->path.config))
config_path = global->path.config; config_path = global->path.config;
} }
@ -288,7 +289,7 @@ void menu_shader_manager_save_preset(
strlcpy(buffer, conf_path, sizeof(buffer)); strlcpy(buffer, conf_path, sizeof(buffer));
} }
if (*global->path.config) if (!string_is_empty(global->path.config))
fill_pathname_basedir( fill_pathname_basedir(
config_directory, config_directory,
global->path.config, global->path.config,

View File

@ -1062,13 +1062,13 @@ static void retroarch_parse_input(int argc, char *argv[])
} }
} }
if (!*global->subsystem && optind < argc) if (string_is_empty(global->subsystem) && optind < argc)
{ {
/* We requested explicit ROM, so use PLAIN core type. */ /* We requested explicit ROM, so use PLAIN core type. */
retroarch_set_current_core_type(CORE_TYPE_PLAIN, false); retroarch_set_current_core_type(CORE_TYPE_PLAIN, false);
retroarch_set_pathnames((const char*)argv[optind]); retroarch_set_pathnames((const char*)argv[optind]);
} }
else if (*global->subsystem && optind < argc) else if (!string_is_empty(global->subsystem) && optind < argc)
{ {
/* We requested explicit ROM, so use PLAIN core type. */ /* We requested explicit ROM, so use PLAIN core type. */
retroarch_set_current_core_type(CORE_TYPE_PLAIN, false); retroarch_set_current_core_type(CORE_TYPE_PLAIN, false);

View File

@ -562,10 +562,10 @@ static bool task_overlay_resolve_targets(struct overlay *ol,
for (i = 0; i < current->size; i++) for (i = 0; i < current->size; i++)
{ {
const char *next = current->descs[i].next_index_name;
ssize_t next_idx = 0; ssize_t next_idx = 0;
const char *next = current->descs[i].next_index_name;
if (*next) if (!string_is_empty(next))
{ {
next_idx = task_overlay_find_index(ol, next, size); next_idx = task_overlay_find_index(ol, next, size);