From 38a0419a729fde595309fe504442e55adc3d0e4a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 25 May 2013 01:01:05 +0200 Subject: [PATCH] package info parser: improve parse error column numbers Assume 4 column tab stops and compute the column numbers accordingly. --- src/kits/package/PackageInfoParser.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/kits/package/PackageInfoParser.cpp b/src/kits/package/PackageInfoParser.cpp index 1bce2a1ab5..9d0e0ec89a 100644 --- a/src/kits/package/PackageInfoParser.cpp +++ b/src/kits/package/PackageInfoParser.cpp @@ -43,20 +43,28 @@ BPackageInfo::Parser::Parse(const BString& packageInfoString, if (fListener != NULL) { // map error position to line and column int line = 1; - int column; + int inLineOffset; int32 offset = error.pos - packageInfoString.String(); int32 newlinePos = packageInfoString.FindLast('\n', offset - 1); if (newlinePos < 0) - column = offset; + inLineOffset = offset; else { - column = offset - newlinePos; + inLineOffset = offset - newlinePos - 1; do { line++; newlinePos = packageInfoString.FindLast('\n', newlinePos - 1); } while (newlinePos >= 0); } - fListener->OnError(error.message, line, column); + + int column = 0; + for (int i = 0; i < inLineOffset; i++) { + column++; + if (error.pos[i - inLineOffset] == '\t') + column = (column + 3) / 4 * 4; + } + + fListener->OnError(error.message, line, column + 1); } return B_BAD_DATA; } catch (const std::bad_alloc& e) {