aboutsummaryrefslogtreecommitdiff
path: root/sys/fmtio/fmtsetcol.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/fmtsetcol.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fmtio/fmtsetcol.x')
-rw-r--r--sys/fmtio/fmtsetcol.x28
1 files changed, 28 insertions, 0 deletions
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 <ctype.h>
+include <printf.h>
+
+# 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