aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/texpand/span.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/texpand/span.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/utilities/nttools/texpand/span.x')
-rw-r--r--pkg/utilities/nttools/texpand/span.x97
1 files changed, 97 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/texpand/span.x b/pkg/utilities/nttools/texpand/span.x
new file mode 100644
index 00000000..b8d69141
--- /dev/null
+++ b/pkg/utilities/nttools/texpand/span.x
@@ -0,0 +1,97 @@
+# SPAN -- Copy characters while they match a set
+#
+# B.Simon 25-Apr-88 Original
+
+int procedure span (set, str, ic, outstr, maxch)
+
+char set[ARB] # i: Set of characters used in matching
+char str[ARB] # i: Input string
+int ic # io: Index to input string character
+char outstr[ARB] # o: Output string
+int maxch # i: Maximum length of output string
+#--
+bool match
+int jc, kc, setlen
+
+int strlen()
+
+begin
+ # Loop over characters in the input string
+
+ setlen = strlen (set)
+ for (jc = 1; str[ic] != EOS && jc <= maxch; ic = ic + 1) {
+
+ # See if the current character in the input string
+ # matches the characters in the set
+
+ match = false
+ do kc = 1, setlen {
+ if (str[ic] == set[kc]) {
+ match = true
+ break
+ }
+ }
+
+ # Copy character to the output string if it matches
+
+ if (! match)
+ break
+
+ outstr[jc] = str[ic]
+ jc = jc + 1
+
+ }
+
+ # Return number of characters in output string
+
+ outstr[jc] = EOS
+ return (jc - 1)
+end
+
+# NOSPAN -- Copy characters while they do not match a set
+
+int procedure nospan (set, str, ic, outstr, maxch)
+
+char set[ARB] # i: Set of characters used in matching
+char str[ARB] # i: Input string
+int ic # io: Index to input string character
+char outstr[ARB] # o: Output string
+int maxch # i: Maximum length of output string
+#--
+bool match
+int jc, kc, setlen
+
+int strlen()
+
+begin
+ # Loop over characters in the input string
+
+ setlen = strlen (set)
+ for (jc = 1; str[ic] != EOS && jc <= maxch; ic = ic + 1) {
+
+ # See if the current character in the input string
+ # matches the characters in the set
+
+ match = false
+ do kc = 1, setlen {
+ if (str[ic] == set[kc]) {
+ match = true
+ break
+ }
+ }
+
+ # Copy character to the output string if it does not match
+
+ if (match)
+ break
+
+ outstr[jc] = str[ic]
+ jc = jc + 1
+
+ }
+
+ # Return number of characters in output string
+
+ outstr[jc] = EOS
+ return (jc - 1)
+end