~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_error.c

  • Committer: Brian Aker
  • Date: 2008-08-03 22:27:54 UTC
  • mfrom: (236.1.66 codestyle)
  • Revision ID: brian@tangent.org-20080803222754-yhkw8plul06oqvhe
Merge from Monty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <mystrings/m_string.h>
19
19
#include <stdarg.h>
20
20
#include <mystrings/m_ctype.h>
 
21
#include <libdrizzle/gettext.h>
21
22
 
22
23
/* Define some external variables for error handling */
23
24
 
51
52
  const char            **meh_errmsgs;  /* error messages array */
52
53
  int                   meh_first;      /* error number matching array slot 0 */
53
54
  int                   meh_last;       /* error number matching last slot */
54
 
} my_errmsgs_globerrs = {NULL, globerrs, EE_ERROR_FIRST, EE_ERROR_LAST};
 
55
  bool                  is_globerrs;
 
56
} my_errmsgs_globerrs = {NULL, globerrs, EE_ERROR_FIRST, EE_ERROR_LAST, true};
55
57
 
56
58
static struct my_err_head *my_errmsgs_list= &my_errmsgs_globerrs;
57
59
 
80
82
 
81
83
  /* get the error message string. Default, if NULL or empty string (""). */
82
84
  if (! (format= (meh_p && (nr >= meh_p->meh_first)) ?
83
 
         meh_p->meh_errmsgs[nr - meh_p->meh_first] : NULL) || ! *format)
84
 
    (void) snprintf (ebuff, sizeof(ebuff), "Unknown error %d", nr);
 
85
         _(meh_p->meh_errmsgs[nr - meh_p->meh_first]) : NULL) || ! *format)
 
86
    (void) snprintf (ebuff, sizeof(ebuff), _("Unknown error %d"), nr);
85
87
  else
86
88
  {
87
89
    va_start(args,MyFlags);
166
168
  meh_p->meh_errmsgs= errmsgs;
167
169
  meh_p->meh_first= first;
168
170
  meh_p->meh_last= last;
 
171
  meh_p->is_globerrs= false;
169
172
 
170
173
  /* Search for the right position in the list. */
171
174
  for (search_meh_pp= &my_errmsgs_list;
235
238
 
236
239
  /* Save the return value and free the header. */
237
240
  errmsgs= meh_p->meh_errmsgs;
 
241
  bool is_globerrs= meh_p->is_globerrs;
 
242
 
238
243
  my_free((uchar*) meh_p, MYF(0));
 
244
 
 
245
  if (is_globerrs)
 
246
    return NULL;
239
247
  
240
248
  return errmsgs;
241
249
}