mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Fix of uintmax_t variables output.
Use PRIuMAX and PRIXMAX instead of ju and jX modifiers respectively for formatted output of uintmax_t variables. If PRIXMAX is not defined (i.e. in Solaris9), use PRIxMAX instead. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
6e6ec057cb
commit
fe8c5390ad
@ -64,6 +64,11 @@
|
|||||||
#define __attribute__(x)
|
#define __attribute__(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Solaris9 doesn't have PRIXMAX */
|
||||||
|
#ifndef PRIXMAX
|
||||||
|
#define PRIXMAX PRIxMAX
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#define _(String) gettext (String)
|
#define _(String) gettext (String)
|
||||||
|
@ -437,7 +437,7 @@ size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gbool
|
|||||||
|
|
||||||
if (size < power10[len - (j > 0)])
|
if (size < power10[len - (j > 0)])
|
||||||
{
|
{
|
||||||
g_snprintf (buffer, len + 1, "%ju%s", size, use_si ? suffix_lc[j] : suffix[j]);
|
g_snprintf (buffer, len + 1, "%" PRIuMAX "%s", size, use_si ? suffix_lc[j] : suffix[j]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1341,7 +1341,7 @@ save_file_position (const char *filename, long line, long column, off_t offset,
|
|||||||
/* put the new record */
|
/* put the new record */
|
||||||
if (line != 1 || column != 0 || bookmarks != NULL)
|
if (line != 1 || column != 0 || bookmarks != NULL)
|
||||||
{
|
{
|
||||||
if (fprintf (f, "%s %ld;%ld;%ju", filename, line, column, offset) < 0)
|
if (fprintf (f, "%s %ld;%ld;%" PRIuMAX, filename, line, column, (uintmax_t) offset) < 0)
|
||||||
goto write_position_error;
|
goto write_position_error;
|
||||||
if (bookmarks != NULL)
|
if (bookmarks != NULL)
|
||||||
for (i = 0; i < bookmarks->len && i < MAX_SAVED_BOOKMARKS; i++)
|
for (i = 0; i < bookmarks->len && i < MAX_SAVED_BOOKMARKS; i++)
|
||||||
|
@ -703,15 +703,17 @@ vfs_s_print_stats (const char *fs_name, const char *action,
|
|||||||
|
|
||||||
if (i18n_percent_transf_format == NULL)
|
if (i18n_percent_transf_format == NULL)
|
||||||
{
|
{
|
||||||
i18n_percent_transf_format = _("%s: %s: %s %3d%% (%ju bytes transferred)");
|
i18n_percent_transf_format = "%s: %s: %s %3d%% (%" PRIuMAX " %s";
|
||||||
i18n_transf_format = _("%s: %s: %s %ju bytes transferred");
|
i18n_transf_format = "%s: %s: %s %" PRIuMAX " %s";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need)
|
if (need)
|
||||||
print_vfs_message (i18n_percent_transf_format, fs_name, action,
|
print_vfs_message (i18n_percent_transf_format, fs_name, action,
|
||||||
file_name, (int) ((double) have * 100 / need), (uintmax_t) have);
|
file_name, (int) ((double) have * 100 / need), (uintmax_t) have,
|
||||||
|
_("bytes transferred"));
|
||||||
else
|
else
|
||||||
print_vfs_message (i18n_transf_format, fs_name, action, file_name, (uintmax_t) have);
|
print_vfs_message (i18n_transf_format, fs_name, action, file_name, (uintmax_t) have,
|
||||||
|
_("bytes transferred"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -884,7 +884,7 @@ fish_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *lo
|
|||||||
/* FIXME: File size is limited to ULONG_MAX */
|
/* FIXME: File size is limited to ULONG_MAX */
|
||||||
if (!fh->u.fish.append)
|
if (!fh->u.fish.append)
|
||||||
{
|
{
|
||||||
shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%ju;\n",
|
shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%" PRIuMAX ";\n",
|
||||||
SUP.scr_append, (char *) NULL);
|
SUP.scr_append, (char *) NULL);
|
||||||
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
|
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
|
||||||
(uintmax_t) s.st_size);
|
(uintmax_t) s.st_size);
|
||||||
@ -892,7 +892,7 @@ fish_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *lo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%ju;\n",
|
shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%" PRIuMAX ";\n",
|
||||||
SUP.scr_send, (char *) NULL);
|
SUP.scr_send, (char *) NULL);
|
||||||
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
|
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
|
||||||
(uintmax_t) s.st_size);
|
(uintmax_t) s.st_size);
|
||||||
@ -932,8 +932,9 @@ fish_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *lo
|
|||||||
}
|
}
|
||||||
tty_disable_interrupt_key ();
|
tty_disable_interrupt_key ();
|
||||||
total += n;
|
total += n;
|
||||||
print_vfs_message (_("fish: storing %s %d (%ju)"),
|
print_vfs_message ("%s: %d/%" PRIuMAX,
|
||||||
was_error ? _("zeros") : _("file"), total, (uintmax_t) s.st_size);
|
was_error ? _("fish: storing zeros") : _("fish: storing file"),
|
||||||
|
total, (uintmax_t) s.st_size);
|
||||||
}
|
}
|
||||||
close (h);
|
close (h);
|
||||||
g_free (quoted_name);
|
g_free (quoted_name);
|
||||||
@ -971,7 +972,7 @@ fish_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset)
|
|||||||
* standard output (i.e. over the network).
|
* standard output (i.e. over the network).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_START_OFFSET=%ju;\n",
|
shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_START_OFFSET=%" PRIuMAX ";\n",
|
||||||
SUP.scr_get, (char *) NULL);
|
SUP.scr_get, (char *) NULL);
|
||||||
offset = fish_command (me, super, WANT_STRING, shell_commands, quoted_name, (uintmax_t) offset);
|
offset = fish_command (me, super, WANT_STRING, shell_commands, quoted_name, (uintmax_t) offset);
|
||||||
g_free (shell_commands);
|
g_free (shell_commands);
|
||||||
|
@ -1827,8 +1827,8 @@ ftpfs_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *l
|
|||||||
w_buf += n_written;
|
w_buf += n_written;
|
||||||
n_read -= n_written;
|
n_read -= n_written;
|
||||||
}
|
}
|
||||||
print_vfs_message (_("ftpfs: storing file %ju (%ju)"),
|
print_vfs_message ("%s: %" PRIuMAX "/%" PRIuMAX,
|
||||||
(uintmax_t) n_stored, (uintmax_t) s.st_size);
|
_("ftpfs: storing file"), (uintmax_t) n_stored, (uintmax_t) s.st_size);
|
||||||
}
|
}
|
||||||
tty_disable_interrupt_key ();
|
tty_disable_interrupt_key ();
|
||||||
close (sock);
|
close (sock);
|
||||||
|
@ -228,7 +228,9 @@ mcview_ccache_dump (mcview_t * view)
|
|||||||
for (i = 0; i < cache->size; i++)
|
for (i = 0; i < cache->size; i++)
|
||||||
{
|
{
|
||||||
(void) fprintf (f,
|
(void) fprintf (f,
|
||||||
"entry %8u offset %8ju line %8ju column %8ju nroff_column %8ju\n",
|
"entry %8u offset %8" PRIuMAX
|
||||||
|
" line %8" PRIuMAX " column %8" PRIuMAX
|
||||||
|
" nroff_column %8" PRIuMAX "\n",
|
||||||
(unsigned int) i,
|
(unsigned int) i,
|
||||||
(uintmax_t) cache->cache[i]->cc_offset,
|
(uintmax_t) cache->cache[i]->cc_offset,
|
||||||
(uintmax_t) cache->cache[i]->cc_line,
|
(uintmax_t) cache->cache[i]->cc_line,
|
||||||
@ -242,7 +244,7 @@ mcview_ccache_dump (mcview_t * view)
|
|||||||
{
|
{
|
||||||
mcview_offset_to_coord (view, &line, &column, offset);
|
mcview_offset_to_coord (view, &line, &column, offset);
|
||||||
(void) fprintf (f,
|
(void) fprintf (f,
|
||||||
"offset %8ju line %8ju column %8ju\n",
|
"offset %8" PRIuMAX " line %8" PRIuMAX " column %8" PRIuMAX "\n",
|
||||||
(uintmax_t) offset, (uintmax_t) line, (uintmax_t) column);
|
(uintmax_t) offset, (uintmax_t) line, (uintmax_t) column);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +252,7 @@ mcview_ccache_dump (mcview_t * view)
|
|||||||
for (line = 0; TRUE; line++)
|
for (line = 0; TRUE; line++)
|
||||||
{
|
{
|
||||||
mcview_coord_to_offset (view, &nextline_offset, line + 1, 0);
|
mcview_coord_to_offset (view, &nextline_offset, line + 1, 0);
|
||||||
(void) fprintf (f, "nextline_offset %8ju\n", (uintmax_t) nextline_offset);
|
(void) fprintf (f, "nextline_offset %8" PRIuMAX "\n", (uintmax_t) nextline_offset);
|
||||||
|
|
||||||
for (column = 0; TRUE; column++)
|
for (column = 0; TRUE; column++)
|
||||||
{
|
{
|
||||||
@ -259,7 +261,7 @@ mcview_ccache_dump (mcview_t * view)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
(void) fprintf (f,
|
(void) fprintf (f,
|
||||||
"line %8ju column %8ju offset %8ju\n",
|
"line %8" PRIuMAX " column %8" PRIuMAX " offset %8" PRIuMAX "\n",
|
||||||
(uintmax_t) line, (uintmax_t) column, (uintmax_t) offset);
|
(uintmax_t) line, (uintmax_t) column, (uintmax_t) offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,11 +150,11 @@ mcview_display_status (mcview_t * view)
|
|||||||
char buffer[BUF_TINY];
|
char buffer[BUF_TINY];
|
||||||
widget_move (view, top, width - 32);
|
widget_move (view, top, width - 32);
|
||||||
if (view->hex_mode)
|
if (view->hex_mode)
|
||||||
tty_printf ("0x%08jx", (uintmax_t) view->hex_cursor);
|
tty_printf ("0x%08" PRIxMAX, (uintmax_t) view->hex_cursor);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_trunc_len (buffer, 5, mcview_get_filesize (view), 0, panels_options.kilobyte_si);
|
size_trunc_len (buffer, 5, mcview_get_filesize (view), 0, panels_options.kilobyte_si);
|
||||||
tty_printf ("%9ju/%s%s %s", (uintmax_t) view->dpy_end,
|
tty_printf ("%9" PRIuMAX "/%s%s %s", (uintmax_t) view->dpy_end,
|
||||||
buffer, mcview_may_still_grow (view) ? "+" : " ",
|
buffer, mcview_may_still_grow (view) ? "+" : " ",
|
||||||
#ifdef HAVE_CHARSET
|
#ifdef HAVE_CHARSET
|
||||||
source_codepage >= 0 ? get_codepage_id (source_codepage) : ""
|
source_codepage >= 0 ? get_codepage_id (source_codepage) : ""
|
||||||
@ -375,7 +375,7 @@ mcview_display_ruler (mcview_t * view)
|
|||||||
|
|
||||||
if ((cl != 0) && (cl % 10) == 0)
|
if ((cl != 0) && (cl % 10) == 0)
|
||||||
{
|
{
|
||||||
g_snprintf (r_buff, sizeof (r_buff), "%ju", (uintmax_t) cl);
|
g_snprintf (r_buff, sizeof (r_buff), "%" PRIuMAX, (uintmax_t) cl);
|
||||||
if (nums_row < height)
|
if (nums_row < height)
|
||||||
{
|
{
|
||||||
widget_move (view, top + nums_row, left + c - 1);
|
widget_move (view, top + nums_row, left + c - 1);
|
||||||
|
@ -161,7 +161,7 @@ mcview_display_hex (mcview_t * view)
|
|||||||
col = 0;
|
col = 0;
|
||||||
|
|
||||||
/* Print the hex offset */
|
/* Print the hex offset */
|
||||||
g_snprintf (hex_buff, sizeof (hex_buff), "%08jX ", (uintmax_t) from);
|
g_snprintf (hex_buff, sizeof (hex_buff), "%08" PRIXMAX, (uintmax_t) from);
|
||||||
widget_move (view, top + row, left);
|
widget_move (view, top + row, left);
|
||||||
tty_setcolor (VIEW_BOLD_COLOR);
|
tty_setcolor (VIEW_BOLD_COLOR);
|
||||||
for (i = 0; col < width && hex_buff[i] != '\0'; i++)
|
for (i = 0; col < width && hex_buff[i] != '\0'; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user