summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2017-04-29 18:25:44 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2017-05-05 23:26:30 -0700
commitdb8fe2eab6951bda3a17f63ea5a6d9c801ef8419 (patch)
tree25b3a2cb8abc9394cd563bcdd314bc9b45227b17
parent459e881f32edae33323a0943a26286a79c70fb11 (diff)
downloadgjs-db8fe2eab6951bda3a17f63ea5a6d9c801ef8419.tar.gz
modules/console: Update to js::PrintError from upstream
The existing code doesn't compile with SpiderMonkey 45, so we copy the corresponding code from SpiderMonkey 45's js::PrintError() function.
-rw-r--r--modules/console.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/modules/console.cpp b/modules/console.cpp
index 57a16b7c..df0d5f8b 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -100,20 +100,28 @@ gjs_console_error_reporter(JSContext *cx, const char *message, JSErrorReport *re
fputs(prefix, stderr);
fputs(message, stderr);
- if (report->linebuf) {
- /* report->linebuf usually ends with a newline. */
- int n = strlen(report->linebuf);
- fprintf(stderr, ":\n%s%s%s%s",
- prefix,
- report->linebuf,
- (n > 0 && report->linebuf[n-1] == '\n') ? "" : "\n",
- prefix);
- n = report->tokenptr - report->linebuf;
- for (int i = 0, j = 0; i < n; i++) {
- if (report->linebuf[i] == '\t') {
- for (int k = (j + 8) & ~7; j < k; j++) {
+ if (const char16_t* linebuf = report->linebuf()) {
+ size_t n = report->linebufLength();
+
+ fputs(":\n", stderr);
+ if (prefix)
+ fputs(prefix, stderr);
+
+ for (size_t i = 0; i < n; i++)
+ fputc(static_cast<char>(linebuf[i]), stderr);
+
+ // linebuf usually ends with a newline. If not, add one here.
+ if (n == 0 || linebuf[n - 1] != '\n')
+ fputc('\n', stderr);
+
+ if (prefix)
+ fputs(prefix, stderr);
+
+ n = report->tokenOffset();
+ for (size_t i = 0, j = 0; i < n; i++) {
+ if (linebuf[i] == '\t') {
+ for (size_t k = (j + 8) & ~7; j < k; j++)
fputc('.', stderr);
- }
continue;
}
fputc('.', stderr);