aboutsummaryrefslogtreecommitdiff
path: root/pkg/system/help/lroff/nextcmd.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/system/help/lroff/nextcmd.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/system/help/lroff/nextcmd.x')
-rw-r--r--pkg/system/help/lroff/nextcmd.x56
1 files changed, 56 insertions, 0 deletions
diff --git a/pkg/system/help/lroff/nextcmd.x b/pkg/system/help/lroff/nextcmd.x
new file mode 100644
index 00000000..d4b09f44
--- /dev/null
+++ b/pkg/system/help/lroff/nextcmd.x
@@ -0,0 +1,56 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <ctype.h>
+include "lroff.h"
+
+.help nextcmd
+.nf ________________________________________________________________________
+NEXTCMD -- Examine the input line; if it is an Lroff directive, return
+the integer code of the directive, otherwise NULL. Leave IP pointing
+to the argument field if a command, otherwise leave it pointing at the
+first char of the text line. Note that the "directives" string must
+match the opcode definitions given in lroff.h
+.endhelp ___________________________________________________________________
+
+define SZ_OPCODE 2
+
+int procedure nextcmd (linebuf, ip)
+
+char linebuf[ARB]
+int ip, op
+char opcode[SZ_OPCODE]
+int command, kwp, strmatch(), strncmp()
+string directives "finfjunjrjshihnhbrcespinlslebptpkskehrhn"
+
+begin
+ if (linebuf[1] != '.') # not a command line?
+ return (NULL)
+ if (strmatch (linebuf, "^.endhelp") > 0)
+ return (ENDHELP)
+ ip = 2 # skip the '.'
+
+ # Directives may be either upper or lower case.
+ for (op=1; op <= SZ_OPCODE; op=op+1) {
+ opcode[op] = linebuf[ip]
+ if (IS_UPPER (opcode[op]))
+ opcode[op] = TO_LOWER (opcode[op])
+ ip = ip + 1
+ }
+
+ # Just in case a directive happens to be longer than 2 chars, make
+ # sure IP points past the directive name.
+ while (IS_ALPHA (linebuf[ip]))
+ ip = ip + 1
+
+ # Lookup directive, return opcode number if found.
+ command = NULL
+ for (kwp=1; directives[kwp] != EOS; kwp=kwp+SZ_OPCODE)
+ if (strncmp (opcode, directives[kwp], SZ_OPCODE) == 0) {
+ command = (kwp+1) / SZ_OPCODE
+ break
+ }
+
+ if (command == NULL) # unrecognized directive
+ ip = 1
+ return (command)
+end