changeset 31971:37700c8fba9c

maint: Merge stable to default.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 05 Apr 2023 19:20:57 +0200
parents ab928435dd79 (current diff) 701fbdfb3bc0 (diff)
children bc6fe3baf635
files
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/oct-string.cc	Mon Apr 03 18:23:09 2023 +0200
+++ b/liboctave/util/oct-string.cc	Wed Apr 05 19:20:57 2023 +0200
@@ -617,8 +617,12 @@
    const InternT* from, const InternT* from_end, const InternT*& from_next,
    ExternT* to, ExternT* to_end, ExternT*& to_next) const
 {
+  to_next = to;
   if (from_end <= from)
-    return std::codecvt<InternT, ExternT, StateT>::noconv;
+    {
+      from_next = from_end;
+      return std::codecvt<InternT, ExternT, StateT>::noconv;
+    }
 
   // Check if buffer ends in a complete UTF-8 surrogate.
   // FIXME: If this is the last call before a stream is closed, we should
@@ -649,6 +653,7 @@
               && (num_bytes_in_buf < 4)))  // incomplete 4-byte surrogate
         pop_end = num_bytes_in_buf;
     }
+  from_next = from_end - pop_end;
 
   std::size_t srclen = (from_end-from-pop_end) * sizeof (InternT);
   std::size_t length = (to_end-to) * sizeof (ExternT);