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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [stdio/] [swprintf.c] - Blame information for rev 829

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (c) 1990, 2007 The Regents of the University of California.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms are permitted
6
 * provided that the above copyright notice and this paragraph are
7
 * duplicated in all such forms and that any documentation,
8
 * advertising materials, and other materials related to such
9
 * distribution and use acknowledge that the software was developed
10
 * by the University of California, Berkeley.  The name of the
11
 * University may not be used to endorse or promote products derived
12
 * from this software without specific prior written permission.
13
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16
 */
17
 
18
/*
19
FUNCTION
20
<<swprintf>>, <<fwprintf>>, <<wprintf>>---wide character format output
21
 
22
INDEX
23
        fwprintf
24
INDEX
25
        _fwprintf_r
26
INDEX
27
        wprintf
28
INDEX
29
        _wprintf_r
30
INDEX
31
        swprintf
32
INDEX
33
        _swprintf_r
34
 
35
ANSI_SYNOPSIS
36
        #include <wchar.h>
37
 
38
        int wprintf(const wchar_t *<[format]>, ...);
39
        int fwprintf(FILE *<[fd]>, const wchar_t *<[format]>, ...);
40
        int swprintf(wchar_t *<[str]>, size_t <[size]>,
41
                        const wchar_t *<[format]>, ...);
42
 
43
        int _wprintf_r(struct _reent *<[ptr]>, const wchar_t *<[format]>, ...);
44
        int _fwprintf_r(struct _reent *<[ptr]>, FILE *<[fd]>,
45
                        const wchar_t *<[format]>, ...);
46
        int _swprintf_r(struct _reent *<[ptr]>, wchar_t *<[str]>,
47
                        size_t <[size]>, const wchar_t *<[format]>, ...);
48
 
49
DESCRIPTION
50
        <<wprintf>> accepts a series of arguments, applies to each a
51
        format specifier from <<*<[format]>>>, and writes the
52
        formatted data to <<stdout>>, without a terminating NUL
53
        wide character.  The behavior of <<wprintf>> is undefined if there
54
        are not enough arguments for the format or if any argument is not the
55
        right type for the corresponding conversion specifier.  <<wprintf>>
56
        returns when it reaches the end of the format string.  If there are
57
        more arguments than the format requires, excess arguments are
58
        ignored.
59
 
60
        <<fwprintf>> is like <<wprintf>>, except that output is directed
61
        to the stream <[fd]> rather than <<stdout>>.
62
 
63
        <<swprintf>> is like <<wprintf>>, except that output is directed
64
        to the buffer <[str]> with a terminating wide <<NUL>>, and the
65
        resulting string length is limited to at most <[size]> wide characters,
66
        including the terminating <<NUL>>.  It is considered an error if the
67
        output (including the terminating wide-<<NULL>>) does not fit into
68
        <[size]> wide characters.  (This error behavior is not the same as for
69
        <<snprintf>>, which <<swprintf>> is otherwise completely analogous to.
70
        While <<snprintf>> allows the needed size to be known simply by giving
71
        <[size]>=0, <<swprintf>> does not, giving an error instead.)
72
 
73
        For <<swprintf>> the behavior is undefined if the output
74
        <<*<[str]>>> overlaps with one of the arguments.  Behavior is also
75
        undefined if the argument for <<%n>> within <<*<[format]>>>
76
        overlaps another argument.
77
 
78
        <[format]> is a pointer to a wide character string containing two
79
        types of objects: ordinary characters (other than <<%>>),
80
        which are copied unchanged to the output, and conversion
81
        specifications, each of which is introduced by <<%>>. (To
82
        include <<%>> in the output, use <<%%>> in the format string.)
83
        A conversion specification has the following form:
84
 
85
.       %[<[pos]>][<[flags]>][<[width]>][.<[prec]>][<[size]>]<[type]>
86
 
87
        The fields of the conversion specification have the following
88
        meanings:
89
 
90
        O+
91
        o <[pos]>
92
 
93
        Conversions normally consume arguments in the order that they
94
        are presented.  However, it is possible to consume arguments
95
        out of order, and reuse an argument for more than one
96
        conversion specification (although the behavior is undefined
97
        if the same argument is requested with different types), by
98
        specifying <[pos]>, which is a decimal integer followed by
99
        '$'.  The integer must be between 1 and <NL_ARGMAX> from
100
        limits.h, and if argument <<%n$>> is requested, all earlier
101
        arguments must be requested somewhere within <[format]>.  If
102
        positional parameters are used, then all conversion
103
        specifications except for <<%%>> must specify a position.
104
        This positional parameters method is a POSIX extension to the C
105
        standard definition for the functions.
106
 
107
        o <[flags]>
108
 
109
        <[flags]> is an optional sequence of characters which control
110
        output justification, numeric signs, decimal points, trailing
111
        zeros, and octal and hex prefixes.  The flag characters are
112
        minus (<<->>), plus (<<+>>), space ( ), zero (<<0>>), sharp
113
        (<<#>>), and quote (<<'>>).  They can appear in any
114
        combination, although not all flags can be used for all
115
        conversion specification types.
116
 
117
                o+
118
                o '
119
                        A POSIX extension to the C standard.  However, this
120
                        implementation presently treats it as a no-op, which
121
                        is the default behavior for the C locale, anyway.  (If
122
                        it did what it is supposed to, when <[type]> were <<i>>,
123
                        <<d>>, <<u>>, <<f>>, <<F>>, <<g>>, or <<G>>, the
124
                        integer portion of the conversion would be formatted
125
                        with thousands' grouping wide characters.)
126
 
127
                o -
128
                        The result of the conversion is left
129
                        justified, and the right is padded with
130
                        blanks.  If you do not use this flag, the
131
                        result is right justified, and padded on the
132
                        left.
133
 
134
                o +
135
                        The result of a signed conversion (as
136
                        determined by <[type]> of <<d>>, <<i>>, <<a>>,
137
                        <<A>>, <<e>>, <<E>>, <<f>>, <<F>>, <<g>>, or
138
                        <<G>>) will always begin with a plus or minus
139
                        sign.  (If you do not use this flag, positive
140
                        values do not begin with a plus sign.)
141
 
142
                o " " (space)
143
                        If the first character of a signed conversion
144
                        specification is not a sign, or if a signed
145
                        conversion results in no characters, the
146
                        result will begin with a space.  If the space
147
                        ( ) flag and the plus (<<+>>) flag both
148
                        appear, the space flag is ignored.
149
 
150
                o 0
151
                        If the <[type]> character is <<d>>, <<i>>,
152
                        <<o>>, <<u>>, <<x>>, <<X>>, <<a>>, <<A>>,
153
                        <<e>>, <<E>>, <<f>>, <<F>>, <<g>>, or <<G>>:  leading
154
                        zeros are used to pad the field width
155
                        (following any indication of sign or base); no
156
                        spaces are used for padding.  If the zero
157
                        (<<0>>) and minus (<<->>) flags both appear,
158
                        the zero (<<0>>) flag will be ignored.  For
159
                        <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, and <<X>>
160
                        conversions, if a precision <[prec]> is
161
                        specified, the zero (<<0>>) flag is ignored.
162
 
163
                        Note that <<0>> is interpreted as a flag, not
164
                        as the beginning of a field width.
165
 
166
                o #
167
                        The result is to be converted to an
168
                        alternative form, according to the <[type]>
169
                        character:
170
 
171
                        o+
172
                        o o
173
                                Increases precision to force the first
174
                                digit of the result to be a zero.
175
 
176
                        o x
177
                                A non-zero result will have a <<0x>>
178
                                prefix.
179
 
180
                        o X
181
                                A non-zero result will have a <<0X>>
182
                                prefix.
183
 
184
                        o a, A, e, E, f, or F
185
                                The result will always contain a
186
                                decimal point even if no digits follow
187
                                the point.  (Normally, a decimal point
188
                                appears only if a digit follows it.)
189
                                Trailing zeros are removed.
190
 
191
                        o g or G
192
                                The result will always contain a
193
                                decimal point even if no digits follow
194
                                the point.  Trailing zeros are not
195
                                removed.
196
 
197
                        o all others
198
                                Undefined.
199
 
200
                        o-
201
                o-
202
 
203
        o <[width]>
204
 
205
                <[width]> is an optional minimum field width.  You can
206
                either specify it directly as a decimal integer, or
207
                indirectly by using instead an asterisk (<<*>>), in
208
                which case an <<int>> argument is used as the field
209
                width.  If positional arguments are used, then the
210
                width must also be specified positionally as <<*m$>>,
211
                with m as a decimal integer.  Negative field widths
212
                are treated as specifying the minus (<<->>) flag for
213
                left justfication, along with a positive field width.
214
                The resulting format may be wider than the specified
215
                width.
216
 
217
        o <[prec]>
218
 
219
                <[prec]> is an optional field; if present, it is
220
                introduced with `<<.>>' (a period). You can specify
221
                the precision either directly as a decimal integer or
222
                indirectly by using an asterisk (<<*>>), in which case
223
                an <<int>> argument is used as the precision.  If
224
                positional arguments are used, then the precision must
225
                also be specified positionally as <<*m$>>, with m as a
226
                decimal integer.  Supplying a negative precision is
227
                equivalent to omitting the precision.  If only a
228
                period is specified the precision is zero. The effect
229
                depends on the conversion <[type]>.
230
 
231
                o+
232
                o d, i, o, u, x, or X
233
                        Minimum number of digits to appear.  If no
234
                        precision is given, defaults to 1.
235
 
236
                o a or A
237
                        Number of digits to appear after the decimal
238
                        point.  If no precision is given, the
239
                        precision defaults to the minimum needed for
240
                        an exact representation.
241
 
242
                o e, E, f or F
243
                        Number of digits to appear after the decimal
244
                        point.  If no precision is given, the
245
                        precision defaults to 6.
246
 
247
                o g or G
248
                        Maximum number of significant digits.  A
249
                        precision of 0 is treated the same as a
250
                        precision of 1.  If no precision is given, the
251
                        precision defaults to 6.
252
 
253
                o s or S
254
                        Maximum number of characters to print from the
255
                        string.  If no precision is given, the entire
256
                        string is printed.
257
 
258
                o all others
259
                        undefined.
260
 
261
                o-
262
 
263
        o <[size]>
264
 
265
                <[size]> is an optional modifier that changes the data
266
                type that the corresponding argument has.  Behavior is
267
                unspecified if a size is given that does not match the
268
                <[type]>.
269
 
270
                o+
271
                o hh
272
                        With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or
273
                        <<X>>, specifies that the argument should be
274
                        converted to a <<signed char>> or <<unsigned
275
                        char>> before printing.
276
 
277
                        With <<n>>, specifies that the argument is a
278
                        pointer to a <<signed char>>.
279
 
280
                o h
281
                        With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or
282
                        <<X>>, specifies that the argument should be
283
                        converted to a <<short>> or <<unsigned short>>
284
                        before printing.
285
 
286
                        With <<n>>, specifies that the argument is a
287
                        pointer to a <<short>>.
288
 
289
                o l
290
                        With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or
291
                        <<X>>, specifies that the argument is a
292
                        <<long>> or <<unsigned long>>.
293
 
294
                        With <<c>>, specifies that the argument has
295
                        type <<wint_t>>.
296
 
297
                        With <<s>>, specifies that the argument is a
298
                        pointer to <<wchar_t>>.
299
 
300
                        With <<n>>, specifies that the argument is a
301
                        pointer to a <<long>>.
302
 
303
                        With <<a>>, <<A>>, <<e>>, <<E>>, <<f>>, <<F>>,
304
                        <<g>>, or <<G>>, has no effect (because of
305
                        vararg promotion rules, there is no need to
306
                        distinguish between <<float>> and <<double>>).
307
 
308
                o ll
309
                        With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or
310
                        <<X>>, specifies that the argument is a
311
                        <<long long>> or <<unsigned long long>>.
312
 
313
                        With <<n>>, specifies that the argument is a
314
                        pointer to a <<long long>>.
315
 
316
                o j
317
                        With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or
318
                        <<X>>, specifies that the argument is an
319
                        <<intmax_t>> or <<uintmax_t>>.
320
 
321
                        With <<n>>, specifies that the argument is a
322
                        pointer to an <<intmax_t>>.
323
 
324
                o z
325
                        With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or
326
                        <<X>>, specifies that the argument is a <<size_t>>.
327
 
328
                        With <<n>>, specifies that the argument is a
329
                        pointer to a <<size_t>>.
330
 
331
                o t
332
                        With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or
333
                        <<X>>, specifies that the argument is a
334
                        <<ptrdiff_t>>.
335
 
336
                        With <<n>>, specifies that the argument is a
337
                        pointer to a <<ptrdiff_t>>.
338
 
339
                o L
340
                        With <<a>>, <<A>>, <<e>>, <<E>>, <<f>>, <<F>>,
341
                        <<g>>, or <<G>>, specifies that the argument
342
                        is a <<long double>>.
343
 
344
                o-
345
 
346
        o   <[type]>
347
 
348
                <[type]> specifies what kind of conversion <<wprintf>>
349
                performs.  Here is a table of these:
350
 
351
                o+
352
                o %
353
                        Prints the percent character (<<%>>).
354
 
355
                o c
356
                        If no <<l>> qualifier is present, the int argument shall
357
                        be converted to a wide character as if by calling
358
                        the btowc() function and the resulting wide character
359
                        shall be written.  Otherwise, the wint_t argument
360
                        shall be converted to wchar_t, and written.
361
 
362
                o C
363
                        Short for <<%lc>>.  A POSIX extension to the C standard.
364
 
365
                o s
366
                        If no <<l>> qualifier is present, the application
367
                        shall ensure that the argument is a pointer to a
368
                        character array containing a character sequence
369
                        beginning in the initial shift state.  Characters
370
                        from the array shall be converted as if by repeated
371
                        calls to the mbrtowc() function, with the conversion
372
                        state described by an mbstate_t object initialized to
373
                        zero before the first character is converted, and
374
                        written up to (but not including) the terminating
375
                        null wide character. If the precision is specified,
376
                        no more than that many wide characters shall be
377
                        written.  If the precision is not specified, or is
378
                        greater than the size of the array, the application
379
                        shall ensure that the array contains a null wide
380
                        character.
381
 
382
                        If an <<l>> qualifier is present, the application
383
                        shall ensure that the argument is a pointer to an
384
                        array of type wchar_t. Wide characters from the array
385
                        shall be written up to (but not including) a
386
                        terminating null wide character. If no precision is
387
                        specified, or is greater than the size of the array,
388
                        the application shall ensure that the array contains
389
                        a null wide character. If a precision is specified,
390
                        no more than that many wide characters shall be
391
                        written.
392
 
393
                o S
394
                        Short for <<%ls>>.  A POSIX extension to the C standard.
395
 
396
                o d or i
397
                        Prints a signed decimal integer; takes an
398
                        <<int>>.  Leading zeros are inserted as
399
                        necessary to reach the precision.  A value of 0 with
400
                        a precision of 0 produces an empty string.
401
 
402
                o o
403
                        Prints an unsigned octal integer; takes an
404
                        <<unsigned>>.  Leading zeros are inserted as
405
                        necessary to reach the precision.  A value of 0 with
406
                        a precision of 0 produces an empty string.
407
 
408
                o u
409
                        Prints an unsigned decimal integer; takes an
410
                        <<unsigned>>.  Leading zeros are inserted as
411
                        necessary to reach the precision.  A value of 0 with
412
                        a precision of 0 produces an empty string.
413
 
414
                o x
415
                        Prints an unsigned hexadecimal integer (using
416
                        <<abcdef>> as digits beyond <<9>>); takes an
417
                        <<unsigned>>.  Leading zeros are inserted as
418
                        necessary to reach the precision.  A value of 0 with
419
                        a precision of 0 produces an empty string.
420
 
421
                o X
422
                        Like <<x>>, but uses <<ABCDEF>> as digits
423
                        beyond <<9>>.
424
 
425
                o f
426
                        Prints a signed value of the form
427
                        <<[-]9999.9999>>, with the precision
428
                        determining how many digits follow the decimal
429
                        point; takes a <<double>> (remember that
430
                        <<float>> promotes to <<double>> as a vararg).
431
                        The low order digit is rounded to even.  If
432
                        the precision results in at most DECIMAL_DIG
433
                        digits, the result is rounded correctly; if
434
                        more than DECIMAL_DIG digits are printed, the
435
                        result is only guaranteed to round back to the
436
                        original value.
437
 
438
                        If the value is infinite, the result is
439
                        <<inf>>, and no zero padding is performed.  If
440
                        the value is not a number, the result is
441
                        <<nan>>, and no zero padding is performed.
442
 
443
                o F
444
                        Like <<f>>, but uses <<INF>> and <<NAN>> for
445
                        non-finite numbers.
446
 
447
                o e
448
                        Prints a signed value of the form
449
                        <<[-]9.9999e[+|-]999>>; takes a <<double>>.
450
                        The digit before the decimal point is non-zero
451
                        if the value is non-zero.  The precision
452
                        determines how many digits appear between
453
                        <<.>> and <<e>>, and the exponent always
454
                        contains at least two digits.  The value zero
455
                        has an exponent of zero.  If the value is not
456
                        finite, it is printed like <<f>>.
457
 
458
                o E
459
                        Like <<e>>, but using <<E>> to introduce the
460
                        exponent, and like <<F>> for non-finite
461
                        values.
462
 
463
                o g
464
                        Prints a signed value in either <<f>> or <<e>>
465
                        form, based on the given value and
466
                        precision---an exponent less than -4 or
467
                        greater than the precision selects the <<e>>
468
                        form.  Trailing zeros and the decimal point
469
                        are printed only if necessary; takes a
470
                        <<double>>.
471
 
472
                o G
473
                        Like <<g>>, except use <<F>> or <<E>> form.
474
 
475
                o a
476
                        Prints a signed value of the form
477
                        <<[-]0x1.ffffp[+|-]9>>; takes a <<double>>.
478
                        The letters <<abcdef>> are used for digits
479
                        beyond <<9>>.  The precision determines how
480
                        many digits appear after the decimal point.
481
                        The exponent contains at least one digit, and
482
                        is a decimal value representing the power of
483
                        2; a value of 0 has an exponent of 0.
484
                        Non-finite values are printed like <<f>>.
485
 
486
                o A
487
                        Like <<a>>, except uses <<X>>, <<P>>, and
488
                        <<ABCDEF>> instead of lower case.
489
 
490
                o n
491
                        Takes a pointer to <<int>>, and stores a count
492
                        of the number of bytes written so far.  No
493
                        output is created.
494
 
495
                o p
496
                        Takes a pointer to <<void>>, and prints it in
497
                        an implementation-defined format.  This
498
                        implementation is similar to <<%#tx>>), except
499
                        that <<0x>> appears even for the NULL pointer.
500
 
501
                o-
502
        O-
503
 
504
        <<_wprintf_r>>, <<_fwprintf_r>>, <<_swprintf_r>>, are simply
505
        reentrant versions of the functions above.
506
 
507
RETURNS
508
On success, <<swprintf>> return the number of wide characters in
509
the output string, except the concluding <<NUL>> is not counted.
510
<<wprintf>> and <<fwprintf>> return the number of characters transmitted.
511
 
512
If an error occurs, the result of <<wprintf>>, <<fwprintf>>, and
513
<<swprintf>> is a negative value.  For <<wprintf>> and <<fwprintf>>,
514
<<errno>> may be set according to <<fputwc>>.  For <<swprintf>>, <<errno>>
515
may be set to EOVERFLOW if <[size]> is greater than INT_MAX / sizeof (wchar_t),
516
or when the output does not fit into <[size]> wide characters (including the
517
terminating wide <<NULL>>).
518
 
519
BUGS
520
The ``''' (quote) flag does not work when locale's thousands_sep is not empty.
521
 
522
PORTABILITY
523
POSIX-1.2008 with extensions; C99 (compliant except for POSIX extensions).
524
 
525
Depending on how newlib was configured, not all format specifiers are
526
supported.
527
 
528
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
529
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
530
*/
531
 
