aboutsummaryrefslogtreecommitdiff
path: root/sys/fmtio/fprntf.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/fmtio/fprntf.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fmtio/fprntf.x')
-rw-r--r--sys/fmtio/fprntf.x40
1 files changed, 40 insertions, 0 deletions
diff --git a/sys/fmtio/fprntf.x b/sys/fmtio/fprntf.x
new file mode 100644
index 00000000..095b57b2
--- /dev/null
+++ b/sys/fmtio/fprntf.x
@@ -0,0 +1,40 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <printf.h>
+
+# FPRNTF -- Initiate a formatted print. Called by FPRINTF, SPRINTF, etc.
+# Check that the previous print has completed, initialize the current
+# print, and advance to the first format specification (if any).
+
+procedure fprntf (new_fd, format_string, file_type)
+
+int new_fd, file_type
+char format_string[ARB]
+include "fmt.com"
+
+begin
+ # Printf is not reentrant. An expression in a PARG_ call must not
+ # directly or indirectly call any of the printf entry points. There
+ # must be a PARG_ for each "%w.dC" format specification in the format
+ # string. Errors result in lost output, but are otherwise harmless,
+ # and are diagnosed below.
+
+ if (format[ip] != EOS) {
+ call putline (STDERR, "Warning: Incomplete or reentrant printf\n")
+ call fmt_err ("Old ", format, ip)
+ call fmt_err ("New ", format_string, ARB)
+
+ while (format[ip] != EOS) # discard rest of format string
+ ip = ip + 1
+ call fpradv() # possibly close mem file
+ }
+
+ fd = new_fd # normal initialization
+ ip = 1
+ col = 1
+ fmt_state = FMT_START # initialize FPRFMT state
+ ofile_type = file_type
+
+ call strcpy (format_string, format, SZ_OBUF)
+ call fpradv()
+end