-/// ComputeColumn - Examine the current output and figure out which
-/// column we end up in after output.
-void formatted_raw_ostream::ComputeColumn() {
- // The buffer may have been allocated underneath us.
- if (Scanned == 0) Scanned = begin();
- // Scan all characters added since our last scan to determine the new column.
- ColumnScanned = CountColumns(ColumnScanned, Scanned, end() - Scanned);
- // We're now current with everything in the buffer.
- Scanned = end();
+/// ComputePosition - Examine the current output and update line and column
+/// counts.
+void formatted_raw_ostream::ComputePosition(const char *Ptr, size_t Size) {
+ // If our previous scan pointer is inside the buffer, assume we already
+ // scanned those bytes. This depends on raw_ostream to not change our buffer
+ // in unexpected ways.
+ if (Ptr <= Scanned && Scanned <= Ptr + Size)
+ // Scan all characters added since our last scan to determine the new
+ // column.
+ UpdatePosition(Position, Scanned, Size - (Scanned - Ptr));
+ else
+ UpdatePosition(Position, Ptr, Size);
+
+ // Update the scanning pointer.
+ Scanned = Ptr + Size;