X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Futils.c;h=a6c84491605517a8f0af7637ff681c70e943340f;hp=85a83355a6ace521faf8b84a283a20f3ae2c0fe7;hb=e72b57629bf49cdfd663002a8bb336a67b958979;hpb=1ddd88d7c5c32446cc6f8ea2ec4d97eba72bfb28 diff --git a/src/utils.c b/src/utils.c index 85a83355..a6c84491 100644 --- a/src/utils.c +++ b/src/utils.c @@ -88,6 +88,32 @@ as that of the covered work. */ #include "test.h" #endif +static void +memfatal (const char *context, long attempted_size) +{ + /* Make sure we don't try to store part of the log line, and thus + call malloc. */ + log_set_save_context (false); + + /* We have different log outputs in different situations: + 1) output without bytes information + 2) output with bytes information */ + if (attempted_size == UNKNOWN_ATTEMPTED_SIZE) + { + logprintf (LOG_ALWAYS, + _("%s: %s: Failed to allocate enough memory; memory exhausted.\n"), + exec_name, context); + } + else + { + logprintf (LOG_ALWAYS, + _("%s: %s: Failed to allocate %ld bytes; memory exhausted.\n"), + exec_name, context, attempted_size); + } + + exit (1); +} + /* Utility function: like xstrdup(), but also lowercases S. */ char * @@ -348,7 +374,7 @@ fork_to_background (void) /* parent, no error */ printf (_("Continuing in background, pid %d.\n"), (int) pid); if (logfile_changed) - printf (_("Output will be written to `%s'.\n"), opt.lfilename); + printf (_("Output will be written to %s.\n"), quote (opt.lfilename)); exit (0); /* #### should we use _exit()? */ } @@ -394,8 +420,8 @@ remove_link (const char *file) DEBUGP (("Unlinking %s (symlink).\n", file)); err = unlink (file); if (err != 0) - logprintf (LOG_VERBOSE, _("Failed to unlink symlink `%s': %s\n"), - file, strerror (errno)); + logprintf (LOG_VERBOSE, _("Failed to unlink symlink %s: %s\n"), + quote (file), strerror (errno)); } return err; }