18fa80f29Smrg /* mpc_set_str -- Convert a string into a complex number.
28fa80f29Smrg
3*367b8279Smrg Copyright (C) 2009, 2010, 2011, 2022 INRIA
48fa80f29Smrg
58fa80f29Smrg This file is part of GNU MPC.
68fa80f29Smrg
78fa80f29Smrg GNU MPC is free software; you can redistribute it and/or modify it under
88fa80f29Smrg the terms of the GNU Lesser General Public License as published by the
98fa80f29Smrg Free Software Foundation; either version 3 of the License, or (at your
108fa80f29Smrg option) any later version.
118fa80f29Smrg
128fa80f29Smrg GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
138fa80f29Smrg WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
148fa80f29Smrg FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
158fa80f29Smrg more details.
168fa80f29Smrg
178fa80f29Smrg You should have received a copy of the GNU Lesser General Public License
188fa80f29Smrg along with this program. If not, see http://www.gnu.org/licenses/ .
198fa80f29Smrg */
208fa80f29Smrg
218fa80f29Smrg #include <ctype.h>
228fa80f29Smrg #include "mpc-impl.h"
238fa80f29Smrg
248fa80f29Smrg int
mpc_set_str(mpc_ptr z,const char * str,int base,mpc_rnd_t rnd)25*367b8279Smrg mpc_set_str (mpc_ptr z, const char *str, int base, mpc_rnd_t rnd)
268fa80f29Smrg {
278fa80f29Smrg char *p;
288fa80f29Smrg int inex;
298fa80f29Smrg
308fa80f29Smrg inex = mpc_strtoc (z, str, &p, base, rnd);
318fa80f29Smrg
328fa80f29Smrg if (inex != -1){
338fa80f29Smrg while (isspace ((unsigned char) (*p)))
348fa80f29Smrg p++;
358fa80f29Smrg if (*p == '\0')
368fa80f29Smrg return inex;
378fa80f29Smrg }
388fa80f29Smrg
398fa80f29Smrg mpfr_set_nan (mpc_realref (z));
408fa80f29Smrg mpfr_set_nan (mpc_imagref (z));
418fa80f29Smrg return -1;
428fa80f29Smrg }
43