From 7f7be8a8202b9ccea19ae379665e3a34a81b6797 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Tue, 27 Jan 2026 23:18:56 +0000 Subject: Improved examples in 'examples/' --- examples/tools/mini_grep.zc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'examples/tools') diff --git a/examples/tools/mini_grep.zc b/examples/tools/mini_grep.zc index 39fec07..54338bf 100644 --- a/examples/tools/mini_grep.zc +++ b/examples/tools/mini_grep.zc @@ -30,7 +30,7 @@ fn str_find_case(haystack: string, needle: string, ignore_case: bool) -> Option< let n = needle; let n_len = strlen(needle); - while (*h != 0) + while (*h != '\0') { let is_match: bool = true; for i in 0..n_len @@ -52,7 +52,7 @@ fn str_find_case(haystack: string, needle: string, ignore_case: bool) -> Option< return Option::None(); } -fn print_highlight(line: string, match_ptr: string, match_len: usize, config: GrepConfig) { +fn print_highlight(line: string, match_ptr: string, match_len: usize, config: GrepConfig*) { if (!config.color) { "{line}"; @@ -84,7 +84,7 @@ fn print_highlight(line: string, match_ptr: string, match_len: usize, config: Gr "{current}"; } -fn grep_file(path: string, config: GrepConfig) -> Result { +fn grep_file(path: string, config: GrepConfig*) -> Result { let content_str: String = File::read_all(path)?; defer content_str.destroy(); let content = content_str.c_str(); @@ -95,7 +95,7 @@ fn grep_file(path: string, config: GrepConfig) -> Result { let q_len = strlen(config.query); - while (*ptr != 0) + while (*ptr != '\0') { if (*ptr == '\n') { @@ -163,7 +163,7 @@ fn grep_file(path: string, config: GrepConfig) -> Result { return Result::Ok(0); } -fn visit_dir(path: string, config: GrepConfig) { +fn visit_dir(path: string, config: GrepConfig*) { let entries_res = File::read_dir(path); guard entries_res.is_ok() else return; @@ -287,7 +287,7 @@ fn main(argc: int, argv: string*) { if (config.recursive) { - visit_dir(config.path, config); + visit_dir(config.path, &config); } else { @@ -296,7 +296,7 @@ fn main(argc: int, argv: string*) } else { - let res = grep_file(config.path, config); + let res = grep_file(config.path, &config); if (res.is_err()) { !"Error: {res.err}"; return 1; -- cgit v1.2.3