Skip to content

Commit 968b49b

Browse files
Sannisbnoordhuis
authored andcommitted
Check for tabs in source line in DisplayExceptionLine
Fix for nodejs#3280
1 parent ca642b0 commit 968b49b

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

src/node.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,13 +1271,13 @@ void DisplayExceptionLine (TryCatch &try_catch) {
12711271
// Print wavy underline (GetUnderline is deprecated).
12721272
int start = message->GetStartColumn();
12731273
for (int i = offset; i < start; i++) {
1274-
fprintf(stderr, " ");
1274+
fputc((sourceline_string[i] == '\t') ? '\t' : ' ', stderr);
12751275
}
12761276
int end = message->GetEndColumn();
12771277
for (int i = start; i < end; i++) {
1278-
fprintf(stderr, "^");
1278+
fputc('^', stderr);
12791279
}
1280-
fprintf(stderr, "\n");
1280+
fputc('\n', stderr);
12811281
}
12821282
}
12831283

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright Joyent, Inc. and other Node contributors.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a
4+
// copy of this software and associated documentation files (the
5+
// "Software"), to deal in the Software without restriction, including
6+
// without limitation the rights to use, copy, modify, merge, publish,
7+
// distribute, sublicense, and/or sell copies of the Software, and to permit
8+
// persons to whom the Software is furnished to do so, subject to the
9+
// following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included
12+
// in all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
23+
24+
25+
var common = require('../common');
26+
var assert = require('assert');
27+
28+
common.error('before');
29+
30+
(function () {
31+
// these lines should contain tab!
32+
throw ({ foo: 'bar' });
33+
})();
34+
35+
common.error('after');
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
before
2+
3+
*/test/message/throw_in_line_with_tabs.js:32
4+
throw ({ foo: 'bar' });
5+
^
6+
[object Object]

0 commit comments

Comments
 (0)