532
 
533
#include <_ansi.h>
534
#include <reent.h>
535
#include <stdio.h>
536
#include <wchar.h>
537
#include <stdarg.h>
538
#include <limits.h>
539
#include <errno.h>
540
#include "local.h"
541
 
542
/* NOTE:  _swprintf_r() should be identical to swprintf() except for the
543
 * former having ptr as a parameter and the latter needing to declare it as
544
 * a variable set to _REENT.  */
545
 
546
int
547
_DEFUN(_swprintf_r, (ptr, str, size, fmt),
548
       struct _reent *ptr _AND
549
       wchar_t *str          _AND
550
       size_t size        _AND
551
       _CONST wchar_t *fmt _DOTS)
552
{
553
  int ret;
554
  va_list ap;
555
  FILE f;
556
 
557
  if (size > INT_MAX / sizeof (wchar_t))
558
    {
559
      ptr->_errno = EOVERFLOW;  /* POSIX extension */
560
      return EOF;
561
    }
562
  f._flags = __SWR | __SSTR;
563
  f._bf._base = f._p = (unsigned char *) str;
564
  f._bf._size = f._w = (size > 0 ? (size - 1) * sizeof (wchar_t) : 0);
565
  f._file = -1;  /* No file. */
566
  va_start (ap, fmt);
567
  ret = _svfwprintf_r (ptr, &f, fmt, ap);
568
  va_end (ap);
569
  /* _svfwprintf_r() does not put in a terminating NUL, so add one if
570
   * appropriate, which is whenever size is > 0.  _svfwprintf_r() stops
571
   * after n-1, so always just put at the end.  */
572
  if (size > 0)  {
573
    *(wchar_t *)f._p = L'\0';   /* terminate the string */
574
  }
575
  if(ret >= size)  {
576
    /* _svfwprintf_r() returns how many wide characters it would have printed
577
     * if there were enough space.  Return an error if too big to fit in str,
578
     * unlike snprintf, which returns the size needed.  */
579
    ptr->_errno = EOVERFLOW;    /* POSIX extension */
580
    ret = -1;
581
  }
582
  return (ret);
583
}
584
 
