OpenCores
URL https://opencores.org/ocsvn/minsoc/minsoc/trunk

Subversion Repositories minsoc

[/] [minsoc/] [tags/] [release-0.9/] [sw/] [support/] [vfnprintf.c] - Blame information for rev 127

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rfajardo
// Ripped out of latest ecos build from http://sources-redhat.mirrors.airband.net/ecos/releases/ecos-3.0b1/ecos-3.0beta1.i386linux.tar.bz2
2
// File: ecos-3.0b1/packages/language/c/libc/stdio/v3_0b1/src/output/vfnprintf.cxx
3
 
4
//  Hacked to pieces so it would work with OpenRISC compiler, not using libc
5
//===========================================================================
6
//
7
//      vfnprintf.c
8
//
9
//      I/O routines for vfnprintf() for use with ANSI C library
10
//
11
//===========================================================================
12
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
13
// -------------------------------------------                              
14
// This file is part of eCos, the Embedded Configurable Operating System.   
15
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
16
//
17
// eCos is free software; you can redistribute it and/or modify it under    
18
// the terms of the GNU General Public License as published by the Free     
19
// Software Foundation; either version 2 or (at your option) any later      
20
// version.                                                                 
21
//
22
// eCos is distributed in the hope that it will be useful, but WITHOUT      
23
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
24
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
25
// for more details.                                                        
26
//
27
// You should have received a copy of the GNU General Public License        
28
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
29
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
30
//
31
// As a special exception, if other files instantiate templates or use      
32
// macros or inline functions from this file, or you compile this file      
33
// and link it with other works to produce a work based on this file,       
34
// this file does not by itself cause the resulting work to be covered by   
35
// the GNU General Public License. However the source code for this file    
36
// must still be made available in accordance with section (3) of the GNU   
37
// General Public License v2.                                               
38
//
39
// This exception does not invalidate any other reasons why a work based    
40
// on this file might be covered by the GNU General Public License.         
41
// -------------------------------------------                              
42
// ####ECOSGPLCOPYRIGHTEND####                                              
43
//===========================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):    jlarmour
47
// Contributors: 
48
// Date:         2000-04-20
49
// Purpose:     
50
// Description: 
51
// Usage:       
52
//
53
//####DESCRIPTIONEND####
54
//
55
//===========================================================================
56
//
57
// This code is based on original code with the following copyright:
58
//
59
/*-
60
 * Copyright (c) 1990 The Regents of the University of California.
61
 * All rights reserved.
62
 *
63
 * This code is derived from software contributed to Berkeley by
64
 * Chris Torek.
65
 *
66
 * Redistribution and use in source and binary forms, with or without
67
 * modification, are permitted provided that the following conditions
68
 * are met:
69
 * 1. Redistributions of source code must retain the above copyright
70
 *    notice, this list of conditions and the following disclaimer.
71
 * 2. Redistributions in binary form must reproduce the above copyright
72
 *    notice, this list of conditions and the following disclaimer in the
73
 *    documentation and/or other materials provided with the distribution.
74
 * 3. Neither the name of the University nor the names of its contributors
75
 *    may be used to endorse or promote products derived from this software
76
 *    without specific prior written permission.
77
 *
78
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
79
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
80
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
81
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
82
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
83
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
84
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
85
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
86
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
87
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88
 * SUCH DAMAGE.
89
 */
90
 
91
 
92
// CONFIGURATION
93
 
94
//#include <pkgconf/libc_stdio.h>   // Configuration header
95
//#include <pkgconf/libc_i18n.h>    // Configuration header for mb support
96
 
97
// INCLUDES
98
 
99 36 rfajardo
//#include <stdlib.h> // For mbtowc()
100 2 rfajardo
#include <stddef.h>
101
 
102
 
103
//#include <cyg/infra/cyg_type.h>   // Common type definitions and support
104
#define CYG_MACRO_START do {
105
#define CYG_MACRO_END   } while (0)
106
 
107
#define CYG_EMPTY_STATEMENT CYG_MACRO_START CYG_MACRO_END
108
 
