~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_iocache2.c

  • Committer: Jay Pipes
  • Date: 2008-07-21 17:52:33 UTC
  • mto: (201.2.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: jay@mysql.com-20080721175233-mtyz298j8xl3v63y
cleanup of FAQ file

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
 
#include <mystrings/m_string.h>
 
22
#include <m_string.h>
22
23
#include <stdarg.h>
23
 
#include <mystrings/m_ctype.h>
24
 
#include <mysys/iocache.h>
 
24
#include <m_ctype.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, (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, (uchar*) par, precision))
381
381
        goto err;
382
382
    }
383
383
    else if (*fmt == 'd' || *fmt == 'u')        /* Integer parameter */
395
395
      /* minimum width padding */
396
396
      if (minimum_width > length2) 
397
397
      {
398
 
        const size_t buflen = minimum_width - length2;
399
 
        unsigned char *buffz= my_alloca(buflen);
400
 
        memset(buffz, is_zero_padded ? '0' : ' ', buflen);
401
 
        my_b_write(info, buffz, buflen);
 
398
        uchar *buffz;
 
399
                    
 
400
        buffz= my_alloca(minimum_width - length2);
 
401
        if (is_zero_padded)
 
402
          memset(buffz, '0', minimum_width - length2);
 
403
        else
 
404
          memset(buffz, ' ', minimum_width - length2);
 
405
        my_b_write(info, buffz, minimum_width - length2);
402
406
        my_afree(buffz);
403
407
      }
404
408
 
405
409
      out_length+= length2;
406
 
      if (my_b_write(info, (const unsigned char *)buff, length2))
 
410
      if (my_b_write(info, (uchar*) buff, length2))
407
411
        goto err;
408
412
    }
409
413
    else if ((*fmt == 'l' && fmt[1] == 'd') || fmt[1] == 'u')
419
423
      else
420
424
        length2= (size_t) (int10_to_str(iarg,buff,10)- buff);
421
425
      out_length+= length2;
422
 
      if (my_b_write(info, (unsigned char*) buff, length2))
 
426
      if (my_b_write(info, (uchar*) buff, length2))
423
427
        goto err;
424
428
    }
425
429
    else
426
430
    {
427
431
      /* %% or unknown code */
428
 
      if (my_b_write(info, (const unsigned char*) backtrack, (size_t) (fmt-backtrack)))
 
432
      if (my_b_write(info, (uchar*) backtrack, (size_t) (fmt-backtrack)))
429
433
        goto err;
430
434
      out_length+= fmt-backtrack;
431
435
    }