aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbhfcm.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/tbtables/tbhfcm.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/tbtables/tbhfcm.x')
-rw-r--r--pkg/tbtables/tbhfcm.x56
1 files changed, 56 insertions, 0 deletions
diff --git a/pkg/tbtables/tbhfcm.x b/pkg/tbtables/tbhfcm.x
new file mode 100644
index 00000000..7dfdc22f
--- /dev/null
+++ b/pkg/tbtables/tbhfcm.x
@@ -0,0 +1,56 @@
+include <ctype.h> # defines IS_WHITE
+include <tbset.h>
+
+# tbhfcm -- find a comment in a header parameter string
+# This locates the comment, if present, in a text string containing a
+# header parameter.
+# The returned value of index will be zero if no comment was found.
+# If a comment was found, par[index] will be the first character of
+# the comment.
+# The input string should be the complete parameter record; that is,
+# it includes the keyword name, data type, value, and optional comment.
+#
+# Phil Hodge, 6-Mar-1995 Subroutine created.
+# Phil Hodge, 12-May-1995 Check for both ' and " as string delimiter.
+
+procedure tbhfcm (par, index)
+
+char par[ARB] # i: string containing header parameter
+int index # o: index of beginning of comment, or zero
+#--
+pointer sp
+pointer word # scratch for the parameter value
+int ip, nchar, ctowrd()
+int strlen()
+
+begin
+ index = 0 # initial value
+
+ if (strlen (par) < START_OF_VALUE)
+ return
+
+ # If a parameter of type text does not begin with a quote,
+ # it doesn't have an associated comment.
+ if (par[LOCN_DTYPE] == 't') {
+ if (par[START_OF_VALUE] != '"' && par[START_OF_VALUE] != '\'')
+ return
+ }
+
+ call smark (sp)
+ call salloc (word, SZ_PARREC, TY_CHAR)
+
+ # Skip over the value.
+ ip = START_OF_VALUE
+ nchar = ctowrd (par, ip, Memc[word], SZ_PARREC)
+
+ # Check whether anything follows the value. Skip whitespace.
+ while (IS_WHITE(par[ip]))
+ ip = ip + 1
+
+ # If there is a comment, set index to the first character
+ # of the comment.
+ if (par[ip] != EOS)
+ index = ip
+
+ call sfree (sp)
+end