~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_iocache2.c

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
  More functions to be used with IO_CACHE files
18
18
*/
19
19
 
 
20
#define MAP_TO_USE_RAID
20
21
#include "mysys_priv.h"
21
22
#include <mystrings/m_string.h>
22
23
#include <stdarg.h>
23
24
#include <mystrings/m_ctype.h>
24
 
#include <mysys/iocache.h>
25
25
 
26
26
/*
27
27
  Copy contents of an IO_CACHE to a file.
110
110
     b) see if there is a better way to make it work
111
111
  */
112
112
  if (info->type == SEQ_READ_APPEND)
113
 
    flush_io_cache(info);
 
113
    VOID(flush_io_cache(info));
114
114
 
115
115
  offset=(pos - info->pos_in_file);
116
116
 
138
138
      info->write_pos = info->write_buffer + offset;
139
139
      return;
140
140
    }
141
 
    flush_io_cache(info);
 
141
    VOID(flush_io_cache(info));
142
142
    /* Correct buffer end so that we write in increments of IO_SIZE */
143
143
    info->write_end=(info->write_buffer+info->buffer_length-
144
144
                     (pos & (IO_SIZE-1)));
221
221
 
222
222
  for (;;)
223
223
  {
224
 
    unsigned char *pos, *end;
 
224
    uchar *pos, *end;
225
225
    if (length > max_length)
226
226
      length=max_length;
227
227
    for (pos=info->read_pos,end=pos+length ; pos < end ;)
276
276
size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
277
277
{
278
278
  size_t out_length= 0;
279
 
  uint32_t minimum_width; /* as yet unimplemented */
280
 
  uint32_t minimum_width_sign;
281
 
  uint32_t precision; /* as yet unimplemented for anything but %b */
 
279
  uint minimum_width; /* as yet unimplemented */
 
280
  uint minimum_width_sign;
 
281
  uint precision; /* as yet unimplemented for anything but %b */
282
282
  bool is_zero_padded;
283
283
 
284
284
  /*
299
299
 
300
300
    length= (size_t) (fmt - start);
301
301
    out_length+=length;
302
 
    if (my_b_write(info, (const unsigned char*) start, length))
 
302
    if (my_b_write(info, (const uchar*) start, length))
303
303
      goto err;
304
304
 
305
305
    if (*fmt == '\0')                           /* End of format */
341
341
    }
342
342
    else
343
343
    {
344
 
      while (my_isdigit(&my_charset_utf8_general_ci, *fmt)) {
 
344
      while (my_isdigit(&my_charset_latin1, *fmt)) {
345
345
        minimum_width=(minimum_width * 10) + (*fmt - '0');
346
346
        fmt++;
347
347
      }
357
357
      }
358
358
      else
359
359
      {
360
 
        while (my_isdigit(&my_charset_utf8_general_ci, *fmt)) {
 
360
        while (my_isdigit(&my_charset_latin1, *fmt)) {
361
361
          precision=(precision * 10) + (*fmt - '0');
362
362
          fmt++;
363
363
        }
370
370
      size_t length2 = strlen(par);
371
371
      /* TODO: implement precision */
372
372
      out_length+= length2;
373
 
      if (my_b_write(info, (const unsigned char*) par, length2))
 
373
      if (my_b_write(info, (const uchar*) par, length2))
374
374
        goto err;
375
375
    }
376
376
    else if (*fmt == 'b')                       /* Sized buffer parameter, only precision makes sense */
377
377
    {
378
378
      char *par = va_arg(args, char *);
379
379
      out_length+= precision;
380
 
      if (my_b_write(info, (const unsigned char*) par, precision))
 
380
      if (my_b_write(info, (const uchar*) par, precision))
381
381
        goto err;
382
382
    }
383
383
    else if (*fmt == 'd' || *fmt == 'u')        /* Integer parameter */
396
396
      if (minimum_width > length2) 
397
397
      {
398
398
        const size_t buflen = minimum_width - length2;
399
 
        unsigned char *buffz= my_alloca(buflen);
 
399
        uchar *buffz= my_alloca(buflen);
400
400
        memset(buffz, is_zero_padded ? '0' : ' ', buflen);
401
401
        my_b_write(info, buffz, buflen);
402
402
        my_afree(buffz);
403
403
      }
404
404
 
405
405
      out_length+= length2;
406
 
      if (my_b_write(info, (const unsigned char *)buff, length2))
 
406
      if (my_b_write(info, (const uchar *)buff, length2))
407
407
        goto err;
408
408
    }
409
409
    else if ((*fmt == 'l' && fmt[1] == 'd') || fmt[1] == 'u')
419
419
      else
420
420
        length2= (size_t) (int10_to_str(iarg,buff,10)- buff);
421
421
      out_length+= length2;
422
 
      if (my_b_write(info, (unsigned char*) buff, length2))
 
422
      if (my_b_write(info, (uchar*) buff, length2))
423
423
        goto err;
424
424
    }
425
425
    else
426
426
    {
427
427
      /* %% or unknown code */
428
 
      if (my_b_write(info, (const unsigned char*) backtrack, (size_t) (fmt-backtrack)))
 
428
      if (my_b_write(info, (const uchar*) backtrack, (size_t) (fmt-backtrack)))
429
429
        goto err;
430
430
      out_length+= fmt-backtrack;
431
431
    }