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 1996, 2000, 2001, 2002, 2005 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 Lesser General Public License as published by
10 the Free Software Foundation; either version 3 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 Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
27 mpf_inp_str (mpf_ptr rop
, FILE *stream
, int base
)
30 size_t alloc_size
, str_size
;
39 str
= (char *) (*__gmp_allocate_func
) (alloc_size
);
43 /* Skip whitespace. */
53 if (str_size
>= alloc_size
)
55 size_t old_alloc_size
= alloc_size
;
56 alloc_size
= alloc_size
* 3 / 2;
57 str
= (char *) (*__gmp_reallocate_func
) (str
, old_alloc_size
, alloc_size
);
59 if (c
== EOF
|| isspace (c
))
67 if (str_size
>= alloc_size
)
69 size_t old_alloc_size
= alloc_size
;
70 alloc_size
= alloc_size
* 3 / 2;
71 str
= (char *) (*__gmp_reallocate_func
) (str
, old_alloc_size
, alloc_size
);
75 res
= mpf_set_str (rop
, str
, base
);
76 (*__gmp_free_func
) (str
, alloc_size
);
81 return str_size
+ nread
;