aboutsummaryrefslogtreecommitdiff
path: root/sys/fmtio/ctox.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/fmtio/ctox.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fmtio/ctox.x')
-rw-r--r--sys/fmtio/ctox.x48
1 files changed, 48 insertions, 0 deletions
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 <ctype.h>
+
+# 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