aboutsummaryrefslogtreecommitdiff
path: root/sys/fmtio/fpradv.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/fmtio/fpradv.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/fmtio/fpradv.x')
-rw-r--r--sys/fmtio/fpradv.x76
1 files changed, 76 insertions, 0 deletions
diff --git a/sys/fmtio/fpradv.x b/sys/fmtio/fpradv.x
new file mode 100644
index 00000000..942c29aa
--- /dev/null
+++ b/sys/fmtio/fpradv.x
@@ -0,0 +1,76 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <ctype.h>
+include <chars.h>
+include <printf.h>
+
+# FPRADV -- Copy format chars to output until next "%w.dC" format sequence is
+# encountered, or until EOS is encountered on format string. When EOS is
+# encountered, return buffer containing format string, and if mem_flag is set,
+# close the output file (a string) as well. If a format string contains no
+# regular format sequences, and hence requires no PARG_ calls, we are all done.
+
+procedure fpradv()
+
+int i, junk, ival, ch
+char cch
+int ip_save
+int ctoi(), cctoc()
+include "fmt.com"
+errchk putci
+
+begin
+ for (ch = format[ip]; ch != EOS; ch = format[ip]) {
+ cch = ch
+ if (ch == ESCAPE) {
+ junk = cctoc (format, ip, cch)
+
+ } else if (ch == START_OF_FORMAT) {
+ if (format[ip+1] == START_OF_FORMAT) # '%%' --> '%'
+ ip = ip + 2
+
+ else if (IS_DIGIT (format[ip+1])) { # %Nw or %Nt
+ ip_save = ip # ip_save --> '%'
+ ip = ip + 1
+
+ junk = ctoi (format, ip, ival)
+
+ switch (format[ip]) {
+ case FMT_WHITESPACE: # output blanks
+ do i = 1, ival
+ call putci (fd, BLANK)
+ col = col + ival
+ case FMT_TOCOLUMN: # advance to column
+ for (; col < ival; col=col+1)
+ call putci (fd, BLANK)
+ default:
+ ip = ip_save # regular format spec
+ return
+ }
+
+ ip = ip + 1 # eat "t" or "w"
+ next
+
+ } else
+ return # regular format spec
+
+ } else
+ ip = ip + 1
+
+ call putc (fd, cch) # output ordinary chars
+ if (IS_PRINT (cch)) # keep track of column
+ col = col + 1
+ else
+ call fmt_setcol (cch, col)
+ }
+
+ switch (ofile_type) { # EOS of format reached
+ case STRING_FILE:
+ call close (fd)
+ case CL_PARAM:
+ call putline (CLOUT, "\"\n")
+ }
+
+ ofile_type = REGULAR_FILE # restore default
+ fd = NULL
+end