Skip to content

Commit bd52341

Browse files
committed
[CHORE/FIX] Changed signature of method check_forbidden_functions to get as a parametter a list of functions so it is modular. Fixes #38
1 parent a247759 commit bd52341

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

42PyChecker.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ def check_42_commandements(project_path:str):
238238
return 0
239239

240240

241-
def check_forbidden_functions(project_path: str, binary: str):
242-
# @todo Refactor check_forbidden_functions to have a modular authorized_functions (to be used on multiple projects)
243-
authorized_functions = ['free', 'malloc', 'write', 'main']
241+
def check_forbidden_functions(project_path: str, binary: str, authorized_functions):
244242
functions_called = []
245243
result = subprocess.run(['nm', project_path + '/' + binary], stdout=subprocess.PIPE).stdout.decode('utf-8')
246244
for line in result.splitlines():
@@ -293,6 +291,7 @@ def check_libft(project_path: str):
293291
'ft_memset.c', 'ft_bzero.c']
294292
bonus_functions = ['ft_lstnew.c', 'ft_lstdelone.c', 'ft_lstdel.c',
295293
'ft_lstiter.c', 'ft_lstadd.c', 'ft_lstmap.c']
294+
authorized_functions = ['free', 'malloc', 'write', 'main']
296295
while True:
297296
if all([os.path.isfile(project_path + '/' + function) for function in required_functions]):
298297
break
@@ -315,7 +314,7 @@ def check_libft(project_path: str):
315314
result = subprocess.run(['sh', 'check_static.sh', project_path], stdout=subprocess.PIPE).stdout.decode('utf-8')
316315
file.write(result)
317316
check_makefile(project_path, "libft.a")
318-
check_forbidden_functions(project_path, "libft.a")
317+
check_forbidden_functions(project_path, "libft.a", authorized_functions)
319318
run_libftest(project_path)
320319
# moulitest
321320
# libft-unit-test

0 commit comments

Comments
 (0)