~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/charset.cc

  • Committer: Brian Aker
  • Date: 2009-02-09 19:20:19 UTC
  • Revision ID: brian@tangent.org-20090209192019-ihmx9nwacvq9ivrn
Remove charset directory code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
}
117
117
 
118
118
 
119
 
#define MY_CHARSET_INDEX "Index.xml"
120
 
 
121
 
const char *charsets_dir= NULL;
122
119
static bool charset_initialized= false;
123
120
 
124
 
 
125
 
char *get_charsets_dir(char *buf)
126
 
{
127
 
  char *res;
128
 
 
129
 
  if (charsets_dir != NULL)
130
 
    strncpy(buf, charsets_dir, FN_REFLEN-1);
131
 
  else
132
 
  {
133
 
    if (test_if_hard_path(PKGDATADIR) ||
134
 
        is_prefix(PKGDATADIR, PREFIX))
135
 
      sprintf(buf,"%s/%s",PKGDATADIR,CHARSET_DIR);
136
 
    else
137
 
      sprintf(buf,"%s/%s/%s",PREFIX,PKGDATADIR,CHARSET_DIR);
138
 
  }
139
 
  res= convert_dirname(buf,buf,NULL);
140
 
  return(res);
141
 
}
142
 
 
143
121
CHARSET_INFO *all_charsets[256];
144
122
const CHARSET_INFO *default_charset_info = &my_charset_utf8_general_ci;
145
123
 
157
135
 
158
136
static bool init_available_charsets(myf myflags)
159
137
{
160
 
  char fname[FN_REFLEN + sizeof(MY_CHARSET_INDEX)];
161
 
  bool error=false;
 
138
  bool error= false;
162
139
  /*
163
140
    We have to use charset_initialized to not lock on THR_LOCK_charset
164
141
    inside get_internal_charset...
182
159
      }
183
160
    }
184
161
 
185
 
    strcpy(get_charsets_dir(fname), MY_CHARSET_INDEX);
186
162
    charset_initialized= true;
187
163
  }
188
164
  assert(charset_initialized);
262
238
}
263
239
 
264
240
 
265
 
const CHARSET_INFO *get_charset(uint32_t cs_number, myf flags)
 
241
const CHARSET_INFO *get_charset(uint32_t cs_number)
266
242
{
267
243
  const CHARSET_INFO *cs;
268
244
  if (cs_number == default_charset_info->number)
275
251
 
276
252
  cs= get_internal_charset(cs_number);
277
253
 
278
 
  if (!cs && (flags & MY_WME))
279
 
  {
280
 
    char index_file[FN_REFLEN + sizeof(MY_CHARSET_INDEX)], cs_string[23];
281
 
    strcpy(get_charsets_dir(index_file),MY_CHARSET_INDEX);
282
 
    cs_string[0]='#';
283
 
    int10_to_str(cs_number, cs_string+1, 10);
284
 
    my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_string, index_file);
285
 
  }
286
254
  return cs;
287
255
}
288
256
 
289
 
const CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags)
 
257
const CHARSET_INFO *get_charset_by_name(const char *cs_name)
290
258
{
291
259
  uint32_t cs_number;
292
260
  const CHARSET_INFO *cs;
295
263
  cs_number=get_collation_number(cs_name);
296
264
  cs= cs_number ? get_internal_charset(cs_number) : NULL;
297
265
 
298
 
  if (!cs && (flags & MY_WME))
299
 
  {
300
 
    char index_file[FN_REFLEN + sizeof(MY_CHARSET_INDEX)];
301
 
    strcpy(get_charsets_dir(index_file),MY_CHARSET_INDEX);
302
 
    my_error(EE_UNKNOWN_COLLATION, MYF(ME_BELL), cs_name, index_file);
303
 
  }
304
 
 
305
266
  return cs;
306
267
}
307
268
 
308
269
 
309
 
const CHARSET_INFO *get_charset_by_csname(const char *cs_name,
310
 
                                    uint32_t cs_flags,
311
 
                                    myf flags)
 
270
const CHARSET_INFO *get_charset_by_csname(const char *cs_name, uint32_t cs_flags)
312
271
{
313
272
  uint32_t cs_number;
314
273
  const CHARSET_INFO *cs;
318
277
  cs_number= get_charset_number(cs_name, cs_flags);
319
278
  cs= cs_number ? get_internal_charset(cs_number) : NULL;
320
279
 
321
 
  if (!cs && (flags & MY_WME))
322
 
  {
323
 
    char index_file[FN_REFLEN + sizeof(MY_CHARSET_INDEX)];
324
 
    strcpy(get_charsets_dir(index_file),MY_CHARSET_INDEX);
325
 
    my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_name, index_file);
326
 
  }
327
 
 
328
280
  return(cs);
329
281
}
330
282
 
349
301
                     const CHARSET_INFO *default_cs,
350
302
                     const CHARSET_INFO **cs)
351
303
{
352
 
  *cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0));
 
304
  *cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY);
353
305
 
354
306
  if (*cs == NULL)
355
307
  {
381
333
                       const CHARSET_INFO *default_cl,
382
334
                       const CHARSET_INFO **cl)
383
335
{
384
 
  *cl= get_charset_by_name(cl_name, MYF(0));
 
336
  *cl= get_charset_by_name(cl_name);
385
337
 
386
338
  if (*cl == NULL)
387
339
  {