aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tcheck/cmdsplit.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 /pkg/utilities/nttools/tcheck/cmdsplit.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/utilities/nttools/tcheck/cmdsplit.x')
-rw-r--r--pkg/utilities/nttools/tcheck/cmdsplit.x57
1 files changed, 57 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/tcheck/cmdsplit.x b/pkg/utilities/nttools/tcheck/cmdsplit.x
new file mode 100644
index 00000000..7fa7e714
--- /dev/null
+++ b/pkg/utilities/nttools/tcheck/cmdsplit.x
@@ -0,0 +1,57 @@
+include "tcheck.h"
+
+# CMDSPLIT -- Split a command into keyword and expression strings
+
+procedure cmdsplit (command, keystart, cmdstart)
+
+char command[ARB] # io: Command line
+int keystart # o: Start of keyword substring
+int cmdstart # o: Start of command substring
+#--
+char comment
+int ic, jc
+pointer sp, keyword
+
+data comment / '#' /
+
+string noexpress "No expression following when"
+
+bool streq()
+int stridx(), word_fetch()
+
+begin
+ call smark (sp)
+ call salloc (keyword, SZ_FNAME, TY_CHAR)
+
+ # Strip comments from command line
+
+ ic = stridx (comment, command)
+ if (ic > 0)
+ command[ic] = EOS
+
+ # Set output variables to default values
+
+ keystart = 1
+ cmdstart = 0
+
+ # Find location of "when" in command and split the line there
+
+ ic = 1
+ jc = 0
+ while (word_fetch (command, ic, Memc[keyword], SZ_FNAME) > 0) {
+ if (jc > 0 && streq (Memc[keyword], "when")) {
+ command[jc] = EOS
+ cmdstart = ic
+ break
+ }
+ jc = ic
+ }
+
+ # Exit with error if no expression was found
+
+ if (cmdstart == 0 && jc > 0)
+ call error (SYNTAX, noexpress)
+
+ call sfree (sp)
+end
+