source: trunk/third/gmp/printf/obprntffuns.c @ 18191

Revision 18191, 1.9 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18190, which included commits to RCS files with non-trunk default branches.
Line 
1/* __gmp_obstack_printf_funs -- support for gmp_obstack_printf and
2   gmp_obstack_vprintf.
3
4   THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY.  THEY'RE ALMOST
5   CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
6   FUTURE GNU MP RELEASES.
7
8Copyright 2001 Free Software Foundation, Inc.
9
10This file is part of the GNU MP Library.
11
12The GNU MP Library is free software; you can redistribute it and/or modify
13it under the terms of the GNU Lesser General Public License as published by
14the Free Software Foundation; either version 2.1 of the License, or (at your
15option) any later version.
16
17The GNU MP Library is distributed in the hope that it will be useful, but
18WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
20License for more details.
21
22You should have received a copy of the GNU Lesser General Public License
23along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
24the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25MA 02111-1307, USA. */
26
27#include "config.h"
28
29#if HAVE_OBSTACK_VPRINTF
30
31#define _GNU_SOURCE   /* ask glibc <stdio.h> for obstack_vprintf */
32
33#if HAVE_STDARG
34#include <stdarg.h>
35#else
36#include <varargs.h>
37#endif
38
39#include <stdio.h>    /* for obstack_vprintf */
40#include <string.h>
41#include <obstack.h>
42
43#include "gmp.h"
44#include "gmp-impl.h"
45
46
47static int
48gmp_obstack_memory (struct obstack *ob, const char *ptr, size_t len)
49{
50  obstack_grow (ob, ptr, len);
51  return len; 
52}
53
54static int
55gmp_obstack_reps (struct obstack *ob, int c, int reps)
56{
57  obstack_blank (ob, reps);
58  memset ((char *) obstack_next_free(ob) - reps, c, reps);
59  return reps;
60}
61
62const struct doprnt_funs_t  __gmp_obstack_printf_funs = {
63  (doprnt_format_t) obstack_vprintf,
64  (doprnt_memory_t) gmp_obstack_memory,
65  (doprnt_reps_t)   gmp_obstack_reps
66};
67
68#endif /* HAVE_OBSTACK_VPRINTF */
Note: See TracBrowser for help on using the repository browser.