freetype-devel
[Top][All Lists]
Advanced

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

Re: [Devel] new error scheme


From: David Turner
Subject: Re: [Devel] new error scheme
Date: Fri, 15 Jun 2001 14:28:20 +0200

Hi Werner,

> 
> I've answered too quickly: Why does it break source compatibility?
> The order of errors previously defined in fterrors.h hasn't changed.
> The only difference is that the enumeration (or array) is now larger,
> containing values above 0x70.  Am I missing something?
>

OK, the main problem is that the "FT_" prefix has disappeared from
the error code constants definitions. This breaks the following code
that is part of Pango, for example:

Of course, it's trivial to change Pango to adjust to the new scheme,
but it'd be nice not to break compatibility for applications that
rely on the 2.0.x sources yet..

Cheers,

- David

---------------------------------------------------------------------------
typedef struct
{
  FT_Error     code;
  const char*  msg;
} ft_error_description;

static int
ft_error_compare (const void *pkey,
                  const void *pbase)
{
  return ((ft_error_description *) pkey)->code - ((ft_error_description *) 
pbase)->code;
}

const char *
pango_ft2_ft_strerror (FT_Error error)
{
#undef __FTERRORS_H__
#define FT_ERRORDEF( e, v, s )  { e, s },
#define FT_ERROR_START_LIST  {
#define FT_ERROR_END_LIST    { 0, 0 } };

  const ft_error_description ft_errors[] =
#include FT_ERRORS_H

#undef FT_ERRORDEF
#undef FT_ERROR_START_LIST
#undef FT_ERROR_END_LIST

  ft_error_description *found =
    bsearch (&error, ft_errors, G_N_ELEMENTS (ft_errors) - 1,
             sizeof (ft_errors[0]), ft_error_compare);
  if (found != NULL)
    return found->msg;
  else
    {
      static char default_msg[100];

      sprintf (default_msg, "Unknown FreeType2 error %#x", error);
      return default_msg;
    }
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]