From 8eef63e84f66a03dc8d2f70c736fd25e8dedfbb7 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Wed, 6 Mar 2024 16:47:00 -0500 Subject: [PATCH] Minor unicode file changes --- code/grime_unicode.odin | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/grime_unicode.odin b/code/grime_unicode.odin index 554d96b..fa41b67 100644 --- a/code/grime_unicode.odin +++ b/code/grime_unicode.odin @@ -19,16 +19,18 @@ string_to_runes_array :: proc( content : string, allocator := context.allocator return runes, alloc_error } -string_to_runes :: proc "odin" (s: string, allocator := context.allocator) -> (runes: []rune, alloc_error : AllocatorError) { - num := str_rune_count(s) +// Exposing the alloc_error +@(require_results) +string_to_runes :: proc "odin" ( content : string, allocator := context.allocator) -> (runes : []rune, alloc_error : AllocatorError) { + num := str_rune_count(content) runes, alloc_error = make([]rune, num, allocator) - if alloc_error != AllocatorError.None { - return nil, alloc_error + if runes == nil || alloc_error != AllocatorError.None { + return } idx := 0 - for codepoint in s { + for codepoint in content { runes[idx] = codepoint idx += 1 }