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/fmtsetcol.x | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sys/fmtio/fmtsetcol.x (limited to 'sys/fmtio/fmtsetcol.x') diff --git a/sys/fmtio/fmtsetcol.x b/sys/fmtio/fmtsetcol.x new file mode 100644 index 00000000..a8d06855 --- /dev/null +++ b/sys/fmtio/fmtsetcol.x @@ -0,0 +1,28 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include + +# FMT_SETCOL -- Called when a control character is output, to keep track of +# the column index during output, for the "%nt" (tabulate) format. Columns +# are indexed from the start of the printf, rather than in absolute units on +# the output, unless a \r or \n is output during the print. + +procedure fmt_setcol (ch, col) + +char ch +int col + +begin + switch (ch) { + case '\t': # next tab stop + col = ((col + TABSTOP-1) / TABSTOP) * TABSTOP + 1 + case '\n', '\r', '\f': + col = 1 + case '\b': + col = col - 1 + default: + if (IS_PRINT (ch)) + col = col + 1 + } +end -- cgit