mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
This patch implements _Escaping_sink that stores characters in a local (stack) buffer. When the buffer is full, the range of characters is escaped and written to the underlying sink. To support above, the __write_escaped_unicode_part function are defined. It takes __str and __prev_esc by reference. The __prev_esc value is updated based on the last character written. If the buffer ends with an incomplete code point sequence, __str is left non-empty and last code points are not written. _Escaping_sink then copies these characters to the front of the buffer to reconstruct the full code point. __formatter__str::_M_format_range now uses _Escaping_sink to escape any non-continuous character sequences. libstdc++-v3/ChangeLog: * include/std/format (__format::__write_escape_seqs) (__format::_Escaping_sink): Define. (__format::__write_escaped_unicode_part): Extract from __format::__write_escaped_unicode. (__format::__write_escaped_unicode): Forward to __write_escaped_unicode_part. (__formatter_str::_M_format_range): Use _Escaping sink. * testsuite/std/format/ranges/string.cc: New tests for character which codepoints will be split in buffer and escaping. Invoked test_padding. Reviewed-by: Patrick Palka <ppalka@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>