Re: PATCH: Re: Gtk-CRITICAL error



Soeren Sandmann wrote:
> 
> Soeren Sandmann <sandmann@daimi.au.dk> writes:
> 
> > "Iain" <nodatadj@webtribe.net> writes:
> >
> > > Here's a patch for gmessages.c in GLIB so that it will print out the program
> > > name everytime it prints a warning. I find it annoying whenever I return to
> >
> > Your patch makes testglib and and any other program that does not
> > use g_set_prgname crash.

maybe fixing this programs will also be good ...

> > I think it should be written like this:
> 
> Duh.
> 
> Like this:

why you don't do just only one 'if' like:

if (!prgname) then prgname = 'unknown'      (you get the idea, no?)


> --- /users/sandmann/extra/src/glib/gmessages.c  Sun Aug  1 19:55:31 1999
> +++ gmessages.c Sun Aug  1 20:35:58 1999
> @@ -423,10 +423,12 @@
>    GErrorFunc     local_glib_error_func;
>    GWarningFunc   local_glib_warning_func;
>    GPrintFunc     local_glib_message_func;
> +  gchar *prgname;
> 
>    in_recursion = (log_level & G_LOG_FLAG_RECURSION) != 0;
>    is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
>    log_level &= G_LOG_LEVEL_MASK;
> +  prgname = g_get_prgname ();
> 
>    if (!message)
>      message = "g_log_default_handler(): (NULL) message";
> @@ -457,14 +459,19 @@
>         }
>        /* use write(2) for output, in case we are out of memeory */
>        ensure_stdout_valid ();
> +      write (fd, "\n", 1);
> +      if (prgname)
> +       {
> +         write (fd, prgname, strlen (prgname));
> +         write (fd, ": ", 2);
> +       }
>        if (log_domain)
>         {
> -         write (fd, "\n", 1);
>           write (fd, log_domain, strlen (log_domain));
>           write (fd, "-", 1);
>         }
>        else
> -       write (fd, "\n** ", 4);
> +       write (fd, "** ", 3);
>        if (in_recursion)
>         write (fd, "ERROR (recursed) **: ", 21);
>        else
> @@ -477,14 +484,19 @@
>        break;
>      case G_LOG_LEVEL_CRITICAL:
>        ensure_stdout_valid ();
> +      write (fd, "\n", 1);
> +      if (prgname)
> +       {
> +         write (fd, prgname, strlen (prgname));
> +         write (fd, ": ", 2);
> +       }
>        if (log_domain)
>         {
> -         write (fd, "\n", 1);
>           write (fd, log_domain, strlen (log_domain));
>           write (fd, "-", 1);
>         }
>        else
> -       write (fd, "\n** ", 4);
> +       write (fd, "** ", 3);
>        if (in_recursion)
>         write (fd, "CRITICAL (recursed) **: ", 24);
>        else
> @@ -503,14 +515,19 @@
>           return;
>         }
>        ensure_stdout_valid ();
> +      write (fd, "\n", 1);
> +      if (prgname)
> +       {
> +         write (fd, prgname, strlen (prgname));
> +         write (fd, ": ", 2);
> +       }
>        if (log_domain)
>         {
> -         write (fd, "\n", 1);
>           write (fd, log_domain, strlen (log_domain));
>           write (fd, "-", 1);
>         }
>        else
> -       write (fd, "\n** ", 4);
> +       write (fd, "** ", 3);
>        if (in_recursion)
>         write (fd, "WARNING (recursed) **: ", 23);
>        else
> @@ -529,6 +546,11 @@
>           return;
>         }
>        ensure_stdout_valid ();
> +      if (prgname)
> +       {
> +         write (fd, prgname, strlen (prgname));
> +         write (fd, ": ", 2);
> +       }
>        if (log_domain)
>         {
>           write (fd, log_domain, strlen (log_domain));
> @@ -546,6 +568,11 @@
>        break;
>      case G_LOG_LEVEL_INFO:
>        ensure_stdout_valid ();
> +      if (prgname)
> +       {
> +         write (fd, prgname, strlen (prgname));
> +         write (fd, ": ", 2);
> +       }
>        if (log_domain)
>         {
>           write (fd, log_domain, strlen (log_domain));
> @@ -563,6 +590,11 @@
>        break;
>      case G_LOG_LEVEL_DEBUG:
>        ensure_stdout_valid ();
> +      if (prgname)
> +       {
> +         write (fd, prgname, strlen (prgname));
> +         write (fd, ": ", 2);
> +       }
>        if (log_domain)
>         {
>           write (fd, log_domain, strlen (log_domain));
> @@ -583,6 +615,11 @@
>         * try to make the best out of it.
>         */
>        ensure_stdout_valid ();
> +      if (prgname)
> +       {
> +         write (fd, prgname, strlen (prgname));
> +         write (fd, ": ", 2);
> +       }
>        if (log_domain)
>         {
>           write (fd, log_domain, strlen (log_domain));
> 
> --
>          To unsubscribe: mail gtk-devel-list-request@redhat.com with
>                        "unsubscribe" as the Subject.


-- 
  |    Sergio A. Kessler  http://sak.org.ar
-O_O-  You can have it Soon, Cheap, and Working; choose *two*.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]