55#ifndef SRC_LIB_SYMBOLIZER_MARKUP_INCLUDE_LIB_SYMBOLIZER_MARKUP_WRITER_H_
66#define SRC_LIB_SYMBOLIZER_MARKUP_INCLUDE_LIB_SYMBOLIZER_MARKUP_WRITER_H_
77
8- #include < lib/fit/defer.h>
9- #include < lib/stdcompat/span.h>
10- #include < zircon/assert.h>
11-
8+ #include < cassert>
129#include < climits>
1310#include < cstddef>
1411#include < cstdint>
1512#include < initializer_list>
1613#include < limits>
14+ #include < span>
1715#include < string_view>
1816#include < type_traits>
1917#include < utility>
@@ -82,12 +80,17 @@ class Writer {
8280 auto ChangeColor (Color color, bool bold = false ) {
8381 using namespace std ::string_view_literals;
8482
83+ struct ResetColor {
84+ ~ResetColor () { writer.Literal (" \033 [0m" sv); }
85+ Writer& writer;
86+ };
87+
8588 Literal (" \033 [" sv).template DecimalDigits (static_cast <unsigned int >(color)).Literal (' m' );
8689 if (bold) {
8790 Literal (" \033 [1m" sv);
8891 }
8992
90- return fit::defer ([ this ]() { Literal ( " \033 [0m " sv); }) ;
93+ return ResetColor{* this } ;
9194 }
9295
9396 //
@@ -155,7 +158,7 @@ class Writer {
155158 // Emits the markup for a given ELF module.
156159 //
157160 // {{{module:$id:$name:elf:$build_id}}}
158- Writer& ElfModule (unsigned int id, std::string_view name, cpp20 ::span<const std::byte> build_id) {
161+ Writer& ElfModule (unsigned int id, std::string_view name, std ::span<const std::byte> build_id) {
159162 return BeginElement (kModule )
160163 .DecimalField (id)
161164 .Field (name)
@@ -170,7 +173,7 @@ class Writer {
170173 // {{mmap:$start:$size:load:$module_id:$perms:$static_start}}
171174 Writer& LoadImageMmap (uintptr_t start, size_t size, unsigned int module_id,
172175 const MemoryPermissions& perms, uint64_t static_start) {
173- ZX_ASSERT (perms.read || perms.write || perms.execute );
176+ assert (perms.read || perms.write || perms.execute );
174177 char perm_str[3 ];
175178 size_t perm_size = 0 ;
176179 if (perms.read ) {
@@ -309,7 +312,7 @@ class Writer {
309312 return Separator ().HexDigits (n);
310313 }
311314
312- Writer& HexField (cpp20 ::span<const std::byte> bytes) {
315+ Writer& HexField (std ::span<const std::byte> bytes) {
313316 Separator ();
314317 for (const std::byte byte : bytes) {
315318 const uint8_t b = static_cast <uint8_t >(byte);
0 commit comments