From 03668a9b21c484e410ec6cc95eedbecb4a9c8a50 Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Thu, 15 Sep 2016 17:34:14 +0200 Subject: [PATCH] Fix line numbers with --print-changes --- src/astyle_main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/astyle_main.cpp b/src/astyle_main.cpp index bb30b76..cf265a6 100644 --- a/src/astyle_main.cpp +++ b/src/astyle_main.cpp @@ -548,11 +548,13 @@ void ASConsole::formatFile(const string& fileName_) displayName = fileName_; // format the file + int currentLine = 0; while (formatter.hasMoreLines()) { nextLine = formatter.nextLine(); out << nextLine; linesOut++; + currentLine++; if (formatter.hasMoreLines()) { setOutputEOL(lineEndFormat, streamIterator.getOutputEOL()); @@ -569,6 +571,7 @@ void ASConsole::formatFile(const string& fileName_) nextLine = formatter.nextLine(); out << nextLine; linesOut++; + currentLine++; streamIterator.saveLastInputLine(); } } @@ -580,14 +583,14 @@ void ASConsole::formatFile(const string& fileName_) if (nextLine.find_first_not_of(" \t") != string::npos) { if (printChanges) - printChangedLine(displayName, nextLine, linesOut); + printChangedLine(displayName, nextLine, currentLine); filesAreIdentical = false; } } else if (!streamIterator.compareToInputBuffer(nextLine)) { if (printChanges) - printChangedLine(displayName, nextLine, linesOut); + printChangedLine(displayName, nextLine, currentLine); filesAreIdentical = false; } streamIterator.checkForEmptyLine = false;