mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-08 20:41:59 +03:00
Removing calls of strerror() function in mc-core
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
f6637e4871
commit
d5526e13dc
@ -23,7 +23,6 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h> /* strerror() */
|
|
||||||
#include <errno.h> /* extern int errno */
|
#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);
|
fd = mc_open (ini_path, O_WRONLY | O_TRUNC | O_SYNC, 0);
|
||||||
if (fd == -1) {
|
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;
|
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) {
|
if (cur_written == -1) {
|
||||||
mc_util_restore_from_backup_if_possible (ini_path, "~");
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,17 +720,13 @@ const char *
|
|||||||
unix_error_string (int error_num)
|
unix_error_string (int error_num)
|
||||||
{
|
{
|
||||||
static char buffer [BUF_LARGE];
|
static char buffer [BUF_LARGE];
|
||||||
#if GLIB_MAJOR_VERSION >= 2
|
|
||||||
gchar *strerror_currentlocale;
|
gchar *strerror_currentlocale;
|
||||||
|
|
||||||
strerror_currentlocale = g_locale_from_utf8(g_strerror (error_num), -1, NULL, NULL, NULL);
|
strerror_currentlocale = g_locale_from_utf8(g_strerror (error_num), -1, NULL, NULL, NULL);
|
||||||
g_snprintf (buffer, sizeof (buffer), "%s (%d)",
|
g_snprintf (buffer, sizeof (buffer), "%s (%d)",
|
||||||
strerror_currentlocale, error_num);
|
strerror_currentlocale, error_num);
|
||||||
g_free(strerror_currentlocale);
|
g_free(strerror_currentlocale);
|
||||||
#else
|
|
||||||
g_snprintf (buffer, sizeof (buffer), "%s (%d)",
|
|
||||||
g_strerror (error_num), error_num);
|
|
||||||
#endif
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ mcview_hexedit_save_changes (mcview_t * view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mc_close (fp) == -1) {
|
if (mc_close (fp) == -1) {
|
||||||
error = g_strdup (strerror (errno));
|
error = g_strdup (unix_error_string (errno));
|
||||||
message (D_ERROR, _(" Save file "),
|
message (D_ERROR, _(" Save file "),
|
||||||
_(" Error while closing the file: \n %s \n"
|
_(" Error while closing the file: \n %s \n"
|
||||||
" Data may have been written or not. "), error);
|
" Data may have been written or not. "), error);
|
||||||
@ -291,7 +291,7 @@ mcview_hexedit_save_changes (mcview_t * view)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
save_error:
|
save_error:
|
||||||
error = g_strdup (strerror (errno));
|
error = g_strdup (unix_error_string (errno));
|
||||||
text = g_strdup_printf (_(" Cannot save file: \n %s "), error);
|
text = g_strdup_printf (_(" Cannot save file: \n %s "), error);
|
||||||
g_free (error);
|
g_free (error);
|
||||||
(void) mc_close (fp);
|
(void) mc_close (fp);
|
||||||
|
Loading…
Reference in New Issue
Block a user