diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-07-21 21:58:25 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-07-22 14:25:12 -0400 |
| commit | cb0704d51c6a170bca8206a9bb3e9796c71c6341 (patch) | |
| tree | 2e275eb1a22d74ddd5d5052a4f89aa45ef9245b0 /core/text/regex/common/debugging.odin | |
| parent | ccf8b2764d4a3add4a575b2c88b710b2d15ebae8 (diff) | |
Add `core:text/regex`
Diffstat (limited to 'core/text/regex/common/debugging.odin')
| -rw-r--r-- | core/text/regex/common/debugging.odin | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/text/regex/common/debugging.odin b/core/text/regex/common/debugging.odin new file mode 100644 index 000000000..062c314cc --- /dev/null +++ b/core/text/regex/common/debugging.odin @@ -0,0 +1,25 @@ +package regex_common + +@require import "core:os" +import "core:io" +import "core:strings" + +ODIN_DEBUG_REGEX :: #config(ODIN_DEBUG_REGEX, false) + +when ODIN_DEBUG_REGEX { + debug_stream := os.stream_from_handle(os.stderr) +} + +write_padded_hex :: proc(w: io.Writer, #any_int n, zeroes: int) { + sb := strings.builder_make() + defer strings.builder_destroy(&sb) + + sbw := strings.to_writer(&sb) + io.write_int(sbw, n, 0x10) + + io.write_string(w, "0x") + for _ in 0..<max(0, zeroes - strings.builder_len(sb)) { + io.write_byte(w, '0') + } + io.write_int(w, n, 0x10) +} |