[gjs: 2/10] jsapi-util: Fix non-flat string message
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gjs: 2/10] jsapi-util: Fix non-flat string message
- Date: Sun,  6 Mar 2022 00:46:42 +0000 (UTC)
commit 5145abf522facafdc36f7b3f08526fa8ab272bf7
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Feb 12 13:14:22 2022 -0800
    jsapi-util: Fix non-flat string message
    
    Bizarrely, if we construct ostringstream with a string already in it, the
    default behaviour is to start overwriting characters at the start when
    later inserting more text into the stream. If we don't want that, we have
    to construct it with the 'advance to end' flag.
 gjs/jsapi-util-string.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index 2b880e6fc..c78069a83 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -538,7 +538,8 @@ gjs_debug_string(JSString *str)
     if (!str)
         return "<null string>";
     if (!JS_StringIsLinear(str)) {
-        std::ostringstream out("<non-flat string of length ");
+        std::ostringstream out("<non-flat string of length ",
+                               std::ios_base::ate);
         out << JS_GetStringLength(str) << '>';
         return out.str();
     }
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]