diff --git a/src/mcconfig/common.c b/src/mcconfig/common.c index fdd392bbe..6aaf25968 100644 --- a/src/mcconfig/common.c +++ b/src/mcconfig/common.c @@ -23,7 +23,6 @@ #include #include #include -#include /* strerror() */ #include /* extern int errno */ @@ -68,7 +67,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path, fd = mc_open (ini_path, O_WRONLY | O_TRUNC | O_SYNC, 0); if (fd == -1) { - g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, "%s", strerror(errno))); + g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, unix_error_string (errno))); return FALSE; } @@ -80,7 +79,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path, if (cur_written == -1) { mc_util_restore_from_backup_if_possible (ini_path, "~"); - g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, "%s", strerror(errno))); + g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, unix_error_string (errno))); return FALSE; } diff --git a/src/util.c b/src/util.c index 08c577715..37f3e8e3f 100644 --- a/src/util.c +++ b/src/util.c @@ -720,17 +720,13 @@ const char * unix_error_string (int error_num) { static char buffer [BUF_LARGE]; -#if GLIB_MAJOR_VERSION >= 2 gchar *strerror_currentlocale; - + strerror_currentlocale = g_locale_from_utf8(g_strerror (error_num), -1, NULL, NULL, NULL); g_snprintf (buffer, sizeof (buffer), "%s (%d)", strerror_currentlocale, error_num); g_free(strerror_currentlocale); -#else - g_snprintf (buffer, sizeof (buffer), "%s (%d)", - g_strerror (error_num), error_num); -#endif + return buffer; } diff --git a/src/viewer/hex.c b/src/viewer/hex.c index 41cdd6c2b..226292943 100644 --- a/src/viewer/hex.c +++ b/src/viewer/hex.c @@ -281,7 +281,7 @@ mcview_hexedit_save_changes (mcview_t * view) } if (mc_close (fp) == -1) { - error = g_strdup (strerror (errno)); + error = g_strdup (unix_error_string (errno)); message (D_ERROR, _(" Save file "), _(" Error while closing the file: \n %s \n" " Data may have been written or not. "), error); @@ -291,7 +291,7 @@ mcview_hexedit_save_changes (mcview_t * view) return TRUE; save_error: - error = g_strdup (strerror (errno)); + error = g_strdup (unix_error_string (errno)); text = g_strdup_printf (_(" Cannot save file: \n %s "), error); g_free (error); (void) mc_close (fp);