[gjs/wip/ptomato/mozjs45: 25/30] modules/console: Update to js::PrintError from upstream
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs45: 25/30] modules/console: Update to js::PrintError from upstream
- Date: Wed, 3 May 2017 06:40:19 +0000 (UTC)
commit ad1522fdd3b2735eb2ee191d556b5e09019fef35
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Apr 29 18:25:44 2017 -0700
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.
modules/console.cpp | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/modules/console.cpp b/modules/console.cpp
index 57a16b7..df0d5f8 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]