summaryrefslogtreecommitdiff
path: root/libgo/go/tabwriter/tabwriter.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/tabwriter/tabwriter.go')
-rw-r--r--libgo/go/tabwriter/tabwriter.go27
1 files changed, 1 insertions, 26 deletions
diff --git a/libgo/go/tabwriter/tabwriter.go b/libgo/go/tabwriter/tabwriter.go
index d91a07db242..2f35d961eb2 100644
--- a/libgo/go/tabwriter/tabwriter.go
+++ b/libgo/go/tabwriter/tabwriter.go
@@ -17,7 +17,6 @@ import (
"utf8"
)
-
// ----------------------------------------------------------------------------
// Filter implementation
@@ -32,7 +31,6 @@ type cell struct {
htab bool // true if the cell is terminated by an htab ('\t')
}
-
// A Writer is a filter that inserts padding around tab-delimited
// columns in its input to align them in the output.
//
@@ -95,10 +93,8 @@ type Writer struct {
widths []int // list of column widths in runes - re-used during formatting
}
-
func (b *Writer) addLine() { b.lines = append(b.lines, []cell{}) }
-
// Reset the current state.
func (b *Writer) reset() {
b.buf.Reset()
@@ -110,7 +106,6 @@ func (b *Writer) reset() {
b.addLine()
}
-
// Internal representation (current state):
//
// - all text written is appended to buf; tabs and line breaks are stripped away
@@ -134,7 +129,6 @@ func (b *Writer) reset() {
// | | |
// buf start of incomplete cell pos
-
// Formatting can be controlled with these flags.
const (
// Ignore html tags and treat entities (starting with '&'
@@ -158,11 +152,10 @@ const (
TabIndent
// Print a vertical bar ('|') between columns (after formatting).
- // Discarded colums appear as zero-width columns ("||").
+ // Discarded columns appear as zero-width columns ("||").
Debug
)
-
// A Writer must be initialized with a call to Init. The first parameter (output)
// specifies the filter output. The remaining parameters control the formatting:
//
@@ -205,7 +198,6 @@ func (b *Writer) Init(output io.Writer, minwidth, tabwidth, padding int, padchar
return b
}
-
// debugging support (keep code around)
func (b *Writer) dump() {
pos := 0
@@ -220,14 +212,12 @@ func (b *Writer) dump() {
print("\n")
}
-
// local error wrapper so we can distinguish os.Errors we want to return
// as errors from genuine panics (which we don't want to return as errors)
type osError struct {
err os.Error
}
-
func (b *Writer) write0(buf []byte) {
n, err := b.output.Write(buf)
if n != len(buf) && err == nil {
@@ -238,7 +228,6 @@ func (b *Writer) write0(buf []byte) {
}
}
-
func (b *Writer) writeN(src []byte, n int) {
for n > len(src) {
b.write0(src)
@@ -247,13 +236,11 @@ func (b *Writer) writeN(src []byte, n int) {
b.write0(src[0:n])
}
-
var (
newline = []byte{'\n'}
tabs = []byte("\t\t\t\t\t\t\t\t")
)
-
func (b *Writer) writePadding(textw, cellw int, useTabs bool) {
if b.padbytes[0] == '\t' || useTabs {
// padding is done with tabs
@@ -274,7 +261,6 @@ func (b *Writer) writePadding(textw, cellw int, useTabs bool) {
b.writeN(b.padbytes[0:], cellw-textw)
}
-
var vbar = []byte{'|'}
func (b *Writer) writeLines(pos0 int, line0, line1 int) (pos int) {
@@ -328,7 +314,6 @@ func (b *Writer) writeLines(pos0 int, line0, line1 int) (pos int) {
return
}
-
// Format the text between line0 and line1 (excluding line1); pos
// is the buffer position corresponding to the beginning of line0.
// Returns the buffer position corresponding to the beginning of
@@ -392,21 +377,18 @@ func (b *Writer) format(pos0 int, line0, line1 int) (pos int) {
return b.writeLines(pos, line0, line1)
}
-
// Append text to current cell.
func (b *Writer) append(text []byte) {
b.buf.Write(text)
b.cell.size += len(text)
}
-
// Update the cell width.
func (b *Writer) updateWidth() {
b.cell.width += utf8.RuneCount(b.buf.Bytes()[b.pos:b.buf.Len()])
b.pos = b.buf.Len()
}
-
// To escape a text segment, bracket it with Escape characters.
// For instance, the tab in this string "Ignore this tab: \xff\t\xff"
// does not terminate a cell and constitutes a single character of
@@ -416,7 +398,6 @@ func (b *Writer) updateWidth() {
//
const Escape = '\xff'
-
// Start escaped mode.
func (b *Writer) startEscape(ch byte) {
switch ch {
@@ -429,7 +410,6 @@ func (b *Writer) startEscape(ch byte) {
}
}
-
// Terminate escaped mode. If the escaped text was an HTML tag, its width
// is assumed to be zero for formatting purposes; if it was an HTML entity,
// its width is assumed to be one. In all other cases, the width is the
@@ -450,7 +430,6 @@ func (b *Writer) endEscape() {
b.endChar = 0
}
-
// Terminate the current cell by adding it to the list of cells of the
// current line. Returns the number of cells in that line.
//
@@ -462,14 +441,12 @@ func (b *Writer) terminateCell(htab bool) int {
return len(*line)
}
-
func handlePanic(err *os.Error) {
if e := recover(); e != nil {
*err = e.(osError).err // re-panics if it's not a local osError
}
}
-
// Flush should be called after the last call to Write to ensure
// that any data buffered in the Writer is written to output. Any
// incomplete escape sequence at the end is simply considered
@@ -494,7 +471,6 @@ func (b *Writer) Flush() (err os.Error) {
return
}
-
var hbar = []byte("---\n")
// Write writes buf to the writer b.
@@ -577,7 +553,6 @@ func (b *Writer) Write(buf []byte) (n int, err os.Error) {
return
}
-
// NewWriter allocates and initializes a new tabwriter.Writer.
// The parameters are the same as for the the Init function.
//