From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/fmtio/ctox.x | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 sys/fmtio/ctox.x (limited to 'sys/fmtio/ctox.x') diff --git a/sys/fmtio/ctox.x b/sys/fmtio/ctox.x new file mode 100644 index 00000000..3f0479a2 --- /dev/null +++ b/sys/fmtio/ctox.x @@ -0,0 +1,48 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include + +# CTOX -- Convert a character string into a complex number. The complex +# number must have the form (r,i), with no embedded whitespace (GCTOX is +# cabable of accepting numbers in other formats). + +int procedure ctox (str, ip, xval) + +char str[ARB] +int ip, ip_save +double dval1, dval2 +complex xval +int ctod() +define notanumber_ 99 + +begin + while (IS_WHITE (str[ip])) + ip = ip + 1 + ip_save = ip + dval2 = 0.0d0 + + if (str[ip] == '(') { # x = (r1,r2) + ip = ip + 1 + if (ctod (str, ip, dval1) <= 0) + goto notanumber_ + if (str[ip] != ',') + goto notanumber_ + ip = ip + 1 + if (ctod (str, ip, dval2) <= 0) + goto notanumber_ + if (str[ip] != ')') + goto notanumber_ + ip = ip + 1 + } else + goto notanumber_ + + if (IS_INDEFD(dval1) || IS_INDEFD(dval2)) + xval = INDEFX + else + xval = complex (dval1, dval2) + return (ip - ip_save) + +notanumber_ + ip = ip_save + return (0) +end -- cgit