diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /pkg/xtools/inlfit/inlstrext.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/xtools/inlfit/inlstrext.x')
-rw-r--r-- | pkg/xtools/inlfit/inlstrext.x | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/pkg/xtools/inlfit/inlstrext.x b/pkg/xtools/inlfit/inlstrext.x new file mode 100644 index 00000000..b2b071d9 --- /dev/null +++ b/pkg/xtools/inlfit/inlstrext.x @@ -0,0 +1,47 @@ +include <ctype.h> + +# INLSTREXT - Extract a word (delimited substring) from a string. +# The input string is scanned from the given initial value until one +# of the delimiters is found. The delimiters are not included in the +# output word. +# Leading white spaces in a word may be optionally skipped. White +# spaces are skipped before looking at the delimiters string, so it's +# possible to remove leading white spaces and use them as delimiters +# at the same time. +# The value returned is the number of characters in the output string. +# Upon return, the pointer is located at the begining of the next word. + +int procedure inlstrext (str, ip, dict, skip, outstr, maxch) + +char str[ARB] # input string +int ip # pointer into input string +char dict[ARB] # dictionary of delimiters +int skip # skip leading white spaces ? +char outstr[ARB] # extracted word +int maxch # max number of chars + +int op +int stridx() + +begin + # Skip leading white spaces + if (skip == YES) { + while (IS_WHITE (str[ip])) + ip = ip + 1 + } + + # Process input string + for (op=1; str[ip] != EOS && op <= maxch; op=op+1) + if (stridx (str[ip], dict) == 0) { + outstr[op] = str[ip] + ip = ip + 1 + } else { + repeat { + ip = ip + 1 + } until (stridx (str[ip], dict) == 0 || str[ip] == EOS) + break + } + + outstr[op] = EOS + return (op - 1) +end |