Skip to content

Commit a48c184

Browse files
att
1 parent 84990f0 commit a48c184

File tree

9 files changed

+67
-18
lines changed

9 files changed

+67
-18
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ deer.txt
4141
*.so
4242
*.so.*
4343
*.dylib
44-
44+
output_test
4545
# Executables
4646
*.exe
4747
*.out

build.exe

1 KB
Binary file not shown.

build.out

0 Bytes
Binary file not shown.

build/lua/amalgamation/amalgamation.lua

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11

2+
3+
24
---@param start_point string
5+
---@param already_included_list StringArray | nil
36
---@return string
4-
function Generate_amalgamation_recursive(start_point)
7+
function Generate_amalgamation_recursive(start_point,already_included_list)
8+
9+
10+
if already_included_list == nil then
11+
already_included_list = Created_already_included()
12+
end
13+
14+
local start_point_sha = dtw.generate_sha_from_file(start_point)
15+
if already_included_list.is_included(start_point_sha) then
16+
clib.print(ANSI_YELLOW.."file"..start_point.."already included\n")
17+
return ""
18+
end
19+
20+
already_included_list.append(start_point_sha)
521

622

723
local content = dtw.load_file(start_point)
@@ -46,7 +62,7 @@
4662
local dir = dtw.newPath(start_point).get_dir()
4763
local full_path = dtw.concat_path(dir,string_buffer)
4864

49-
local acumulated = Generate_amalgamation_recursive(full_path)
65+
local acumulated = Generate_amalgamation_recursive(full_path,already_included_list)
5066
final_text = final_text.. acumulated.."\n"
5167

5268
waiting_include = false
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
---@class StringArray
3+
---@field size number
4+
---@field elements string[]
5+
---@field append fun(element:string)
6+
---@field is_included fun(element:string):boolean
7+
8+
---@return StringArray
9+
function Created_already_included()
10+
local self = {
11+
size = 0,
12+
elements = {}
13+
}
14+
15+
self.append = function (element)
16+
self.size = self.size +1
17+
self.elements[self.size] = element
18+
end
19+
20+
self.is_included = function (element)
21+
for i=1,self.size do
22+
if self.elements[i] == element then
23+
return true
24+
end
25+
end
26+
return false
27+
end
28+
return self
29+
30+
end

doTheWorld.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ uint8_t *sha_256_close(struct Sha_256 *sha_256);
504504

505505
#endif
506506

507+
507508
#undef SHA_256_H
508509
#endif //SHA_256_H
509510

output_test

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
==89809== Memcheck, a memory error detector
2-
==89809== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
3-
==89809== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
4-
==89809== Command: ./tests/main_test/trees/T_tree_map/exec.out
5-
==89809== Parent PID: 88415
6-
==89809==
7-
==89809==
8-
==89809== HEAP SUMMARY:
9-
==89809== in use at exit: 0 bytes in 0 blocks
10-
==89809== total heap usage: 550 allocs, 550 frees, 346,874 bytes allocated
11-
==89809==
12-
==89809== All heap blocks were freed -- no leaks are possible
13-
==89809==
14-
==89809== For lists of detected and suppressed errors, rerun with: -s
15-
==89809== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
1+
==94192== Memcheck, a memory error detector
2+
==94192== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
3+
==94192== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
4+
==94192== Command: ./tests/main_test/trees/T_tree_map/exec.out
5+
==94192== Parent PID: 92989
6+
==94192==
7+
==94192==
8+
==94192== HEAP SUMMARY:
9+
==94192== in use at exit: 0 bytes in 0 blocks
10+
==94192== total heap usage: 550 allocs, 550 frees, 346,874 bytes allocated
11+
==94192==
12+
==94192== All heap blocks were freed -- no leaks are possible
13+
==94192==
14+
==94192== For lists of detected and suppressed errors, rerun with: -s
15+
==94192== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

src/declaration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
#ifndef SHA_256_H
3939
#include "dependencies/sha256/sha-256.h"
40+
4041
#undef SHA_256_H
4142
#endif //SHA_256_H
4243

tests/doTheWorld_test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ uint8_t *sha_256_close(struct Sha_256 *sha_256);
504504

505505
#endif
506506

507+
507508
#undef SHA_256_H
508509
#endif //SHA_256_H
509510

0 commit comments

Comments
 (0)