From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/fmtio/fprntf.x | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sys/fmtio/fprntf.x (limited to 'sys/fmtio/fprntf.x') 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 + +# 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 -- cgit