585
#ifndef _REENT_ONLY
586
 
587
int
588
_DEFUN(swprintf, (str, size, fmt),
589
       wchar_t *str   _AND
590
       size_t size _AND
591
       _CONST wchar_t *fmt _DOTS)
592
{
593
  int ret;
594
  va_list ap;
595
  FILE f;
596
  struct _reent *ptr = _REENT;
597
 
598
  if (size > INT_MAX / sizeof (wchar_t))
599
    {
600
      ptr->_errno = EOVERFLOW;  /* POSIX extension */
601
      return EOF;
602
    }
603
  f._flags = __SWR | __SSTR;
604
  f._bf._base = f._p = (unsigned char *) str;
605
  f._bf._size = f._w = (size > 0 ? (size - 1) * sizeof (wchar_t) : 0);
606
  f._file = -1;  /* No file. */
607
  va_start (ap, fmt);
608
  ret = _svfwprintf_r (ptr, &f, fmt, ap);
609
  va_end (ap);
610
  /* _svfwprintf_r() does not put in a terminating NUL, so add one if
611
   * appropriate, which is whenever size is > 0.  _svfwprintf_r() stops
612
   * after n-1, so always just put at the end.  */
613
  if (size > 0)  {
614
    *(wchar_t *)f._p = L'\0';   /* terminate the string */
615
  }
616
  if(ret >= size)  {
617
    /* _svfwprintf_r() returns how many wide characters it would have printed
618
     * if there were enough space.  Return an error if too big to fit in str,
619
     * unlike snprintf, which returns the size needed.  */
620
    ptr->_errno = EOVERFLOW;    /* POSIX extension */
621
    ret = -1;
622
  }
623
  return (ret);
624
}
625
 
626
#endif

powered by: WebSVN 2.1.0

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