aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbhgcm.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/tbhgcm.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/tbtables/tbhgcm.x')
-rw-r--r--pkg/tbtables/tbhgcm.x75
1 files changed, 75 insertions, 0 deletions
diff --git a/pkg/tbtables/tbhgcm.x b/pkg/tbtables/tbhgcm.x
new file mode 100644
index 00000000..64b34948
--- /dev/null
+++ b/pkg/tbtables/tbhgcm.x
@@ -0,0 +1,75 @@
+include <tbset.h>
+include "tbtables.h"
+
+# tbhgcm -- get a comment from a header parameter
+# This reads the comment from a header parameter. It is an error if
+# the keyword is not found, but there need not be an associated comment.
+# Trailing blanks are removed from the comment.
+#
+# Phil Hodge, 6-Mar-1995 Subroutine created.
+# Phil Hodge, 8-Jun-1995 Modify for FITS tables.
+# Phil Hodge, 7-Jun-1999 Handle text tables.
+
+procedure tbhgcm (tp, keyword, comment, maxch)
+
+pointer tp # i: pointer to table descriptor
+char keyword[SZ_KEYWORD] # i: keyword to be found
+char comment[ARB] # o: comment string for keyword
+int maxch # i: max size of comment
+#--
+pointer sp
+pointer errmsg # scratch for possible error message
+pointer str # scratch for string read from header
+int parnum # number of the parameter
+int index # location of comment within string
+int i
+int strlen()
+bool tbhisc()
+
+begin
+ if (TB_TYPE(tp) == TBL_TYPE_FITS) {
+ call tbfgcm (tp, keyword, comment, maxch)
+ return
+ }
+
+ # We don't read a comment from a comment.
+ if (tbhisc (keyword)) {
+ comment[1] = EOS
+ return
+ }
+
+ call smark (sp)
+ call salloc (str, SZ_PARREC, TY_CHAR)
+
+ # Find the keyword in the header.
+ call tbhfkw (tp, keyword, parnum)
+ if (parnum < 1) {
+ call salloc (errmsg, SZ_FNAME, TY_CHAR)
+ call sprintf (Memc[errmsg], SZ_FNAME,
+ "tbhgcm: keyword `%s' not found in table `%s'")
+ call pargstr (keyword)
+ call pargstr (TB_NAME(tp))
+ call error (1, Memc[errmsg])
+ }
+
+ # Read the string containing keyword, datatype, value.
+ call tbhrpr (tp, parnum, Memc[str])
+
+ # Search for a comment.
+ call tbhfcm (Memc[str], index)
+
+ if (index > 0)
+ call strcpy (Memc[str+index-1], comment, maxch)
+ else
+ comment[1] = EOS # no comment
+
+ # Trim trailing blanks.
+ do i = strlen (comment), 1, -1 {
+ if (comment[i] == ' ')
+ comment[i] = EOS
+ else
+ break
+ }
+
+ call sfree (sp)
+end