Removing calls of strerror() function in mc-core

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2009-11-02 14:12:56 +02:00 committed by Enrico Weigelt, metux IT service
parent f6637e4871
commit d5526e13dc
3 changed files with 6 additions and 11 deletions

View File

@ -23,7 +23,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h> /* strerror() */
#include <errno.h> /* 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;
}

View File

@ -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;
}

View File

@ -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);