summaryrefslogtreecommitdiff
path: root/src/inp_str.c
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2009-03-19 19:27:12 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2009-03-19 19:27:12 +0000
commitf8ab5b5dc3961522317426ace0d50bd8603aed33 (patch)
treeae73b48af13d41c079854949e41b2b473bbaa748 /src/inp_str.c
parent5cc61408d251b37504a19591dfa12392692b276d (diff)
downloadmpc-f8ab5b5dc3961522317426ace0d50bd8603aed33.tar.gz
implementation of new mpc_inp_str semantics
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@490 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src/inp_str.c')
-rw-r--r--src/inp_str.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/inp_str.c b/src/inp_str.c
index 4f7cec4..7910416 100644
--- a/src/inp_str.c
+++ b/src/inp_str.c
@@ -55,9 +55,9 @@ mpc_realloc_str (char * str, size_t oldlen, size_t newlen) {
}
-size_t
-mpc_inp_str (mpc_ptr rop, FILE *stream, int base, mpc_rnd_t rnd_mode) {
- size_t white, nread;
+int
+mpc_inp_str (mpc_ptr rop, FILE *stream, size_t *read, int base, mpc_rnd_t rnd_mode) {
+ size_t white, nread = 0;
int inex = -1;
int c;
int par = 0;
@@ -73,7 +73,6 @@ mpc_inp_str (mpc_ptr rop, FILE *stream, int base, mpc_rnd_t rnd_mode) {
Then have mpc_setstr do the work. */
size_t strsize = 100;
char *str = mpc_alloc_str (strsize);
- nread = 0;
if (c == '(')
par = 1;
while (c != EOF &&
@@ -104,8 +103,8 @@ mpc_inp_str (mpc_ptr rop, FILE *stream, int base, mpc_rnd_t rnd_mode) {
if (inex == -1) {
mpfr_set_nan (MPC_RE(rop));
mpfr_set_nan (MPC_IM(rop));
- return 0;
}
- else
- return white + nread;
+ if (read != NULL)
+ *read = white + nread;
+ return inex;
}