109
#define CYG_UNUSED_PARAM( _type_, _name_ ) CYG_MACRO_START      \
110
  _type_ __tmp1 = (_name_);                                     \
111
  _type_ __tmp2 = __tmp1;                                       \
112
  __tmp1 = __tmp2;                                              \
113
CYG_MACRO_END
114
 
115
#include <stdarg.h>               // Variable argument definitions
116
 
117
#include "vfnprintf.h"
118
 
119
 
120
# define BUF            40
121
 
122
/*
123
 * Actual printf innards.
124
 *
125
 * This code is large and complicated...
126
 */
127
 
128
 
129
/*
130
 * Macros for converting digits to letters and vice versa
131
 */
132
#define to_digit(c)     ((c) - '0')
133
#define is_digit(c)     ((unsigned)to_digit(c) <= 9)
134
#define to_char(n)      ((n) + '0')
135
 
136
/*
137
 * Flags used during conversion.
138
 */
139
#define ALT             0x001           /* alternate form */
140
#define HEXPREFIX       0x002           /* add 0x or 0X prefix */
141
#define LADJUST         0x004           /* left adjustment */
142
#define LONGDBL         0x008           /* long double; unimplemented */
143
#define LONGINT         0x010           /* long integer */
144
#define QUADINT         0x020           /* quad integer */
145
#define SHORTINT        0x040           /* short integer */
146
#define ZEROPAD         0x080           /* zero (as opposed to blank) pad */
147
#define FPT             0x100           /* Floating point number */
148
#define SIZET           0x200           /* size_t */
149
 
150 36 rfajardo
int
151
strlen(const char *s)
152
{
153
        const char *p;
154 2 rfajardo
 
155 36 rfajardo
        for (p = s; *p != '\0'; p++)
156
                ;
157
        return (s - p);
158
}
159
 
160
void *
161
memcpy(void *dst, const void *src, size_t len)
162
{
163
        const char *csrc;
164
        char *cdst;
165
        int i;
166
 
167
        cdst = dst;
168
        csrc = src;
169
        for (i = len; i >= 0; i--) {
170
                cdst[i] = csrc[i];
171
        }
172
        return dst;
173
}
174
 
175 2 rfajardo
// Function which prints back to the buffer, ptr, len bytes
176
// returns 1 if it should finish up, otherwise 0 to continue
177
int print_back_to_string(char * ptr, int len, size_t * n, int * ret, char ** stream)
178
{
179
#define MIN(a, b) ((a) < (b) ? (a) : (b))
180
  do {
181
    int length = MIN( (int) len, *n - *ret - 1);
182
    memcpy(*stream + *ret, ptr, length);
183
    if (length < (int)len) {
184
      *ret += length;
185
      return 1; // finish up
186
    }
187
 
188
  } while(0);
189
 
190
    return 0;
191
}
192
 
