1 /* mpf_inp_str(dest_float, stream, base) -- Input a number in base
2 BASE from stdio stream STREAM and store the result in DEST_FLOAT.
4 Copyright (C) 1996 Free Software Foundation, Inc.
6 This file is part of the GNU MP Library.
8 The GNU MP Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Library General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or (at your
11 option) any later version.
13 The GNU MP Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16 License for more details.
18 You should have received a copy of the GNU Library General Public License
19 along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 MA 02111-1307, USA. */
30 mpf_inp_str (mpf_ptr rop, FILE *stream, int base)
32 mpf_inp_str (rop, stream, base)
39 size_t alloc_size, str_size;
48 str = (char *) (*_mp_allocate_func) (alloc_size);
52 /* Skip whitespace. */
62 if (str_size >= alloc_size)
64 size_t old_alloc_size = alloc_size;
65 alloc_size = alloc_size * 3 / 2;
66 str = (char *) (*_mp_reallocate_func) (str, old_alloc_size, alloc_size);
68 if (c == EOF || isspace (c))
75 if (str_size >= alloc_size)
77 size_t old_alloc_size = alloc_size;
78 alloc_size = alloc_size * 3 / 2;
79 str = (char *) (*_mp_reallocate_func) (str, old_alloc_size, alloc_size);
83 retval = mpf_set_str (rop, str, base);
87 (*_mp_free_func) (str, alloc_size);
88 return str_size + nread;