[前][次][番号順一覧][スレッド一覧]

ruby-changes:72971

From: Nobuyoshi <ko1@a...>
Date: Fri, 19 Aug 2022 03:06:13 +0900 (JST)
Subject: [ruby-changes:72971] 99116da7f0 (master): Scan the code range of the last added portion

https://git.ruby-lang.org/ruby.git/commit/?id=99116da7f0

From 99116da7f05633697177c09cf4de5080028d77f8 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 17 Aug 2022 16:10:51 +0900
Subject: Scan the code range of the last added portion

---
 sprintf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sprintf.c b/sprintf.c
index 04cead7731..b16ab3f581 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -927,6 +927,10 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) https://github.com/ruby/ruby/blob/trunk/sprintf.c#L927
         flags = FNONE;
     }
 
+    if (coderange != ENC_CODERANGE_BROKEN && scanned < blen) {
+        scanned += rb_str_coderange_scan_restartable(buf+scanned, buf+blen, enc, &coderange);
+        ENC_CODERANGE_SET(result, coderange);
+    }
   sprint_exit:
     rb_str_tmp_frozen_release(orig, fmt);
     /* XXX - We cannot validate the number of arguments if (digit)$ style used.
@@ -937,8 +941,6 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) https://github.com/ruby/ruby/blob/trunk/sprintf.c#L941
         if (RTEST(ruby_verbose)) rb_warn("%s", mesg);
     }
     rb_str_resize(result, blen);
-    // rb_str_format mutates the string without updating coderange
-    ENC_CODERANGE_CLEAR(result);
 
     return result;
 }
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]