From 02404a5b5de39dd25380f8a0193c529e28431dd4 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Thu, 13 Feb 2025 20:21:07 -0700 Subject: [PATCH 01/20] Implemented getting file paths from user using stdin. --- Makefile | 2 +- cmd/diff/main.ha | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 313b80d..e6b6ceb 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ BINDIR=$(PREFIX)/bin all: diff -diff: +diff: cmd/diff/main.ha $(HARE) build $(HAREFLAGS) -o $@ cmd/$@/ clean: diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index 943c971..4d7fa74 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -1,5 +1,13 @@ +use bufio; use fmt; +use os; +use strings; export fn main() void = { - fmt::println("Hello world!")!; + fmt::println("Enter 2 files to compare:")!; + const path = bufio::read_line(os::stdin)! as []u8; + const other_path = bufio::read_line(os::stdin)! as []u8; + const path = strings::fromutf8(path)!; + const other_path = strings::fromutf8(other_path)!; + fmt::printfln("Comparing file '{}' to '{}'", path, other_path)!; }; From de970bd1c91448bd8d3460e1eb41dd78739781ea Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Thu, 13 Feb 2025 20:39:18 -0700 Subject: [PATCH 02/20] Figured out how to get arguments passed from the command line. --- cmd/diff/main.ha | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index 4d7fa74..4fd73ad 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -4,10 +4,7 @@ use os; use strings; export fn main() void = { - fmt::println("Enter 2 files to compare:")!; - const path = bufio::read_line(os::stdin)! as []u8; - const other_path = bufio::read_line(os::stdin)! as []u8; - const path = strings::fromutf8(path)!; - const other_path = strings::fromutf8(other_path)!; + const path = os::args[1]; + const other_path = os::args[2]; fmt::printfln("Comparing file '{}' to '{}'", path, other_path)!; }; From 2d828f9a472ef7a018bfd2cf0c779d3544ce0b8e Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Fri, 14 Feb 2025 19:46:01 -0700 Subject: [PATCH 03/20] Added some test files. --- testing/files/long_test.ha | 7 +++++++ testing/files/other_test.ha | 5 +++++ testing/files/test.ha | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 testing/files/long_test.ha create mode 100644 testing/files/other_test.ha create mode 100644 testing/files/test.ha diff --git a/testing/files/long_test.ha b/testing/files/long_test.ha new file mode 100644 index 0000000..7734770 --- /dev/null +++ b/testing/files/long_test.ha @@ -0,0 +1,7 @@ +use fmt; +use strconv; + +export fn main() void = { + const byte_hello = strconv::stou8("Hello world!", strconv::base::BIN)!; + fmt::bsprint(byte_hello)!; +}; diff --git a/testing/files/other_test.ha b/testing/files/other_test.ha new file mode 100644 index 0000000..cdc1f0a --- /dev/null +++ b/testing/files/other_test.ha @@ -0,0 +1,5 @@ +use fmt; + +export fn main() void = { + fmt::println("Hello world!")!; +}; diff --git a/testing/files/test.ha b/testing/files/test.ha new file mode 100644 index 0000000..cdc1f0a --- /dev/null +++ b/testing/files/test.ha @@ -0,0 +1,5 @@ +use fmt; + +export fn main() void = { + fmt::println("Hello world!")!; +}; From 9e199784ced4b608eedf42fe49ccbe78fabc4e4e Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sun, 16 Feb 2025 17:44:12 -0700 Subject: [PATCH 04/20] Added lines to read contents of provided files into memory. --- cmd/diff/main.ha | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index 4fd73ad..faf514b 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -1,10 +1,18 @@ -use bufio; use fmt; +use io; use os; use strings; export fn main() void = { const path = os::args[1]; + const fh = os::open(path)!; + const file_contents = io::drain(fh)!; + const file_contents = strings::fromutf8(file_contents)!; + const other_path = os::args[2]; + const other_fh = os::open(other_path)!; + const other_file_contents = io::drain(other_fh)!; + const other_file_contents = strings::fromutf8(other_file_contents)!; + fmt::printfln("Comparing file '{}' to '{}'", path, other_path)!; }; From 69a401635e60f590d08d1b4329729470021a0ee7 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sun, 16 Feb 2025 17:50:30 -0700 Subject: [PATCH 05/20] Decided to add extra empty lines to 'long_test.ha' to demonstrate how 'diff' handles white space in files. --- testing/files/long_test.ha | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/files/long_test.ha b/testing/files/long_test.ha index 7734770..1746dff 100644 --- a/testing/files/long_test.ha +++ b/testing/files/long_test.ha @@ -1,7 +1,7 @@ use fmt; -use strconv; export fn main() void = { - const byte_hello = strconv::stou8("Hello world!", strconv::base::BIN)!; - fmt::bsprint(byte_hello)!; + + + fmt::println("Hello world!")!; }; From 21d4ab8dbda960753b1b27b7c697e1473e58daee Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sun, 16 Feb 2025 17:52:13 -0700 Subject: [PATCH 06/20] Added a new test file 'err_test.ha' which does not deal with the possible error when printing a line to the screen. Serves to demonstrate on 'diff' handles in-line differences. --- testing/files/err_test.ha | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 testing/files/err_test.ha diff --git a/testing/files/err_test.ha b/testing/files/err_test.ha new file mode 100644 index 0000000..61ef873 --- /dev/null +++ b/testing/files/err_test.ha @@ -0,0 +1,5 @@ +use fmt; + +export fn main() void = { + fmt::println("Hello world!"); +}; From cd37385d89674451d7db40875155ee35b6b667c0 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sun, 16 Feb 2025 17:57:36 -0700 Subject: [PATCH 07/20] Added function stub for comparison function. --- cmd/diff/main.ha | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index faf514b..ddb47ca 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -16,3 +16,8 @@ export fn main() void = { fmt::printfln("Comparing file '{}' to '{}'", path, other_path)!; }; + + +fn compare() uint = { + return 0; +}; From 337a581f10b6997416bac929840fd4eb0b5f47c7 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sun, 16 Feb 2025 18:01:29 -0700 Subject: [PATCH 08/20] Filled out parameters for comparison function. Moved code to read files into memory into the comparison function. --- cmd/diff/main.ha | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index ddb47ca..42e2fb0 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -6,18 +6,22 @@ use strings; export fn main() void = { const path = os::args[1]; const fh = os::open(path)!; - const file_contents = io::drain(fh)!; - const file_contents = strings::fromutf8(file_contents)!; const other_path = os::args[2]; const other_fh = os::open(other_path)!; - const other_file_contents = io::drain(other_fh)!; - const other_file_contents = strings::fromutf8(other_file_contents)!; fmt::printfln("Comparing file '{}' to '{}'", path, other_path)!; + compare_files(fh, other_fh); }; -fn compare() uint = { +fn compare_files(lhh: io::handle, rhh: io::handle) uint = { + const lhh_contents = io::drain(lhh)!; + const lhh_contents = strings::fromutf8(lhh_contents)!; + + const rhh_contents = io::drain(rhh)!; + const rhh_contents = strings::fromutf8(rhh_contents)!; + + return 0; }; From fb268b3e7a48a74e8e3f2894574236a4c2763193 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sun, 16 Feb 2025 21:01:42 -0700 Subject: [PATCH 09/20] Got rid of extra lines in 'long_test.ha' because it was more pertinent to understand how 'diff' consumes lines when files are of different lengths. --- testing/files/long_test.ha | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/testing/files/long_test.ha b/testing/files/long_test.ha index 1746dff..10b8779 100644 --- a/testing/files/long_test.ha +++ b/testing/files/long_test.ha @@ -1,7 +1,6 @@ use fmt; export fn main() void = { - - - fmt::println("Hello world!")!; + const hello_str = "Hello world!"; + fmt::println(hello_str)!; }; From 731946d0a43d94b75784c1978897227f90f7a4c4 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sun, 16 Feb 2025 21:16:03 -0700 Subject: [PATCH 10/20] Implemented a straightforward comparison of lines in a file. Implementation does not wait and save the group of lines which differs in each file. --- cmd/diff/main.ha | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index 42e2fb0..f208910 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -3,6 +3,10 @@ use io; use os; use strings; + +const DELIM = "\n"; + + export fn main() void = { const path = os::args[1]; const fh = os::open(path)!; @@ -10,18 +14,31 @@ export fn main() void = { const other_path = os::args[2]; const other_fh = os::open(other_path)!; - fmt::printfln("Comparing file '{}' to '{}'", path, other_path)!; + fmt::printfln("Comparing file '{}' to '{}'\n", path, other_path)!; compare_files(fh, other_fh); }; fn compare_files(lhh: io::handle, rhh: io::handle) uint = { + // get lines from left hand file provided const lhh_contents = io::drain(lhh)!; const lhh_contents = strings::fromutf8(lhh_contents)!; - + const lhh_lines = strings::split(lhh_contents, DELIM)!; + const lhh_num_lines = len(lhh_lines); + // get lines from right hand file provided const rhh_contents = io::drain(rhh)!; const rhh_contents = strings::fromutf8(rhh_contents)!; + const rhh_lines = strings::split(rhh_contents, DELIM)!; + const rhh_num_lines = len(rhh_lines); + + for (let i = 0z; i < lhh_num_lines && i < rhh_num_lines; i += 1) { + if (lhh_lines[i] != rhh_lines[i]) { + fmt::printfln("< {}", lhh_lines[i])!; + fmt::println("---")!; + fmt::printfln("> {}\n", rhh_lines[i])!; + }; + }; return 0; }; From ba1361b9537a346841507f7a3270293291427bc4 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sat, 1 Mar 2025 10:53:03 -0700 Subject: [PATCH 11/20] Added 'double_hello.ha' to test how 'diff' handles when different sections of two files match and mismatch. --- testing/files/double_hello.ha | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 testing/files/double_hello.ha diff --git a/testing/files/double_hello.ha b/testing/files/double_hello.ha new file mode 100644 index 0000000..668258c --- /dev/null +++ b/testing/files/double_hello.ha @@ -0,0 +1,7 @@ +use fmt; + +export fn main() void = { + const hello_str = "Hello world!"; + fmt::println(hello_str)!; + fmt::println("Hello world!")!; +}; From 9f6825038b34ac6cdc20746ae4f5614aeffbb31b Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sat, 1 Mar 2025 11:14:06 -0700 Subject: [PATCH 12/20] Rigged a while loop to disconnect indices for accessing files. --- cmd/diff/main.ha | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index f208910..2a219b8 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -30,14 +30,20 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { const rhh_contents = strings::fromutf8(rhh_contents)!; const rhh_lines = strings::split(rhh_contents, DELIM)!; const rhh_num_lines = len(rhh_lines); + // iteration + let lhh_i = 0z; + let rhh_i = 0z; - for (let i = 0z; i < lhh_num_lines && i < rhh_num_lines; i += 1) { - if (lhh_lines[i] != rhh_lines[i]) { - fmt::printfln("< {}", lhh_lines[i])!; + for (let i = 0z; lhh_i < lhh_num_lines && rhh_i < rhh_num_lines; i += 1) { + if (lhh_lines[lhh_i] != rhh_lines[rhh_i]) { + fmt::printfln("< {}", lhh_lines[lhh_i])!; fmt::println("---")!; - fmt::printfln("> {}\n", rhh_lines[i])!; + fmt::printfln("> {}\n", rhh_lines[rhh_i])!; }; + + lhh_i += 1; + rhh_i += 1; }; return 0; From 111b9a75b9f98bcb77f7d7e639a2af831bbc2b9e Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sat, 1 Mar 2025 12:17:34 -0700 Subject: [PATCH 13/20] Implemented a buffer to hold all lines from right-hand file which do not match the left-hand file. --- cmd/diff/main.ha | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index 2a219b8..f248bb9 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -33,13 +33,21 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { // iteration let lhh_i = 0z; let rhh_i = 0z; + let rhh_mis_buffer: []str = []; for (let i = 0z; lhh_i < lhh_num_lines && rhh_i < rhh_num_lines; i += 1) { - if (lhh_lines[lhh_i] != rhh_lines[rhh_i]) { - fmt::printfln("< {}", lhh_lines[lhh_i])!; - fmt::println("---")!; - fmt::printfln("> {}\n", rhh_lines[rhh_i])!; + for (let j = 0z; + rhh_i < rhh_num_lines && lhh_lines[lhh_i] != rhh_lines[rhh_i]; + rhh_i += 1) { + append(rhh_mis_buffer, rhh_lines[rhh_i])!; + }; + if (len(rhh_mis_buffer) > 0) { + fmt::printfln("< {}\n---", lhh_lines[lhh_i])!; + for (let j = 0z; j < len(rhh_mis_buffer); j += 1) { + fmt::printfln("> {}", rhh_mis_buffer[j])!; + }; + fmt::println()!; }; lhh_i += 1; From 4ba84ea115379b5c0d4acc26e5ee7939ac2ff3a1 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sat, 1 Mar 2025 12:19:17 -0700 Subject: [PATCH 14/20] Added a TODO for memory leak. --- cmd/diff/main.ha | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index f248bb9..73f32ed 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -34,6 +34,7 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { let lhh_i = 0z; let rhh_i = 0z; let rhh_mis_buffer: []str = []; + // TODO: fix leak above! for (let i = 0z; lhh_i < lhh_num_lines && rhh_i < rhh_num_lines; i += 1) { From 21a3094807c549a025639af6b92bdc35a8cbca77 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sat, 1 Mar 2025 12:31:24 -0700 Subject: [PATCH 15/20] Changed buffer of lines to be a buffer to addresses to strings - this way strings are not constantly being copied. Fixed memory leak related to line buffer. --- cmd/diff/main.ha | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index 73f32ed..d88128b 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -33,20 +33,19 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { // iteration let lhh_i = 0z; let rhh_i = 0z; - let rhh_mis_buffer: []str = []; - // TODO: fix leak above! + let rhh_mis_buffer: []*str = []; for (let i = 0z; lhh_i < lhh_num_lines && rhh_i < rhh_num_lines; i += 1) { for (let j = 0z; rhh_i < rhh_num_lines && lhh_lines[lhh_i] != rhh_lines[rhh_i]; rhh_i += 1) { - append(rhh_mis_buffer, rhh_lines[rhh_i])!; + append(rhh_mis_buffer, &rhh_lines[rhh_i])!; }; if (len(rhh_mis_buffer) > 0) { fmt::printfln("< {}\n---", lhh_lines[lhh_i])!; for (let j = 0z; j < len(rhh_mis_buffer); j += 1) { - fmt::printfln("> {}", rhh_mis_buffer[j])!; + fmt::printfln("> {}", *rhh_mis_buffer[j])!; }; fmt::println()!; }; @@ -55,5 +54,7 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { rhh_i += 1; }; + free(rhh_mis_buffer); + return 0; }; From 5ef99992a805a7f09e19763cb3215c7a58f7abef Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Sat, 1 Mar 2025 12:35:40 -0700 Subject: [PATCH 16/20] Added loop to remove lines from buffer after contents have been printed to stdout. --- cmd/diff/main.ha | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index d88128b..ea9f40d 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -48,6 +48,9 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { fmt::printfln("> {}", *rhh_mis_buffer[j])!; }; fmt::println()!; + for (let j = 0z; j < len(rhh_mis_buffer); j += 1) { + delete(rhh_mis_buffer[j]); + }; }; lhh_i += 1; From 8a75cf82d1b0089cc00cb0853ccb8a239eeb9316 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Wed, 7 May 2025 22:57:49 -0700 Subject: [PATCH 17/20] Realized 'diff' program uses the signed difference between two strings and increments an iterator variable depending on if the comparee file has a line which is bigger or smaller. The differing lines are buffered until a common line is reached, then the differing lines which were buffered are printed. --- cmd/diff/main.ha | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index ea9f40d..22dc3f1 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -33,24 +33,41 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { // iteration let lhh_i = 0z; let rhh_i = 0z; + let cmp_res = 0i; let rhh_mis_buffer: []*str = []; + let lhh_mis_buffer: []*str = []; for (let i = 0z; lhh_i < lhh_num_lines && rhh_i < rhh_num_lines; i += 1) { for (let j = 0z; - rhh_i < rhh_num_lines && lhh_lines[lhh_i] != rhh_lines[rhh_i]; - rhh_i += 1) { - append(rhh_mis_buffer, &rhh_lines[rhh_i])!; + rhh_i < rhh_num_lines && lhh_i < lhh_num_lines; + j += 1) { + // fmt::printfln("'{}' -> '{}'", rhh_lines[rhh_i], lhh_lines[lhh_i])!; + cmp_res = strings::compare(rhh_lines[rhh_i], lhh_lines[lhh_i]); + if (cmp_res < 0) { + append(rhh_mis_buffer, &rhh_lines[rhh_i])!; + rhh_i += 1; + } else if (cmp_res > 0) { + append(lhh_mis_buffer, &lhh_lines[lhh_i])!; + lhh_i += 1; + } else { + break; + }; }; - if (len(rhh_mis_buffer) > 0) { - fmt::printfln("< {}\n---", lhh_lines[lhh_i])!; + if (len(rhh_mis_buffer) > 0 && len(lhh_mis_buffer) > 0) { for (let j = 0z; j < len(rhh_mis_buffer); j += 1) { - fmt::printfln("> {}", *rhh_mis_buffer[j])!; + fmt::printfln("< {}", *rhh_mis_buffer[j])!; + }; + fmt::println("---")!; + for (let j = 0z; j < len(lhh_mis_buffer); j += 1) { + fmt::printfln("> {}", *lhh_mis_buffer[j])!; }; - fmt::println()!; for (let j = 0z; j < len(rhh_mis_buffer); j += 1) { delete(rhh_mis_buffer[j]); }; + for (let j = 0z; j < len(lhh_mis_buffer); j += 1) { + delete(lhh_mis_buffer[j]); + }; }; lhh_i += 1; @@ -58,6 +75,7 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { }; free(rhh_mis_buffer); + free(lhh_mis_buffer); return 0; }; From eb6cee3d3eb43befec40b9d30d8fcaa6e97c7200 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Wed, 7 May 2025 22:59:55 -0700 Subject: [PATCH 18/20] Had to swap in which order the buffered differing lines get printed to the screen. --- cmd/diff/main.ha | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index 22dc3f1..b609d5e 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -42,7 +42,6 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { for (let j = 0z; rhh_i < rhh_num_lines && lhh_i < lhh_num_lines; j += 1) { - // fmt::printfln("'{}' -> '{}'", rhh_lines[rhh_i], lhh_lines[lhh_i])!; cmp_res = strings::compare(rhh_lines[rhh_i], lhh_lines[lhh_i]); if (cmp_res < 0) { append(rhh_mis_buffer, &rhh_lines[rhh_i])!; @@ -55,12 +54,12 @@ fn compare_files(lhh: io::handle, rhh: io::handle) uint = { }; }; if (len(rhh_mis_buffer) > 0 && len(lhh_mis_buffer) > 0) { - for (let j = 0z; j < len(rhh_mis_buffer); j += 1) { - fmt::printfln("< {}", *rhh_mis_buffer[j])!; + for (let j = 0z; j < len(lhh_mis_buffer); j += 1) { + fmt::printfln("< {}", *lhh_mis_buffer[j])!; }; fmt::println("---")!; - for (let j = 0z; j < len(lhh_mis_buffer); j += 1) { - fmt::printfln("> {}", *lhh_mis_buffer[j])!; + for (let j = 0z; j < len(rhh_mis_buffer); j += 1) { + fmt::printfln("> {}", *rhh_mis_buffer[j])!; }; for (let j = 0z; j < len(rhh_mis_buffer); j += 1) { delete(rhh_mis_buffer[j]); From b923db9ddf2a5fa158af82be5b0090433fccfc6b Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Wed, 7 May 2025 23:01:57 -0700 Subject: [PATCH 19/20] Took out reporting of the files being compared - not necessary. --- cmd/diff/main.ha | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/diff/main.ha b/cmd/diff/main.ha index b609d5e..5d1dbcf 100644 --- a/cmd/diff/main.ha +++ b/cmd/diff/main.ha @@ -14,7 +14,6 @@ export fn main() void = { const other_path = os::args[2]; const other_fh = os::open(other_path)!; - fmt::printfln("Comparing file '{}' to '{}'\n", path, other_path)!; compare_files(fh, other_fh); }; From 329bd1ec8e398d3041e2878cc33520d49ffa7310 Mon Sep 17 00:00:00 2001 From: Num0Programmer Date: Wed, 7 May 2025 23:24:37 -0700 Subject: [PATCH 20/20] Added two other testing files for testing robustness of implementation when files have multiple points of divergence and convergence. --- testing/files/inc.ha | 17 +++++++++++++++++ testing/files/inc_dec.ha | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 testing/files/inc.ha create mode 100644 testing/files/inc_dec.ha diff --git a/testing/files/inc.ha b/testing/files/inc.ha new file mode 100644 index 0000000..7c34f42 --- /dev/null +++ b/testing/files/inc.ha @@ -0,0 +1,17 @@ +use fmt; +use io; +use os; + + +export fn main() void = { + let num = 4; + inc(&num); + inc(&num); + fmt::printfln("num = {}", num)!; + inc(&num); + fmt::printfln("num = {}", num)!; +}; + +fn inc(num: *int) void = { + *num += 1; +}; diff --git a/testing/files/inc_dec.ha b/testing/files/inc_dec.ha new file mode 100644 index 0000000..6a7c5ae --- /dev/null +++ b/testing/files/inc_dec.ha @@ -0,0 +1,21 @@ +use fmt; +use io; +use os; + + +export fn main() void = { + let num = 4; + inc(&num); + inc(&num); + fmt::printfln("num = {}", num)!; + dec(&num); + fmt::printfln("num = {}", num)!; +}; + +fn dec(num: *int) void = { + *num -= 1; +}; + +fn inc(num: *int) void = { + *num += 1; +};