193
//externC int 
194
int
195
//vfnprintf ( FILE *stream, size_t n, const char *format, va_list arg) __THROW
196
vfnprintf ( char *stream, size_t n, const char *format, va_list arg)
197
{
198
  char *fmt;     /* format string */
199
  int ch;        /* character from fmt */
200
  int x, y;      /* handy integers (short term usage) */
201
  char *cp;      /* handy char pointer (short term usage) */
202
  int flags;     /* flags as above */
203
 
204
  int ret;                /* return value accumulator */
205
  int width;              /* width from format (%8d), or 0 */
206
  int prec;               /* precision from format (%.3d), or -1 */
207
  char sign;              /* sign prefix (' ', '+', '-', or \0) */
208
  wchar_t wc;
209
 
210
#define quad_t    long long
211
#define u_quad_t  unsigned long long
212
 
213
  u_quad_t _uquad;        /* integer arguments %[diouxX] */
214
  enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */
215
  int dprec;              /* a copy of prec if [diouxX], 0 otherwise */
216
  int fieldsz;            /* field size expanded by sign, etc */
217
  int realsz;             /* field size expanded by dprec */
218
  int size;               /* size of converted field or string */
219
  char *xdigs;            /* digits for [xX] conversion */
220
#define NIOV 8
221
  char buf[BUF];          /* space for %c, %[diouxX], %[eEfgG] */
222
  char ox[2];             /* space for 0x hex-prefix */
223
 
224
  /*
225
   * Choose PADSIZE to trade efficiency vs. size.  If larger printf
226
   * fields occur frequently, increase PADSIZE and make the initialisers
227
   * below longer.
228
   */
229
#define PADSIZE 16              /* pad chunk size */
230
  static char blanks[PADSIZE] =
231
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
232
  static char zeroes[PADSIZE] =
233
    {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
234
 
235
  /*
236
   * BEWARE, these `goto error' on error, and PAD uses `n'.
237
   */
238
 
239
  // We'll copy len bytes from (char*) ptr, into the output stream
240
  // making sure we don't go over the end, so calculate length to be
241
  // either the whole length we've been passed, or the whole length
242
  // that is possible to write
243
  // We finish if it was not possible to write the entire variable
244
  // into the buffer, ie we had to write all we could, not all we
245
  // wanted to.
246
  /*
247
    #define PRINT(ptr, len)                                             \
248
    CYG_MACRO_START                                                     \
249
    int length = MIN( (int) len, n - ret - 1);                          \
250
    char* begin_stream_write = stream;                                  \
251
    stream = memcpy(stream, ptr, length);                               \
252
    length = (unsigned long) stream - (unsigned long) begin_stream_write; \
253
    if (length < (int)len) {                                            \
254
    ret += length;                                                      \
255
    goto done;                                                          \
256
    }                                                                   \
257
    CYG_MACRO_END
258
  */
259
 
260
        //PRINT(with, PADSIZE);                                         \
261
      //PRINT(with, x);                                                 \
262
 
263
#define PAD(howmany, with)                                              \
264
  CYG_MACRO_START                                                       \
265
    if ((x = (howmany)) > 0) {                                           \
266
      while (x > PADSIZE) {                                             \
267
        if (print_back_to_string(with, PADSIZE, &n, &ret, &stream)) goto done; \
268
        x -= PADSIZE;                                                   \
269
      }                                                                 \
270
      if (print_back_to_string(with, x, &n, &ret, &stream))goto done;   \
271
    }                                                                   \
272
  CYG_MACRO_END
273
 
274
  /*
275
   * To extend shorts properly, we need both signed and unsigned
276
   * argument extraction methods.
277
   */
278
 
279
#define SARG()                                    \
280
  (flags&QUADINT ? va_arg(arg, long long) :       \
281
   flags&LONGINT ? va_arg(arg, long) :                       \
282
   flags&SHORTINT ? (long)(short)va_arg(arg, int) :          \
283
   flags&SIZET ? (long)va_arg(arg, size_t) :                 \
284
   (long)va_arg(arg, int))
285
#define UARG()                                             \
286
  (flags&QUADINT ? va_arg(arg, unsigned long long) :       \
287
   flags&LONGINT ? va_arg(arg, unsigned long) :                         \
288
   flags&SHORTINT ? (unsigned long)(unsigned short)va_arg(arg, int) :   \
289
   flags&SIZET ? va_arg(arg, size_t) :                                  \
290
   (unsigned long)va_arg(arg, unsigned int))
291
 
292
 
293
  xdigs = NULL;  // stop compiler whinging
294
  fmt = (char *)format;
295
  ret = 0;
296
 
297
  /*
298
   * Scan the format for conversions (`%' character).
299
   */
300
  for (;;) {
301
    cp = (char *)fmt; // char pointer - set to where we begin looking from
302
    while ((x = ((wc = *fmt) != 0))) { // While, wc=next char and x is one while there's still chars left
303
      fmt += x; // increment the pointer to the char
304
      if (wc == '%') { // check if it's the beginning of
305
        fmt--; // Decrement the char pointer, actually
306
        break;
307
      }
308
    }
309
    if ((y = fmt - cp) != 0) { // y is length of string to copy out just now
310
      //PRINT(cp, y); // Copy macro 
311
      if(print_back_to_string(cp, y, &n, &ret, &stream)) goto done; // Copy macro 
312
      ret += y; // increment return chars
313
    }
314
    if ((x <= 0) || (ret >= (int)n))  // @@@ this check with n isn't good enough
315
      goto done;
316
    fmt++;          /* skip over '%' */
317
 
318
    flags = 0;
319
    dprec = 0;
320
    width = 0;
321
    prec = -1;
322
    sign = '\0';
323
 
324
  rflag:          ch = *fmt++;
325
  reswitch:       switch (ch) {
326
    case ' ':
327
      /*
328
       * ``If the space and + flags both appear, the space
329
       * flag will be ignored.''
330
       *      -- ANSI X3J11
331
       */
332
      if (!sign)
333
        sign = ' ';
334
      goto rflag;
335
    case '#':
336
      flags |= ALT;
337
      goto rflag;
338
    case '*':
339
      /*
340
       * ``A negative field width argument is taken as a
341
       * - flag followed by a positive field width.''
342
       *      -- ANSI X3J11
343
       * They don't exclude field widths read from args.
344
       */
345
      if ((width = va_arg(arg, int)) >= 0)
346
        goto rflag;
347
      width = -width;
348
      /* FALLTHROUGH */
349
    case '-':
350
      flags |= LADJUST;
351
      goto rflag;
352
    case '+':
353
      sign = '+';
354
      goto rflag;
355
    case '.':
356
      if ((ch = *fmt++) == '*') {
357
        x = va_arg(arg, int);
358
        prec = x < 0 ? -1 : x;
359
        goto rflag;
360
      }
361
      x = 0;
362
      while (is_digit(ch)) {
363
        x = 10 * x + to_digit(ch);
364
        ch = *fmt++;
365
      }
366
      prec = x < 0 ? -1 : x;
367
      goto reswitch;
368
    case '0':
369
      /*
370
       * ``Note that 0 is taken as a flag, not as the
371
       * beginning of a field width.''
372
       *      -- ANSI X3J11
373
       */
374
      flags |= ZEROPAD;
375
      goto rflag;
376
    case '1': case '2': case '3': case '4':
377
    case '5': case '6': case '7': case '8': case '9':
378
      x = 0;
379
      do {
380
        x = 10 * x + to_digit(ch);
381
        ch = *fmt++;
382
      } while (is_digit(ch));
383
      width = x;
384
      goto reswitch;
385
    case 'h':
386
      flags |= SHORTINT;
387
      goto rflag;
388
    case 'l':
389
      if (*fmt == 'l') {
390
        fmt++;
391
        flags |= QUADINT;
392
      } else {
393
        flags |= LONGINT;
394
      }
395
      goto rflag;
396
    case 'q':
397
      flags |= QUADINT;
398
      goto rflag;
399
    case 'c':
400
      *(cp = buf) = va_arg(arg, int);
401
      size = 1;
402
      sign = '\0';
403
      break;
404
    case 'D':
405
      flags |= LONGINT;
406
      /*FALLTHROUGH*/
407
    case 'd':
408
    case 'i':
409
      _uquad = SARG();
410
#ifndef _NO_LONGLONG
411
      if ((quad_t)_uquad < 0)
412
#else
413
        if ((long) _uquad < 0)
414
#endif
415
          {
416
 
417
            _uquad = -_uquad;
418
            sign = '-';
419
          }
420
      base = DEC;
421
      goto number;
422
 
423
    case 'e':
424
    case 'E':
425
    case 'f':
426
    case 'g':
427
    case 'G':
428
      // Output nothing at all
429
      (void) va_arg(arg, double); // take off arg anyway
430
      cp = "";
431
      size = 0;
432
      sign = '\0';
433
      break;
434
 
435
    case 'n':
436
#ifndef _NO_LONGLONG
437
      if (flags & QUADINT)
438
        *va_arg(arg, quad_t *) = ret;
439
      else
440
#endif
441
        if (flags & LONGINT)
442
          *va_arg(arg, long *) = ret;
443
        else if (flags & SHORTINT)
444
          *va_arg(arg, short *) = ret;
445
        else if (flags & SIZET)
446
          *va_arg(arg, size_t *) = ret;
447
        else
448
          *va_arg(arg, int *) = ret;
449
      continue;       /* no output */
450
    case 'O':
451
      flags |= LONGINT;
452
      /*FALLTHROUGH*/
453
    case 'o':
454
      _uquad = UARG();
455
      base = OCT;
456
      goto nosign;
457
    case 'p':
458
      /*
459
       * ``The argument shall be a pointer to void.  The
460
       * value of the pointer is converted to a sequence
461
       * of printable characters, in an implementation-
462
       * defined manner.''
463
       *      -- ANSI X3J11
464
       */
465
      /* NOSTRICT */
466
      _uquad = (unsigned long)va_arg(arg, void *);
467
      base = HEX;
468
      xdigs = (char *)"0123456789abcdef";
469
      flags |= HEXPREFIX;
470
      ch = 'x';
471
      goto nosign;
472
    case 's':
473
      if ((cp = va_arg(arg, char *)) == NULL)
474
        cp = (char *)"(null)";
475
      if (prec >= 0) {
476
        /*
477
         * can't use strlen; can only look for the
478
         * NUL in the first `prec' characters, and
479
         * strlen() will go further.
480
         */
481
        char *p = (char *)memchr(cp, 0, prec);
482
 
483
        if (p != NULL) {
484
          size = p - cp;
485
          if (size > prec)
486
            size = prec;
487
        } else
488
          size = prec;
489
      } else
490
        size = strlen(cp);
491
      sign = '\0';
492
      break;
493
    case 'U':
494
      flags |= LONGINT;
495
      /*FALLTHROUGH*/
496
    case 'u':
497
      _uquad = UARG();
498
      base = DEC;
499
      goto nosign;
500
    case 'X':
501
      xdigs = (char *)"0123456789ABCDEF";
502
      goto hex;
503
    case 'x':
504
      xdigs = (char *)"0123456789abcdef";
505
    hex:                    _uquad = UARG();
506
      base = HEX;
507
      /* leading 0x/X only if non-zero */
508
      if (flags & ALT && _uquad != 0)
509
        flags |= HEXPREFIX;
510
 
511
      /* unsigned conversions */
512
    nosign:                 sign = '\0';
513
      /*
514
       * ``... diouXx conversions ... if a precision is
515
       * specified, the 0 flag will be ignored.''
516
       *      -- ANSI X3J11
517
       */
518
    number:                 if ((dprec = prec) >= 0)
519
        flags &= ~ZEROPAD;
520
 
521
      /*
522
       * ``The result of converting a zero value with an
523
       * explicit precision of zero is no characters.''
524
       *      -- ANSI X3J11
525
       */
526
      cp = buf + BUF;
527
      if (_uquad != 0 || prec != 0) {
528
        /*
529
         * Unsigned mod is hard, and unsigned mod
530
         * by a constant is easier than that by
531
         * a variable; hence this switch.
532
         */
533
        switch (base) {
534
        case OCT:
535
          do {
536
            *--cp = to_char(_uquad & 7);
537
            _uquad >>= 3;
538
          } while (_uquad);
539
          /* handle octal leading 0 */
540
          if (flags & ALT && *cp != '0')
541
            *--cp = '0';
542
          break;
543
 
544
        case DEC:
545
          if (!(flags & QUADINT)) {
546
            /* many numbers are 1 digit */
547
            unsigned long v = (unsigned long)_uquad;
548
            while (v >= 10) {
549
              /* The following is usually faster than using a modulo */
550
              unsigned long next = v / 10;
551
              *--cp = to_char(v - (next * 10));
552
              v = next;
553
            }
554
            *--cp = to_char(v);
555
          }
556
          else {
557
            while (_uquad >= 10) {
558
              /* The following is usually faster than using a modulo */
559
              u_quad_t next = _uquad / 10;
560
              *--cp = to_char(_uquad - (next * 10));
561
              _uquad = next;
562
            }
563
            *--cp = to_char(_uquad);
564
          }
565
          break;
566
 
567
        case HEX:
568
          do {
569
            *--cp = xdigs[_uquad & 15];
570
            _uquad >>= 4;
571
          } while (_uquad);
572
          break;
573
 
574
        default:
575
          cp = (char *)"bug in vfprintf: bad base";
576
          size = strlen(cp);
577
          goto skipsize;
578
        }
579
      }
580
      size = buf + BUF - cp;
581
    skipsize:
582
      break;
583
    case 'z':
584
      flags |= SIZET;
585
      goto rflag;
586
    default:        /* "%?" prints ?, unless ? is NUL */
587
      if (ch == '\0')
588
        goto done;
589
      /* pretend it was %c with argument ch */
590
      cp = buf;
591
      *cp = ch;
592
      size = 1;
593
      sign = '\0';
594
      break;
595
    }
596
 
597
    /*
598
     * All reasonable formats wind up here.  At this point, `cp'
599
     * points to a string which (if not flags&LADJUST) should be
600
     * padded out to `width' places.  If flags&ZEROPAD, it should
601
     * first be prefixed by any sign or other prefix; otherwise,
602
     * it should be blank padded before the prefix is emitted.
603
     * After any left-hand padding and prefixing, emit zeroes
604
     * required by a decimal [diouxX] precision, then print the
605
     * string proper, then emit zeroes required by any leftover
606
     * floating precision; finally, if LADJUST, pad with blanks.
607
     *
608
     * Compute actual size, so we know how much to pad.
609
     * fieldsz excludes decimal prec; realsz includes it.
610
     */
611
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
612
    fieldsz = size + fpprec;
613
#else
614
    fieldsz = size;
615
#endif
616
    if (sign)
617
      fieldsz++;
618
    else if (flags & HEXPREFIX)
619
      fieldsz+= 2;
620
    realsz = dprec > fieldsz ? dprec : fieldsz;
621
 
622
    /* right-adjusting blank padding */
623
    if ((flags & (LADJUST|ZEROPAD)) == 0) {
624
      if (width - realsz > 0) {
625
        PAD(width - realsz, blanks);
626
        ret += width - realsz;
627
      }
628
    }
629
 
630
    /* prefix */
631
    if (sign) {
632
      //PRINT(&sign, 1);
633
      if(print_back_to_string(&sign, 1, &n, &ret, &stream))goto done;
634
      ret++;
635
    } else if (flags & HEXPREFIX) {
636
      ox[0] = '0';
637
      ox[1] = ch;
638
      //PRINT(ox, 2);
639
      if(print_back_to_string(ox, 2, &n, &ret, &stream))goto done;
640
      ret += 2;
641
    }
642
 
643
    /* right-adjusting zero padding */
644
    if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) {
645
      if (width - realsz > 0) {
646
        PAD(width - realsz, zeroes);
647
        ret += width - realsz;
648
      }
649
    }
650
 
651
    if (dprec - fieldsz > 0) {
652
      /* leading zeroes from decimal precision */
653
      PAD(dprec - fieldsz, zeroes);
654
      ret += dprec - fieldsz;
655
    }
656
 
657
    /* the string or number proper */
658
    //PRINT(cp, size);
659
    if(print_back_to_string(cp,size, &n, &ret, &stream))goto done;
660
    ret += size;
661
 
662
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
663
    /* trailing f.p. zeroes */
664
    PAD(fpprec, zeroes);
665
    ret += fpprec;
666
#endif
667
 
668
    /* left-adjusting padding (always blank) */
669
    if (flags & LADJUST) {
670
      if (width - realsz > 0) {
671
        PAD(width - realsz, blanks);
672
        ret += width - realsz;
673
      }
674
    }
675
 
676
  }
677
 
678
 done:
679
 error:
680
  return ret;// remove this error stuff (((Cyg_OutputStream *) stream)->get_error() ? EOF : ret);
681
  /* NOTREACHED */
682
}
683
 
684
 
685
 
686
// EOF vfnprintf.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.