1
1

Use local buffers instead of global cmd_buf one.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2009-10-11 11:13:55 +04:00
родитель 998001a22e
Коммит 42ba60cebe
4 изменённых файлов: 43 добавлений и 45 удалений

Просмотреть файл

@ -66,7 +66,7 @@
#include "setup.h" #include "setup.h"
#include "dialog.h" #include "dialog.h"
#include "widget.h" #include "widget.h"
#include "main.h" /* cmd_buf */ #include "main.h"
#include "layout.h" #include "layout.h"
#include "widget.h" #include "widget.h"
#include "wtools.h" #include "wtools.h"
@ -1639,8 +1639,8 @@ static const char *op_names1[] = {
}; };
#define FMD_XLEN 64 #define FMD_XLEN 64
int fmd_xlen = FMD_XLEN; int fmd_xlen = FMD_XLEN;
char fmd_buf [BUF_MEDIUM];
/* /*
* These are formats for building a prompt. Parts encoded as follows: * These are formats for building a prompt. Parts encoded as follows:
@ -1742,12 +1742,12 @@ panel_operate_generate_prompt (const WPanel *panel, const int operation,
if (single_source) { if (single_source) {
i = fmd_xlen - str_term_width1 (format_string) - 4; i = fmd_xlen - str_term_width1 (format_string) - 4;
g_snprintf (cmd_buf, sizeof (cmd_buf), format_string, g_snprintf (fmd_buf, sizeof (fmd_buf), format_string,
str_trunc (single_source, i)); str_trunc (single_source, i));
} else { } else {
g_snprintf (cmd_buf, sizeof (cmd_buf), format_string, g_snprintf (fmd_buf, sizeof (fmd_buf), format_string,
panel->marked); panel->marked);
i = str_term_width1 (cmd_buf) + 6 - fmd_xlen; i = str_term_width1 (fmd_buf) + 6 - fmd_xlen;
if (i > 0) { if (i > 0) {
fmd_xlen += i; fmd_xlen += i;
} }
@ -1796,13 +1796,11 @@ panel_operate (void *source_panel, FileOperation operation,
free_linklist (&linklist); free_linklist (&linklist);
free_linklist (&dest_dirs); free_linklist (&dest_dirs);
#if 0
/* Update panel contents to avoid actions on deleted files */ /* Update panel contents to avoid actions on deleted files */
if (!panel->is_panelized) { if (!panel->is_panelized) {
update_panels (UP_RELOAD, UP_KEEPSEL); update_panels (UP_RELOAD, UP_KEEPSEL);
repaint_screen (); repaint_screen ();
} }
#endif
if (single_entry) { if (single_entry) {
if (force_single) { if (force_single) {
@ -1854,7 +1852,7 @@ panel_operate (void *source_panel, FileOperation operation,
return 0; return 0;
} }
dest = file_mask_dialog (ctx, operation, cmd_buf, dest_dir_, dest = file_mask_dialog (ctx, operation, fmd_buf, dest_dir_,
single_entry, &do_bg); single_entry, &do_bg);
g_free (dest_dir_); g_free (dest_dir_);
@ -1867,7 +1865,7 @@ panel_operate (void *source_panel, FileOperation operation,
if (safe_delete) if (safe_delete)
query_set_sel (1); query_set_sel (1);
i = query_dialog (_(op_names[operation]), cmd_buf, D_ERROR, 2, i = query_dialog (_(op_names[operation]), fmd_buf, D_ERROR, 2,
_("&Yes"), _("&No")); _("&Yes"), _("&No"));
if (i != 0) { if (i != 0) {
@ -2189,26 +2187,29 @@ real_do_file_error (enum OperationMode mode, const char *error)
FileProgressStatus FileProgressStatus
file_error (const char *format, const char *file) file_error (const char *format, const char *file)
{ {
g_snprintf (cmd_buf, sizeof (cmd_buf), format, char buf [BUF_MEDIUM];
g_snprintf (buf, sizeof (buf), format,
path_trunc (file, 30), unix_error_string (errno)); path_trunc (file, 30), unix_error_string (errno));
return do_file_error (cmd_buf); return do_file_error (buf);
} }
/* Report error with two files */ /* Report error with two files */
static FileProgressStatus static FileProgressStatus
files_error (const char *format, const char *file1, const char *file2) files_error (const char *format, const char *file1, const char *file2)
{ {
char buf [BUF_MEDIUM];
char *nfile1 = g_strdup (path_trunc (file1, 15)); char *nfile1 = g_strdup (path_trunc (file1, 15));
char *nfile2 = g_strdup (path_trunc (file2, 15)); char *nfile2 = g_strdup (path_trunc (file2, 15));
g_snprintf (cmd_buf, sizeof (cmd_buf), format, nfile1, nfile2, g_snprintf (buf, sizeof (buf), format, nfile1, nfile2,
unix_error_string (errno)); unix_error_string (errno));
g_free (nfile1); g_free (nfile1);
g_free (nfile2); g_free (nfile2);
return do_file_error (cmd_buf); return do_file_error (buf);
} }
static FileProgressStatus static FileProgressStatus

Просмотреть файл

@ -298,8 +298,6 @@ char *mc_home = NULL;
/* mc_home_alt: Alternative home of MC - deprecated /usr/share/mc */ /* mc_home_alt: Alternative home of MC - deprecated /usr/share/mc */
char *mc_home_alt = NULL; char *mc_home_alt = NULL;
char cmd_buf[512];
/* Define this function for glib-style error handling */ /* Define this function for glib-style error handling */
GQuark GQuark
mc_main_error_quark (void) mc_main_error_quark (void)

Просмотреть файл

@ -66,7 +66,6 @@ extern int vfs_use_limit;
extern int only_leading_plus_minus; extern int only_leading_plus_minus;
extern int output_starts_shell; extern int output_starts_shell;
extern int midnight_shutdown; extern int midnight_shutdown;
extern char cmd_buf [512];
extern char *shell; extern char *shell;
extern int auto_fill_mkdir_name; extern int auto_fill_mkdir_name;
extern int skip_check_codeset; extern int skip_check_codeset;

Просмотреть файл

@ -608,31 +608,28 @@ tree_forget_cmd (void *data)
tree_remove_entry (tree, tree->selected_ptr->name); tree_remove_entry (tree, tree->selected_ptr->name);
} }
static void tree_copy (WTree *tree, const char *default_dest) static void
tree_copy (WTree *tree, const char *default_dest)
{ {
char msg [BUF_MEDIUM];
char *dest; char *dest;
off_t count = 0; off_t count = 0;
double bytes = 0; double bytes = 0;
FileOpContext *ctx; FileOpContext *ctx;
if (!tree->selected_ptr) if (tree->selected_ptr == NULL)
return; return;
g_snprintf (cmd_buf, sizeof(cmd_buf), _("Copy \"%s\" directory to:"),
g_snprintf (msg, sizeof (msg), _("Copy \"%s\" directory to:"),
str_trunc (tree->selected_ptr->name, 50)); str_trunc (tree->selected_ptr->name, 50));
dest = input_expand_dialog (_(" Copy "), cmd_buf, MC_HISTORY_FM_TREE_COPY, default_dest); dest = input_expand_dialog (_(" Copy "), msg, MC_HISTORY_FM_TREE_COPY, default_dest);
if (!dest)
return;
if (!*dest){
g_free (dest);
return;
}
if (dest != NULL && *dest != '\0') {
ctx = file_op_context_new (OP_COPY); ctx = file_op_context_new (OP_COPY);
file_op_context_create_ui (ctx, FALSE); file_op_context_create_ui (ctx, FALSE);
copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes); copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes);
file_op_context_destroy (ctx); file_op_context_destroy (ctx);
}
g_free (dest); g_free (dest);
} }
@ -650,25 +647,28 @@ tree_copy_cmd (void *data)
tree_copy (tree, ""); tree_copy (tree, "");
} }
static void tree_move (WTree *tree, const char *default_dest) static void
tree_move (WTree *tree, const char *default_dest)
{ {
char msg [BUF_MEDIUM];
char *dest; char *dest;
struct stat buf; struct stat buf;
double bytes = 0; double bytes = 0;
off_t count = 0; off_t count = 0;
FileOpContext *ctx; FileOpContext *ctx;
if (!tree->selected_ptr) if (tree->selected_ptr == NULL)
return; return;
g_snprintf (cmd_buf, sizeof (cmd_buf), _("Move \"%s\" directory to:"),
g_snprintf (msg, sizeof (msg), _("Move \"%s\" directory to:"),
str_trunc (tree->selected_ptr->name, 50)); str_trunc (tree->selected_ptr->name, 50));
dest = input_expand_dialog (_(" Move "), cmd_buf, MC_HISTORY_FM_TREE_MOVE, default_dest); dest = input_expand_dialog (_(" Move "), msg, MC_HISTORY_FM_TREE_MOVE, default_dest);
if (!dest)
return; if (dest == NULL || *dest == '\0') {
if (!*dest){
g_free (dest); g_free (dest);
return; return;
} }
if (stat (dest, &buf)){ if (stat (dest, &buf)){
message (D_ERROR, MSG_ERROR, _(" Cannot stat the destination \n %s "), message (D_ERROR, MSG_ERROR, _(" Cannot stat the destination \n %s "),
unix_error_string (errno)); unix_error_string (errno));