Commit 2b84ce50 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

use gimp_memsize_to_string() instead of always showing bytes with a

2005-02-10  Michael Natterer  <mitch@gimp.org>

	* plug-ins/uri/uri-backend-gnomevfs.c: use gimp_memsize_to_string()
	instead of always showing bytes with a translatable %llu format
	string. Increased BUFSIZE to 4096.

	* plug-ins/uri/uri-backend-wget.c (uri_backend_load_image): don't
	leak the memsize string. Use sizeof(buf) instead of BUFSIZE.
parent 415a2005
2005-02-10 Michael Natterer <mitch@gimp.org>
* plug-ins/uri/uri-backend-gnomevfs.c: use gimp_memsize_to_string()
instead of always showing bytes with a translatable %llu format
string. Increased BUFSIZE to 4096.
* plug-ins/uri/uri-backend-wget.c (uri_backend_load_image): don't
leak the memsize string. Use sizeof(buf) instead of BUFSIZE.
2005-02-10 Michael Natterer <mitch@gimp.org>
* app/tools/gimpcroptool.c
......
......@@ -25,7 +25,7 @@
#include "libgimp/stdplugins-intl.h"
#define BUFSIZE 1024
#define BUFSIZE 4096
/* local function prototypes */
......@@ -92,8 +92,8 @@ uri_backend_load_image (const gchar *uri,
dest_uri = g_filename_to_uri (tmpname, NULL, NULL);
success = copy_uri (uri, dest_uri,
_("Downloading %llu bytes of image data..."),
_("Downloaded %llu bytes of image data"),
_("Downloading %s of image data..."),
_("Downloaded %s of image data"),
error);
g_free (dest_uri);
......@@ -111,8 +111,8 @@ uri_backend_save_image (const gchar *uri,
src_uri = g_filename_to_uri (tmpname, NULL, NULL);
success = copy_uri (src_uri, uri,
_("Uploading %llu bytes of image data..."),
_("Uploaded %llu bytes of image data"),
_("Uploading %s of image data..."),
_("Uploaded %s of image data"),
error);
g_free (src_uri);
......@@ -178,6 +178,7 @@ copy_uri (const gchar *src_uri,
GnomeVFSFileSize bytes_read = 0;
guchar buffer[BUFSIZE];
GnomeVFSResult result;
gchar *memsize;
gchar *message;
gimp_progress_init (_("Connecting to server..."));
......@@ -216,10 +217,14 @@ copy_uri (const gchar *src_uri,
return FALSE;
}
memsize = gimp_memsize_to_string (file_size);
if (file_size > 0)
message = g_strdup_printf (copying_format_str, file_size);
message = g_strdup_printf (copying_format_str, memsize);
else
message = g_strdup_printf (copied_format_str, (GnomeVFSFileSize) 0);
message = g_strdup_printf (copied_format_str, memsize);
g_free (memsize);
gimp_progress_init (message);
g_free (message);
......@@ -236,10 +241,13 @@ copy_uri (const gchar *src_uri,
{
if (result != GNOME_VFS_ERROR_EOF)
{
memsize = gimp_memsize_to_string (sizeof (buffer));
g_set_error (error, 0, 0,
_("Failed to read %d bytes from '%s': %s"),
sizeof (buffer), src_uri,
_("Failed to read %s from '%s': %s"),
memsize, src_uri,
gnome_vfs_result_to_string (result));
g_free (memsize);
gnome_vfs_close (read_handle);
gnome_vfs_close (write_handle);
return FALSE;
......@@ -259,7 +267,10 @@ copy_uri (const gchar *src_uri,
}
else
{
message = g_strdup_printf (copied_format_str, bytes_read);
memsize = gimp_memsize_to_string (bytes_read);
message = g_strdup_printf (copied_format_str, memsize);
g_free (memsize);
gimp_progress_init (message);
g_free (message);
}
......@@ -269,10 +280,13 @@ copy_uri (const gchar *src_uri,
if (chunk_written < chunk_read)
{
memsize = gimp_memsize_to_string (chunk_read);
g_set_error (error, 0, 0,
_("Failed to write %llu bytes to '%s': %s"),
chunk_read, dest_uri,
_("Failed to write %s to '%s': %s"),
memsize, dest_uri,
gnome_vfs_result_to_string (result));
g_free (memsize);
gnome_vfs_close (read_handle);
gnome_vfs_close (write_handle);
return FALSE;
......
......@@ -116,6 +116,7 @@ uri_backend_load_image (const gchar *uri,
gint kilobytes = 0;
gboolean finished = FALSE;
gboolean debug = FALSE;
gchar *memsize;
gchar *message;
gchar *timeout_msg;
gchar *progress;
......@@ -128,7 +129,7 @@ uri_backend_load_image (const gchar *uri,
/* hardcoded and not-really-foolproof scanning of wget putput */
if (fgets (buf, BUFSIZE, input) == NULL)
if (fgets (buf, sizeof (buf), input) == NULL)
{
/* no message here because failing on the first line means
* that wget was not found
......@@ -139,7 +140,7 @@ uri_backend_load_image (const gchar *uri,
DEBUG (buf);
/* The second line is the local copy of the file */
if (fgets (buf, BUFSIZE, input) == NULL)
if (fgets (buf, sizeof (buf), input) == NULL)
{
g_set_error (error, 0, 0,
_("wget exited abnormally on URI '%s'"), uri);
......@@ -158,7 +159,7 @@ uri_backend_load_image (const gchar *uri,
g_free (progress);
read_connect:
if (fgets (buf, BUFSIZE, input) == NULL)
if (fgets (buf, sizeof (buf), input) == NULL)
{
g_set_error (error, 0, 0,
_("wget exited abnormally on URI '%s'"), uri);
......@@ -183,7 +184,7 @@ uri_backend_load_image (const gchar *uri,
gimp_progress_init (progress);
g_free (progress);
if (fgets (buf, BUFSIZE, input) == NULL)
if (fgets (buf, sizeof (buf), input) == NULL)
{
g_set_error (error, 0, 0,
_("wget exited abnormally on URI '%s'"), uri);
......@@ -202,7 +203,7 @@ uri_backend_load_image (const gchar *uri,
DEBUG (buf);
/* The fifth line is either the length of the file or an error */
if (fgets (buf, BUFSIZE, input) == NULL)
if (fgets (buf, sizeof (buf), input) == NULL)
{
g_set_error (error, 0, 0,
_("wget exited abnormally on URI '%s'"), uri);
......@@ -246,14 +247,16 @@ uri_backend_load_image (const gchar *uri,
size = atoi (sizestr);
/* Start the actual download... */
message = g_strdup_printf (_("Downloading %s of image data... "),
gimp_memsize_to_string (size));
memsize = gimp_memsize_to_string (size);
message = g_strdup_printf (_("Downloading %s of image data..."),
memsize);
progress = g_strdup_printf ("%s %s", message, timeout_msg);
gimp_progress_init (progress);
g_free (progress);
g_free (message);
g_free (memsize);
/* Switch to byte parsing wget's output... */
......@@ -278,7 +281,7 @@ uri_backend_load_image (const gchar *uri,
}
else if (dot == ':') /* the time string contains a ':' */
{
fgets (buf, BUFSIZE, input);
fgets (buf, sizeof (buf), input);
DEBUG (buf);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment