aboutsummaryrefslogtreecommitdiff
path: root/sys/imio/dbc/imdrmcom.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 /sys/imio/dbc/imdrmcom.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/imio/dbc/imdrmcom.x')
-rw-r--r--sys/imio/dbc/imdrmcom.x96
1 files changed, 96 insertions, 0 deletions
diff --git a/sys/imio/dbc/imdrmcom.x b/sys/imio/dbc/imdrmcom.x
new file mode 100644
index 00000000..4a10f2df
--- /dev/null
+++ b/sys/imio/dbc/imdrmcom.x
@@ -0,0 +1,96 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <syserr.h>
+include "idbc.h"
+
+# IMDRMCOM -- Remove the comment field for a keyword.
+
+procedure imdrmcom (im, key)
+
+pointer im #I image descriptor
+char key[ARB] #I parameter to be set
+
+bool string_valued
+int ch, i, ti, j, n
+pointer rp, ip, op, sp, val, start, text, cmmt
+int idb_findrecord()
+errchk syserrs
+
+begin
+ call smark (sp)
+ call salloc (val, SZ_LINE, TY_CHAR)
+ call salloc (text, SZ_LINE, TY_CHAR)
+ call salloc (cmmt, SZ_LINE, TY_CHAR)
+
+ # Find the record.
+ if (idb_findrecord (im, key, rp) == 0)
+ call syserrs (SYS_IDBKEYNF, key)
+
+ for (i=0; i<SZ_LINE; i=i+1)
+ Memc[text+i] = ' '
+ Memc[text+SZ_LINE] = EOS
+
+ # Determine the actual datatype of the parameter. String valued
+ # parameters will have an apostrophe in the first nonblank column
+ # of the value field.
+
+ string_valued = false
+ ti = text
+ for (ip=IDB_STARTVALUE; ip <= IDB_ENDVALUE; ip=ip+1) {
+ # Skip leading whitespace.
+ for (; Memc[rp+ip-1] == ' '; ip=ip+1) {
+ Memc[ti] = Memc[rp+ip-1]
+ ti = ti + 1
+ }
+ if (Memc[rp+ip-1] == '\'') {
+ # Get string value.
+ Memc[ti] = Memc[rp+ip-1]
+ ti = ti + 1
+ do i = ip, IDB_RECLEN {
+ ch = Memc[rp+i]
+ Memc[ti] = ch
+ ti = ti + 1
+ if (ch == '\n')
+ break
+ if (ch == '\'')
+ break
+ }
+ break
+
+ } else {
+ # Numeric value.
+ do i = ip, IDB_RECLEN {
+ ch = Memc[rp+i-1]
+ Memc[ti] = ch
+ ti = ti + 1
+ if (ch == '\n' || ch == ' ' || ch == '/')
+ break
+ }
+# if (ch == ' ')
+# ti = ti - 1
+ break
+ }
+ }
+
+ n = 0
+ do j = i, IDB_RECLEN {
+ ch = Memc[rp+j]
+ Memc[cmmt+n] = ch
+ n = n + 1
+ if (ch == '\n') {
+ n = n - 1
+ break
+ }
+ }
+ Memc[cmmt+n] = EOS
+
+ # Update the parameter value.
+ op = rp + IDB_STARTVALUE + ti-text - 1
+ start = op
+ for (ip=ti; Memc[ip] != EOS && Memc[op] != '\n'; ip=ip+1) {
+ Memc[op] = Memc[ip]
+ op = op + 1
+ }
+
+ call sfree (sp)
+end