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

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [newlib/] [libc/] [stdio/] [snprintf.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 56 joel
/* doc in sprintf.c */
2
 
3
/* This code created by modifying sprintf.c so copyright inherited. */
4
 
5
/*
6
 * Copyright (c) 1990 The Regents of the University of California.
7
 * All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms are permitted
10
 * provided that the above copyright notice and this paragraph are
11
 * duplicated in all such forms and that any documentation,
12
 * advertising materials, and other materials related to such
13
 * distribution and use acknowledge that the software was developed
14
 * by the University of California, Berkeley.  The name of the
15
 * University may not be used to endorse or promote products derived
16
 * from this software without specific prior written permission.
17
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20
 */
21
 
22
#include <stdio.h>
23
#ifdef _HAVE_STDC
24
#include <stdarg.h>
25
#else
26
#include <varargs.h>
27
#endif
28
#include <limits.h>
29
#include <_ansi.h>
30
#include "local.h"
31
 
32
int
33
#ifdef _HAVE_STDC
34
_DEFUN (_snprintf_r, (ptr, str, size, fmt), struct _reent *ptr _AND char *str _AND size_t size _AND _CONST char *fmt _DOTS)
35
#else
36
_snprintf_r (ptr, str, size, fmt, va_alist)
37
     struct _reent *ptr;
38
     char *str;
39
     size_t size;
40
     _CONST char *fmt;
41
     va_dcl
42
#endif
43
{
44
  int ret;
45
  va_list ap;
46
  FILE f;
47
 
48
  f._flags = __SWR | __SSTR;
49
  f._bf._base = f._p = (unsigned char *) str;
50
  f._bf._size = f._w = size;
51
  f._data = ptr;
52
#ifdef _HAVE_STDC
53
  va_start (ap, fmt);
54
#else
55
  va_start (ap);
56
#endif
57
  ret = vfprintf (&f, fmt, ap);
58
  va_end (ap);
59
  *f._p = 0;
60
  return (ret);
61
}
62
 
63
#ifndef _REENT_ONLY
64
 
65
int
66
#ifdef _HAVE_STDC
67
_DEFUN (snprintf, (str, size, fmt), char *str _AND size_t size _AND _CONST char *fmt _DOTS)
68
#else
69
snprintf (str, size, fmt, va_alist)
70
     char *str;
71
     size_t size;
72
     _CONST char *fmt;
73
     va_dcl
74
#endif
75
{
76
  int ret;
77
  va_list ap;
78
  FILE f;
79
 
80
  f._flags = __SWR | __SSTR;
81
  f._bf._base = f._p = (unsigned char *) str;
82
  f._bf._size = f._w = size;
83
  f._data = _REENT;
84
#ifdef _HAVE_STDC
85
  va_start (ap, fmt);
86
#else
87
  va_start (ap);
88
#endif
89
  ret = vfprintf (&f, fmt, ap);
90
  va_end (ap);
91
  *f._p = 0;
92
  return (ret);
93
}
94
 
95
#endif

powered by: WebSVN 2.1.0

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