updated: [589ffd0] Use g_snprintf instead of snprintf as we switch back to glib
Patrick Winnertz
winnie at debian.org
Tue Feb 10 11:49:55 UTC 2009
The following commit has been merged in the master branch:
commit 589ffd0b106b192fc43d1879aa1b7d364297528d
Author: Patrick Winnertz <winnie at debian.org>
Date: Thu Feb 5 23:49:00 2009 +0100
Use g_snprintf instead of snprintf as we switch back to glib
Signed-off-by: Patrick Winnertz <winnie at debian.org>
diff --git a/edit/editcmd.c b/edit/editcmd.c
index 60bced2..6d3c2ed 100644
--- a/edit/editcmd.c
+++ b/edit/editcmd.c
@@ -2316,7 +2316,7 @@ edit_goto_cmd (WEdit *edit)
char *error;
char s[32];
- snprintf (s, sizeof (s), "%ld", line);
+ g_snprintf (s, sizeof (s), "%ld", line);
f = input_dialog (_(" Goto line "), _(" Enter line: "), MC_HISTORY_EDIT_GOTO_LINE,
line ? s : "");
if (!f)
diff --git a/edit/editdraw.c b/edit/editdraw.c
index b191391..86ea3f9 100644
--- a/edit/editdraw.c
+++ b/edit/editdraw.c
@@ -72,7 +72,7 @@ static void status_string (WEdit * edit, char *s, int w)
*/
if (edit->curs1 < edit->last_byte) {
unsigned char cur_byte = edit_get_byte (edit, edit->curs1);
- snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X",
+ g_snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X",
is_printable (cur_byte) ? cur_byte : '.',
(int) cur_byte,
(unsigned) cur_byte);
@@ -81,7 +81,7 @@ static void status_string (WEdit * edit, char *s, int w)
}
/* The field lengths just prevent the status line from shortening too much */
- snprintf (s, w,
+ g_snprintf (s, w,
"[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb)= %s",
edit->mark1 != edit->mark2 ? ( column_highlighting ? 'C' : 'B') : '-',
edit->modified ? 'M' : '-',
diff --git a/edit/editoptions.c b/edit/editoptions.c
index 777431f..9011ded 100644
--- a/edit/editoptions.c
+++ b/edit/editoptions.c
@@ -147,9 +147,9 @@ edit_options_dialog (void)
i18n_flag = 1;
}
- snprintf (wrap_length, sizeof (wrap_length), "%d",
+ g_snprintf (wrap_length, sizeof (wrap_length), "%d",
option_word_wrap_line_length);
- snprintf (tab_spacing, sizeof (tab_spacing), "%d",
+ g_snprintf (tab_spacing, sizeof (tab_spacing), "%d",
option_tab_spacing);
quick_widgets[3].text = wrap_length;
diff --git a/src/boxes.c b/src/boxes.c
index a2c863c..a950f3d 100644
--- a/src/boxes.c
+++ b/src/boxes.c
@@ -573,7 +573,7 @@ sel_charset_button (int action)
: codepages[new_display_codepage].name;
/* avoid strange bug with label repainting */
- snprintf (buf, sizeof (buf), "%-27s", cpname);
+ g_snprintf (buf, sizeof (buf), "%-27s", cpname);
label_set_text (cplabel, buf);
return 0;
}
@@ -774,12 +774,12 @@ configure_vfs (void)
ret_use_netrc = use_netrc;
ret_ftpfs_use_passive_connections = ftpfs_use_passive_connections;
ret_ftpfs_use_passive_connections_over_proxy = ftpfs_use_passive_connections_over_proxy;
- snprintf(buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
+ g_snprintf(buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
confvfs_widgets[8].text = buffer3;
confvfs_widgets[10].text = ftpfs_anonymous_passwd;
confvfs_widgets[5].text = ftpfs_proxy_host;
#endif
- snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
+ g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
confvfs_widgets [3 + VFS_WIDGETBASE].text = buffer2;
if (quick_dialog (&confvfs_dlg) != B_CANCEL) {
diff --git a/src/charsets.c b/src/charsets.c
index 4e807c0..f2e69e0 100644
--- a/src/charsets.c
+++ b/src/charsets.c
@@ -198,7 +198,7 @@ init_translation_table (int cpsource, int cpdisplay)
cd = iconv_open (cpdisp, cpsour);
if (cd == (iconv_t) - 1) {
- snprintf (errbuf, sizeof (errbuf),
+ g_snprintf (errbuf, sizeof (errbuf),
_("Cannot translate from %s to %s"), cpsour, cpdisp);
return errbuf;
}
@@ -212,7 +212,7 @@ init_translation_table (int cpsource, int cpdisplay)
cd = iconv_open (cpsour, cpdisp);
if (cd == (iconv_t) - 1) {
- snprintf (errbuf, sizeof (errbuf),
+ g_snprintf (errbuf, sizeof (errbuf),
_("Cannot translate from %s to %s"), cpdisp, cpsour);
return errbuf;
}
diff --git a/src/chmod.c b/src/chmod.c
index 3f76b0c..2671c65 100644
--- a/src/chmod.c
+++ b/src/chmod.c
@@ -161,7 +161,7 @@ chmod_callback (Dlg_head *h, dlg_msg_t msg, int parm)
case DLG_ACTION:
if (id >= 0) {
c_stat ^= check_perm[id].mode;
- snprintf (buffer, sizeof (buffer), "%o", c_stat);
+ g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
label_set_text (statl, buffer);
chmod_toggle_select (h, id);
mode_change = 1;
@@ -302,7 +302,7 @@ void chmod_cmd (void)
add_widget (ch_dlg, label_new (FY+6, FX+2, c_fown));
c_fgrp = name_trunc (get_group (sf_stat.st_gid), 21);
add_widget (ch_dlg, label_new (FY+8, FX+2, c_fgrp));
- snprintf (buffer, sizeof (buffer), "%o", c_stat);
+ g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
statl = label_new (FY+4, FX+2, buffer);
add_widget (ch_dlg, statl);
diff --git a/src/cmd.c b/src/cmd.c
index da9248f..0bab86e 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -122,7 +122,7 @@ view_file_at_line (const char *filename, int plain_view, int internal,
char view_entry[BUF_TINY];
if (start_line != 0)
- snprintf (view_entry, sizeof (view_entry), "View:%d",
+ g_snprintf (view_entry, sizeof (view_entry), "View:%d",
start_line);
else
strcpy (view_entry, "View");
diff --git a/src/file.c b/src/file.c
index e3bba04..4ef043c 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1701,10 +1701,10 @@ panel_operate_generate_prompt (const WPanel *panel, const int operation,
if (single_source) {
i = fmd_xlen - strlen (format_string) - 4;
- snprintf (cmd_buf, sizeof (cmd_buf), format_string,
+ g_snprintf (cmd_buf, sizeof (cmd_buf), format_string,
name_trunc (single_source, i));
} else {
- snprintf (cmd_buf, sizeof (cmd_buf), format_string,
+ g_snprintf (cmd_buf, sizeof (cmd_buf), format_string,
panel->marked);
i = strlen (cmd_buf) + 6 - fmd_xlen;
if (i > 0) {
@@ -2126,7 +2126,7 @@ real_do_file_error (enum OperationMode mode, const char *error)
int
file_error (const char *format, const char *file)
{
- snprintf (cmd_buf, sizeof (cmd_buf), format,
+ g_snprintf (cmd_buf, sizeof (cmd_buf), format,
path_trunc (file, 30), unix_error_string (errno));
return do_file_error (cmd_buf);
@@ -2142,7 +2142,7 @@ files_error (const char *format, const char *file1, const char *file2)
strcpy (nfile1, path_trunc (file1, 15));
strcpy (nfile2, path_trunc (file2, 15));
- snprintf (cmd_buf, sizeof (cmd_buf), format, nfile1, nfile2,
+ g_snprintf (cmd_buf, sizeof (cmd_buf), format, nfile1, nfile2,
unix_error_string (errno));
return do_file_error (cmd_buf);
diff --git a/src/filegui.c b/src/filegui.c
index c57dc79..87ea36c 100644
--- a/src/filegui.c
+++ b/src/filegui.c
@@ -322,7 +322,7 @@ file_eta_show (FileOpContext *ctx)
eta_hours = ctx->eta_secs / (60 * 60);
eta_mins = (ctx->eta_secs - (eta_hours * 60 * 60)) / 60;
eta_s = ctx->eta_secs - (eta_hours * 60 * 60 + eta_mins * 60);
- snprintf (eta_buffer, sizeof (eta_buffer), _("ETA %d:%02d.%02d"),
+ g_snprintf (eta_buffer, sizeof (eta_buffer), _("ETA %d:%02d.%02d"),
eta_hours, eta_mins, eta_s);
} else
*eta_buffer = 0;
@@ -345,13 +345,13 @@ file_bps_show (FileOpContext *ctx)
return;
if (ctx->bps > 1024 * 1024) {
- snprintf (bps_buffer, sizeof (bps_buffer), _("%.2f MB/s"),
+ g_snprintf (bps_buffer, sizeof (bps_buffer), _("%.2f MB/s"),
ctx->bps / (1024 * 1024.0));
} else if (ctx->bps > 1024) {
- snprintf (bps_buffer, sizeof (bps_buffer), _("%.2f KB/s"),
+ g_snprintf (bps_buffer, sizeof (bps_buffer), _("%.2f KB/s"),
ctx->bps / 1024.0);
} else if (ctx->bps > 1) {
- snprintf (bps_buffer, sizeof (bps_buffer), _("%ld B/s"),
+ g_snprintf (bps_buffer, sizeof (bps_buffer), _("%ld B/s"),
ctx->bps);
} else
*bps_buffer = 0;
@@ -542,7 +542,7 @@ static struct {
NORMAL_BUTTON, rd_widgets [i].text, 0))
#define ADD_RD_LABEL(ui,i,p1,p2)\
- snprintf (buffer, sizeof (buffer), rd_widgets [i].text, p1, p2);\
+ g_snprintf (buffer, sizeof (buffer), rd_widgets [i].text, p1, p2);\
add_widget (ui->replace_dlg,\
label_new (rd_widgets [i].ypos, rd_widgets [i].xpos, buffer))
diff --git a/src/find.c b/src/find.c
index f493b3d..517a219 100644
--- a/src/find.c
+++ b/src/find.c
@@ -532,7 +532,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
if (file_fd == -1)
return 0;
- snprintf (buffer, sizeof (buffer), _("Grepping in %s"), name_trunc (filename, FIND2_X_USE));
+ g_snprintf (buffer, sizeof (buffer), _("Grepping in %s"), name_trunc (filename, FIND2_X_USE));
status_update (buffer);
mc_refresh ();
@@ -668,7 +668,7 @@ do_search (struct Dlg_head *h)
if (verbose){
char buffer [BUF_SMALL];
- snprintf (buffer, sizeof (buffer), _("Searching %s"),
+ g_snprintf (buffer, sizeof (buffer), _("Searching %s"),
name_trunc (directory, FIND2_X_USE));
status_update (buffer);
}
diff --git a/src/layout.c b/src/layout.c
index 9d91845..37298a9 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -877,7 +877,7 @@ const char *get_nth_panel_name (int num)
else if (num == 1)
return "New Right Panel";
else {
- snprintf (buffer, sizeof (buffer), "%ith Panel", num);
+ g_snprintf (buffer, sizeof (buffer), "%ith Panel", num);
return buffer;
}
}
diff --git a/src/learn.c b/src/learn.c
index 9320883..fb98033 100644
--- a/src/learn.c
+++ b/src/learn.c
@@ -270,7 +270,7 @@ init_learn (void)
for (i = j - 1, key = key_name_conv_tab + j - 1; i >= 0; i--, key--) {
learnkeys[i].ok = 0;
learnkeys[i].sequence = NULL;
- snprintf (buffer, sizeof (buffer), "%-16s", _(key->longname));
+ g_snprintf (buffer, sizeof (buffer), "%-16s", _(key->longname));
add_widget (learn_dlg, learnkeys[i].button = (Widget *)
button_new (y, x, B_USER + i, NARROW_BUTTON, buffer,
learn_button));
diff --git a/src/main.c b/src/main.c
index 881a3d6..367663a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1650,7 +1650,7 @@ load_hint (int force)
} else {
char text[BUF_SMALL];
- snprintf (text, sizeof (text), _("GNU Midnight Commander %s\n"),
+ g_snprintf (text, sizeof (text), _("GNU Midnight Commander %s\n"),
VERSION);
set_hintbar (text);
}
diff --git a/src/man2hlp.c b/src/man2hlp.c
index 231639e..6a92237 100644
--- a/src/man2hlp.c
+++ b/src/man2hlp.c
@@ -146,7 +146,7 @@ fopen_check (const char *filename, const char *flags)
f = fopen (filename, flags);
if (f == NULL) {
- snprintf (tmp, sizeof (tmp), "man2hlp: Cannot open file \"%s\"",
+ g_snprintf (tmp, sizeof (tmp), "man2hlp: Cannot open file \"%s\"",
filename);
perror (tmp);
exit (3);
@@ -584,7 +584,7 @@ handle_command (char *buffer)
} else {
/* Other commands are ignored */
char warn_str[BUFFER_SIZE];
- snprintf (warn_str, sizeof (warn_str),
+ g_snprintf (warn_str, sizeof (warn_str),
"Warning: unsupported command %s", buffer);
print_error (warn_str);
return;
@@ -813,7 +813,7 @@ main (int argc, char **argv)
}
}
if (!found) {
- snprintf (buffer, sizeof (buffer), "Stale link \"%s\"",
+ g_snprintf (buffer, sizeof (buffer), "Stale link \"%s\"",
current_link->linkname);
c_in = current_link->filename;
in_row = current_link->line;
diff --git a/src/profile.c b/src/profile.c
index 07c201e..49871da 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -359,7 +359,7 @@ int GetPrivateProfileInt (const char * AppName, const char * KeyName, int Defaul
char IntBuf [BUF_TINY];
char buf [BUF_TINY];
- snprintf (buf, sizeof (buf), "%d", Default);
+ g_snprintf (buf, sizeof (buf), "%d", Default);
/* Check the exact semantic with the SDK */
GetPrivateProfileString (AppName, KeyName, buf, IntBuf, BUF_TINY, File);
diff --git a/src/screen.c b/src/screen.c
index 369f1fd..9810287 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -213,7 +213,7 @@ static void format_device_number (char *buf, size_t bufsize, dev_t dev)
g_assert(bufsize >= 1);
if (major_digits + 1 + minor_digits + 1 <= bufsize) {
- snprintf(buf, bufsize, "%lu,%lu", (unsigned long) major_dev,
+ g_snprintf(buf, bufsize, "%lu,%lu", (unsigned long) major_dev,
(unsigned long) minor_dev);
} else {
g_strlcpy(buf, _("[dev]"), bufsize);
@@ -338,7 +338,7 @@ string_file_perm_octal (file_entry *fe, int len)
{
static char buffer [10];
- snprintf (buffer, sizeof (buffer), "0%06lo", (unsigned long) fe->st.st_mode);
+ g_snprintf (buffer, sizeof (buffer), "0%06lo", (unsigned long) fe->st.st_mode);
return buffer;
}
@@ -348,7 +348,7 @@ string_file_nlinks (file_entry *fe, int len)
{
static char buffer[BUF_TINY];
- snprintf (buffer, sizeof (buffer), "%16d", (int) fe->st.st_nlink);
+ g_snprintf (buffer, sizeof (buffer), "%16d", (int) fe->st.st_nlink);
return buffer;
}
@@ -358,7 +358,7 @@ string_inode (file_entry *fe, int len)
{
static char buffer [10];
- snprintf (buffer, sizeof (buffer), "%lu",
+ g_snprintf (buffer, sizeof (buffer), "%lu",
(unsigned long) fe->st.st_ino);
return buffer;
}
@@ -369,7 +369,7 @@ string_file_nuid (file_entry *fe, int len)
{
static char buffer [10];
- snprintf (buffer, sizeof (buffer), "%lu",
+ g_snprintf (buffer, sizeof (buffer), "%lu",
(unsigned long) fe->st.st_uid);
return buffer;
}
@@ -380,7 +380,7 @@ string_file_ngid (file_entry *fe, int len)
{
static char buffer [10];
- snprintf (buffer, sizeof (buffer), "%lu",
+ g_snprintf (buffer, sizeof (buffer), "%lu",
(unsigned long) fe->st.st_gid);
return buffer;
}
@@ -687,11 +687,11 @@ display_mini_info (WPanel *panel)
* This is a trick to use two ngettext() calls in one sentence.
* First make "N bytes", then insert it into "X in M files".
*/
- snprintf(b_bytes, sizeof (b_bytes),
+ g_snprintf(b_bytes, sizeof (b_bytes),
ngettext("%s byte", "%s bytes",
(unsigned long)panel->total),
size_trunc_sep(panel->total));
- snprintf(buffer, sizeof (buffer),
+ g_snprintf(buffer, sizeof (buffer),
ngettext("%s in %d file", "%s in %d files", panel->marked),
b_bytes, panel->marked);
diff --git a/src/selcodepage.c b/src/selcodepage.c
index 4959882..4f7fa3e 100644
--- a/src/selcodepage.c
+++ b/src/selcodepage.c
@@ -62,12 +62,12 @@ select_charset (int current_charset, int seldisplay)
/* insert all the items found */
for (i = 0; i < n_codepages; i++) {
char *name = codepages[i].name;
- snprintf (buffer, sizeof (buffer), "%c %s", get_hotkey (i),
+ g_snprintf (buffer, sizeof (buffer), "%c %s", get_hotkey (i),
name);
LISTBOX_APPEND_TEXT (listbox, get_hotkey (i), buffer, NULL);
}
if (seldisplay) {
- snprintf (buffer, sizeof (buffer), "%c %s",
+ g_snprintf (buffer, sizeof (buffer), "%c %s",
get_hotkey (n_codepages), _("Other 8 bit"));
LISTBOX_APPEND_TEXT (listbox, get_hotkey (n_codepages), buffer,
NULL);
diff --git a/src/setup.c b/src/setup.c
index d46c408..8e6ae1d 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -246,11 +246,11 @@ panel_save_setup (struct WPanel *panel, const char *section)
char buffer [BUF_TINY];
int i;
- snprintf (buffer, sizeof (buffer), "%d", panel->reverse);
+ g_snprintf (buffer, sizeof (buffer), "%d", panel->reverse);
save_string (section, "reverse", buffer, profile_name);
- snprintf (buffer, sizeof (buffer), "%d", panel->case_sensitive);
+ g_snprintf (buffer, sizeof (buffer), "%d", panel->case_sensitive);
save_string (section, "case_sensitive", buffer, profile_name);
- snprintf (buffer, sizeof (buffer), "%d", panel->exec_first);
+ g_snprintf (buffer, sizeof (buffer), "%d", panel->exec_first);
save_string (section, "exec_first", buffer, profile_name);
for (i = 0; sort_names [i].key; i++)
if (sort_names [i].sort_type == (sortfn *) panel->sort_type){
@@ -269,12 +269,12 @@ panel_save_setup (struct WPanel *panel, const char *section)
panel->user_format, profile_name);
for (i = 0; i < LIST_TYPES; i++){
- snprintf (buffer, sizeof (buffer), "user_status%d", i);
+ g_snprintf (buffer, sizeof (buffer), "user_status%d", i);
save_string (section, buffer,
panel->user_status_format [i], profile_name);
}
- snprintf (buffer, sizeof (buffer), "%d", panel->user_mini_status);
+ g_snprintf (buffer, sizeof (buffer), "%d", panel->user_mini_status);
save_string (section, "user_mini_status", buffer,
profile_name);
}
@@ -290,7 +290,7 @@ save_layout (void)
/* Save integer options */
for (i = 0; layout [i].opt_name; i++){
- snprintf (buffer, sizeof (buffer), "%d", *layout [i].opt_addr);
+ g_snprintf (buffer, sizeof (buffer), "%d", *layout [i].opt_addr);
save_string ("Layout", layout [i].opt_name, buffer, profile);
}
@@ -420,7 +420,7 @@ panel_load_setup (WPanel *panel, const char *section)
profile_name));
for (i = 0; i < LIST_TYPES; i++){
g_free (panel->user_status_format [i]);
- snprintf (buffer, sizeof (buffer), "user_status%d", i);
+ g_snprintf (buffer, sizeof (buffer), "user_status%d", i);
panel->user_status_format [i] =
mhl_str_dup (get_profile_string (section, buffer,
DEFAULT_USER_FORMAT, profile_name));
diff --git a/src/slint.c b/src/slint.c
index a3b63eb..5945b42 100644
--- a/src/slint.c
+++ b/src/slint.c
@@ -246,10 +246,10 @@ slang_reset_softkeys (void)
char tmp[BUF_SMALL];
for (key = 1; key < 9; key++) {
- snprintf (tmp, sizeof (tmp), "k%d", key);
+ g_snprintf (tmp, sizeof (tmp), "k%d", key);
send = (char *) SLtt_tgetstr (tmp);
if (send) {
- snprintf (tmp, sizeof (tmp), "\033&f%dk%dd%dL%s%s", key,
+ g_snprintf (tmp, sizeof (tmp), "\033&f%dk%dd%dL%s%s", key,
(int) (sizeof (display) - 1), (int) strlen (send),
display, send);
SLtt_write_string (tmp);
diff --git a/src/subshell.c b/src/subshell.c
index f336602..fe2ae68 100644
--- a/src/subshell.c
+++ b/src/subshell.c
@@ -230,7 +230,7 @@ init_subshell_child (const char *pty_name)
mc_sid = getsid (0);
if (mc_sid != -1) {
char sid_str[BUF_SMALL];
- snprintf (sid_str, sizeof (sid_str), "MC_SID=%ld",
+ g_snprintf (sid_str, sizeof (sid_str), "MC_SID=%ld",
(long) mc_sid);
putenv (g_strdup (sid_str));
}
@@ -423,7 +423,7 @@ init_subshell (void)
/* Create a pipe for receiving the subshell's CWD */
if (subshell_type == TCSH) {
- snprintf (tcsh_fifo, sizeof (tcsh_fifo), "%s/mc.pipe.%d",
+ g_snprintf (tcsh_fifo, sizeof (tcsh_fifo), "%s/mc.pipe.%d",
mc_tmpdir (), (int) getpid ());
if (mkfifo (tcsh_fifo, 0600) == -1) {
fprintf (stderr, "mkfifo(%s) failed: %s\r\n", tcsh_fifo,
@@ -471,19 +471,19 @@ init_subshell (void)
switch (subshell_type) {
case BASH:
- snprintf (precmd, sizeof (precmd),
+ g_snprintf (precmd, sizeof (precmd),
" PROMPT_COMMAND='pwd>&%d;kill -STOP $$'\n",
subshell_pipe[WRITE]);
break;
case ZSH:
- snprintf (precmd, sizeof (precmd),
+ g_snprintf (precmd, sizeof (precmd),
" precmd(){ pwd>&%d;kill -STOP $$ }\n",
subshell_pipe[WRITE]);
break;
case TCSH:
- snprintf (precmd, sizeof (precmd),
+ g_snprintf (precmd, sizeof (precmd),
"set echo_style=both;"
"alias precmd 'echo $cwd:q >>%s;kill -STOP $$'\n",
tcsh_fifo);
diff --git a/src/tree.c b/src/tree.c
index 580cfc4..f4e7cee 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -597,7 +597,7 @@ static void tree_copy (WTree *tree, const char *default_dest)
if (!tree->selected_ptr)
return;
- snprintf (cmd_buf, sizeof(cmd_buf), _("Copy \"%s\" directory to:"),
+ g_snprintf (cmd_buf, sizeof(cmd_buf), _("Copy \"%s\" directory to:"),
name_trunc (tree->selected_ptr->name, 50));
dest = input_expand_dialog (_(" Copy "), cmd_buf, MC_HISTORY_FM_TREE_COPY, default_dest);
@@ -640,7 +640,7 @@ static void tree_move (WTree *tree, const char *default_dest)
if (!tree->selected_ptr)
return;
- snprintf (cmd_buf, sizeof (cmd_buf), _("Move \"%s\" directory to:"),
+ g_snprintf (cmd_buf, sizeof (cmd_buf), _("Move \"%s\" directory to:"),
name_trunc (tree->selected_ptr->name, 50));
dest = input_expand_dialog (_(" Move "), cmd_buf, MC_HISTORY_FM_TREE_MOVE, default_dest);
if (!dest)
diff --git a/src/util.c b/src/util.c
index ea647f0..3b8d934 100644
--- a/src/util.c
+++ b/src/util.c
@@ -291,7 +291,7 @@ size_trunc (double size)
xtra = "M";
}
}
- snprintf (x, sizeof (x), "%.0f%s", (size/divisor), xtra);
+ g_snprintf (x, sizeof (x), "%.0f%s", (size/divisor), xtra);
return x;
}
@@ -350,18 +350,18 @@ size_trunc_len (char *buffer, int len, off_t size, int units)
if (size == 0) {
if (j == units) {
/* Empty files will print "0" even with minimal width. */
- snprintf (buffer, len + 1, "0");
+ g_snprintf (buffer, len + 1, "0");
break;
}
/* Use "~K" or just "K" if len is 1. Use "B" for bytes. */
- snprintf (buffer, len + 1, (len > 1) ? "~%s" : "%s",
+ g_snprintf (buffer, len + 1, (len > 1) ? "~%s" : "%s",
(j > 1) ? suffix[j - 1] : "B");
break;
}
if (size < power10 [len - (j > 0)]) {
- snprintf (buffer, len + 1, "%lu%s", (unsigned long) size, suffix[j]);
+ g_snprintf (buffer, len + 1, "%lu%s", (unsigned long) size, suffix[j]);
break;
}
@@ -635,7 +635,7 @@ set_int (const char *file, const char *key, int value)
{
char buffer [BUF_TINY];
- snprintf (buffer, sizeof (buffer), "%d", value);
+ g_snprintf (buffer, sizeof (buffer), "%d", value);
return WritePrivateProfileString (app_text, key, buffer, file);
}
@@ -851,11 +851,11 @@ unix_error_string (int error_num)
gchar *strerror_currentlocale;
strerror_currentlocale = g_locale_from_utf8(g_strerror (error_num), -1, NULL, NULL, NULL);
- snprintf (buffer, sizeof (buffer), "%s (%d)",
+ g_snprintf (buffer, sizeof (buffer), "%s (%d)",
strerror_currentlocale, error_num);
g_free(strerror_currentlocale);
#else
- snprintf (buffer, sizeof (buffer), "%s (%d)",
+ g_snprintf (buffer, sizeof (buffer), "%s (%d)",
g_strerror (error_num), error_num);
#endif
return buffer;
diff --git a/src/utilunix.c b/src/utilunix.c
index 213ea6d..1a778b0 100644
--- a/src/utilunix.c
+++ b/src/utilunix.c
@@ -97,7 +97,7 @@ char *get_owner (int uid)
return pwd->pw_name;
}
else {
- snprintf (ibuf, sizeof (ibuf), "%d", uid);
+ g_snprintf (ibuf, sizeof (ibuf), "%d", uid);
return ibuf;
}
}
@@ -117,7 +117,7 @@ char *get_group (int gid)
i_cache_add (gid, gid_cache, GID_CACHE_SIZE, grp->gr_name, &gid_last);
return grp->gr_name;
} else {
- snprintf (gbuf, sizeof (gbuf), "%d", gid);
+ g_snprintf (gbuf, sizeof (gbuf), "%d", gid);
return gbuf;
}
}
@@ -258,10 +258,10 @@ mc_tmpdir (void)
pwd = getpwuid (getuid ());
if (pwd)
- snprintf (buffer, sizeof (buffer), "%s/mc-%s", sys_tmp,
+ g_snprintf (buffer, sizeof (buffer), "%s/mc-%s", sys_tmp,
pwd->pw_name);
else
- snprintf (buffer, sizeof (buffer), "%s/mc-%lu", sys_tmp,
+ g_snprintf (buffer, sizeof (buffer), "%s/mc-%lu", sys_tmp,
(unsigned long) getuid ());
canonicalize_pathname (buffer);
@@ -310,11 +310,11 @@ mc_tmpdir (void)
if (fallback_ok) {
fprintf (stderr, _("Temporary files will be created in %s\n"),
sys_tmp);
- snprintf (buffer, sizeof (buffer), "%s", sys_tmp);
+ g_snprintf (buffer, sizeof (buffer), "%s", sys_tmp);
error = NULL;
} else {
fprintf (stderr, _("Temporary files will not be created\n"));
- snprintf (buffer, sizeof (buffer), "%s", "/dev/null/");
+ g_snprintf (buffer, sizeof (buffer), "%s", "/dev/null/");
}
fprintf (stderr, "%s\n", _("Press any key to continue..."));
diff --git a/src/view.c b/src/view.c
index d83f00f..f58b263 100644
--- a/src/view.c
+++ b/src/view.c
@@ -1519,7 +1519,7 @@ view_load (WView *view, const char *command, const char *file,
} else if (file != NULL && file[0] != '\0') {
/* Open the file */
if ((fd = mc_open (file, O_RDONLY | O_NONBLOCK)) == -1) {
- snprintf (tmp, sizeof (tmp), _(" Cannot open \"%s\"\n %s "),
+ g_snprintf (tmp, sizeof (tmp), _(" Cannot open \"%s\"\n %s "),
file, unix_error_string (errno));
view_show_error (view, tmp);
goto finish;
@@ -1528,7 +1528,7 @@ view_load (WView *view, const char *command, const char *file,
/* Make sure we are working with a regular file */
if (mc_fstat (fd, &st) == -1) {
mc_close (fd);
- snprintf (tmp, sizeof (tmp), _(" Cannot stat \"%s\"\n %s "),
+ g_snprintf (tmp, sizeof (tmp), _(" Cannot stat \"%s\"\n %s "),
file, unix_error_string (errno));
view_show_error (view, tmp);
goto finish;
@@ -1744,7 +1744,7 @@ view_display_ruler (WView *view)
}
if ((cl != 0) && (cl % 10) == 0) {
- snprintf (r_buff, sizeof (r_buff), "%"OFFSETTYPE_PRId, cl);
+ g_snprintf (r_buff, sizeof (r_buff), "%"OFFSETTYPE_PRId, cl);
if (nums_row < height) {
widget_move (view, top + nums_row, left + c - 1);
tty_print_string (r_buff);
@@ -1792,7 +1792,7 @@ view_display_hex (WView *view)
col = 0;
/* Print the hex offset */
- snprintf (hex_buff, sizeof (hex_buff), "%08"OFFSETTYPE_PRIX" ", from);
+ g_snprintf (hex_buff, sizeof (hex_buff), "%08"OFFSETTYPE_PRIX" ", from);
widget_move (view, top + row, left);
tty_setcolor (MARKED_COLOR);
for (i = 0; col < width && hex_buff[i] != '\0'; i++) {
@@ -2734,7 +2734,7 @@ view_moveto_line_cmd (WView *view)
view_offset_to_coord (view, &line, &col, view->dpy_start);
- snprintf (prompt, sizeof (prompt),
+ g_snprintf (prompt, sizeof (prompt),
_(" The current line number is %d.\n"
" Enter the new line number:"), (int) (line + 1));
answer = input_dialog (_(" Goto line "), prompt, MC_HISTORY_VIEW_GOTO_LINE, "");
@@ -2755,7 +2755,7 @@ view_moveto_addr_cmd (WView *view)
char *line, *error, prompt[BUF_SMALL];
offset_type addr;
- snprintf (prompt, sizeof (prompt),
+ g_snprintf (prompt, sizeof (prompt),
_(" The current address is 0x%lx.\n"
" Enter the new address:"), view->hex_cursor);
line = input_dialog (_(" Goto Address "), prompt, MC_HISTORY_VIEW_GOTO_ADDR, "");
diff --git a/src/widget.c b/src/widget.c
index 909a6c1..3b209ad 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -159,15 +159,15 @@ button_callback (Widget *w, widget_msg_t msg, int parm)
switch (b->flags) {
case DEFPUSH_BUTTON:
- snprintf (buf, sizeof (buf), "[< %s >]", b->text);
+ g_snprintf (buf, sizeof (buf), "[< %s >]", b->text);
off = 3;
break;
case NORMAL_BUTTON:
- snprintf (buf, sizeof (buf), "[ %s ]", b->text);
+ g_snprintf (buf, sizeof (buf), "[ %s ]", b->text);
off = 2;
break;
case NARROW_BUTTON:
- snprintf (buf, sizeof (buf), "[%s]", b->text);
+ g_snprintf (buf, sizeof (buf), "[%s]", b->text);
off = 1;
break;
case HIDDEN_BUTTON:
@@ -872,7 +872,7 @@ history_get (const char *input_name)
for (i = 0;; i++) {
char key_name[BUF_TINY];
char this_entry[BUF_LARGE];
- snprintf (key_name, sizeof (key_name), "%d", i);
+ g_snprintf (key_name, sizeof (key_name), "%d", i);
GetPrivateProfileString (input_name, key_name, "", this_entry,
sizeof (this_entry), profile);
if (!*this_entry)
@@ -936,7 +936,7 @@ history_put (const char *input_name, GList *h)
/* We shouldn't have null entries, but let's be sure */
if (text && *text) {
char key_name[BUF_TINY];
- snprintf (key_name, sizeof (key_name), "%d", i++);
+ g_snprintf (key_name, sizeof (key_name), "%d", i++);
WritePrivateProfileString (input_name, key_name, text,
profile);
}
diff --git a/vfs/fish.c b/vfs/fish.c
index cd607fb..06cf483 100644
--- a/vfs/fish.c
+++ b/vfs/fish.c
@@ -228,7 +228,7 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
if (SUP.flags > FISH_FLAG_RSH)
{
argv[i++] = "-p";
- snprintf (gbuf, sizeof (gbuf), "%d", SUP.flags);
+ g_snprintf (gbuf, sizeof (gbuf), "%d", SUP.flags);
argv[i++] = gbuf;
}
@@ -907,7 +907,7 @@ static int
fish_chmod (struct vfs_class *me, const char *path, int mode)
{
PREFIX
- snprintf(buf, sizeof(buf), "#CHMOD %4.4o /%s\n"
+ g_snprintf(buf, sizeof(buf), "#CHMOD %4.4o /%s\n"
"chmod %4.4o /%s 2>/dev/null\n"
"echo '### 000'\n",
mode & 07777, rpath.s,
@@ -934,7 +934,7 @@ static int fish_##name (struct vfs_class *me, const char *path1, const char *pat
g_free (mpath1); \
SHELL_ESCAPED_STR rpath2 = mhl_shell_escape_dup (crpath2); \
g_free (mpath2); \
- snprintf(buf, sizeof(buf), string "\n", rpath1.s, rpath2.s, rpath1.s, rpath2.s); \
+ g_snprintf(buf, sizeof(buf), string "\n", rpath1.s, rpath2.s, rpath1.s, rpath2.s); \
g_free (rpath1.s); \
g_free (rpath2.s); \
return fish_send_command(me, super2, buf, OPT_FLUSH); \
@@ -952,7 +952,7 @@ static int fish_symlink (struct vfs_class *me, const char *setto, const char *pa
SHELL_ESCAPED_STR qsetto;
PREFIX
qsetto = mhl_shell_escape_dup (setto);
- snprintf(buf, sizeof(buf),
+ g_snprintf(buf, sizeof(buf),
"#SYMLINK %s /%s\n"
"ln -s %s /%s 2>/dev/null\n"
"echo '### 000'\n",
@@ -978,7 +978,7 @@ fish_chown (struct vfs_class *me, const char *path, int owner, int group)
sgroup = gr->gr_name;
{
PREFIX
- snprintf (buf, sizeof(buf),
+ g_snprintf (buf, sizeof(buf),
"#CHOWN %s /%s\n"
"chown %s /%s 2>/dev/null\n"
"echo '### 000'\n",
@@ -986,7 +986,7 @@ fish_chown (struct vfs_class *me, const char *path, int owner, int group)
sowner, rpath.s);
fish_send_command (me, super, buf, OPT_FLUSH);
/* FIXME: what should we report if chgrp succeeds but chown fails? */
- snprintf (buf, sizeof(buf),
+ g_snprintf (buf, sizeof(buf),
"#CHGRP /%s \"/%s\"\n"
"chgrp %s \"/%s\" 2>/dev/null\n"
"echo '### 000'\n",
@@ -1000,7 +1000,7 @@ fish_chown (struct vfs_class *me, const char *path, int owner, int group)
static int fish_unlink (struct vfs_class *me, const char *path)
{
PREFIX
- snprintf(buf, sizeof(buf),
+ g_snprintf(buf, sizeof(buf),
"#DELE /%s\n"
"rm -f /%s 2>/dev/null\n"
"echo '### 000'\n",
@@ -1014,7 +1014,7 @@ static int fish_mkdir (struct vfs_class *me, const char *path, mode_t mode)
(void) mode;
- snprintf(buf, sizeof(buf),
+ g_snprintf(buf, sizeof(buf),
"#MKD /%s\n"
"mkdir /%s 2>/dev/null\n"
"echo '### 000'\n",
@@ -1025,7 +1025,7 @@ static int fish_mkdir (struct vfs_class *me, const char *path, mode_t mode)
static int fish_rmdir (struct vfs_class *me, const char *path)
{
PREFIX
- snprintf(buf, sizeof(buf),
+ g_snprintf(buf, sizeof(buf),
"#RMD /%s\n"
"rmdir /%s 2>/dev/null\n"
"echo '### 000'\n",
@@ -1084,7 +1084,7 @@ fish_fill_names (struct vfs_class *me, fill_names_f func)
if (SUP.flags > FISH_FLAG_RSH)
{
break;
- snprintf (gbuf, sizeof (gbuf), ":%d", SUP.flags);
+ g_snprintf (gbuf, sizeof (gbuf), ":%d", SUP.flags);
flags = gbuf;
}
break;
diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c
index 796e7df..f1d9f75 100644
--- a/vfs/ftpfs.c
+++ b/vfs/ftpfs.c
@@ -1529,7 +1529,7 @@ static int ftpfs_chmod (struct vfs_class *me, const char *path, int mode)
{
char buf[BUF_SMALL];
- snprintf(buf, sizeof(buf), "SITE CHMOD %4.4o /%%s", mode & 07777);
+ g_snprintf(buf, sizeof(buf), "SITE CHMOD %4.4o /%%s", mode & 07777);
return ftpfs_send_command(me, path, buf, OPT_FLUSH);
}
diff --git a/vfs/mcfs.c b/vfs/mcfs.c
index 27a0cfb..884c523 100644
--- a/vfs/mcfs.c
+++ b/vfs/mcfs.c
@@ -975,8 +975,8 @@ mcfs_utime (struct vfs_class *me, const char *path, struct utimbuf *times)
atime = (long) times->actime;
mtime = (long) times->modtime;
- snprintf (abuf, sizeof (abuf), "%lx", atime);
- snprintf (mbuf, sizeof (mbuf), "%lx", mtime);
+ g_snprintf (abuf, sizeof (abuf), "%lx", atime);
+ g_snprintf (mbuf, sizeof (mbuf), "%lx", mtime);
rpc_send (mc->sock, RPC_INT, MC_UTIME,
RPC_STRING, file,
diff --git a/vfs/undelfs.c b/vfs/undelfs.c
index 3a4c3d8..718238f 100644
--- a/vfs/undelfs.c
+++ b/vfs/undelfs.c
@@ -370,7 +370,7 @@ undelfs_readdir(void *vfs_info)
if (readdir_ptr < 0)
strcpy (dirent_dest, readdir_ptr == -2 ? "." : "..");
else
- snprintf(dirent_dest, MC_MAXPATHLEN, "%ld:%d",
+ g_snprintf(dirent_dest, MC_MAXPATHLEN, "%ld:%d",
(long) delarray[readdir_ptr].ino,
delarray[readdir_ptr].num_blocks);
readdir_ptr++;
--
Midnight Commander Development
More information about the mc-devel
mailing list