Libft.git
17 months agoFix indentation
Lukas Jiriste [Fri, 21 Jun 2024 13:24:52 +0000 (15:24 +0200)]
Fix indentation

17 months agoRefactor functions to comply with the Norm
Lukas Jiriste [Fri, 21 Jun 2024 13:23:51 +0000 (15:23 +0200)]
Refactor functions to comply with the Norm

17 months agoRefactor to better comply with the Norm
Lukas Jiriste [Fri, 21 Jun 2024 12:08:22 +0000 (14:08 +0200)]
Refactor to better comply with the Norm

17 months agoMake ft_parse_tree_print comply with the Norm
Lukas Jiriste [Fri, 21 Jun 2024 11:09:19 +0000 (13:09 +0200)]
Make ft_parse_tree_print comply with the Norm

17 months agoImprove formatting of ft_parsing_table_printf
Lukas Jiriste [Fri, 21 Jun 2024 11:03:35 +0000 (13:03 +0200)]
Improve formatting of ft_parsing_table_printf

The token names in the output header are now limitedr
to the column width.

17 months agoMake ft_parse inputs const, move token_free
Lukas Jiriste [Fri, 21 Jun 2024 09:49:45 +0000 (11:49 +0200)]
Make ft_parse inputs const, move token_free

After playing a little with the functions I thought it stupid to have
all tokens have their own memory for types that repeat so much.
The token_free function I implemented frees both members of token
which leads to multi-frees when reusing a string for type.

This is why I think it will be better to hide token_free again
and the user can decide what to allocate and what to free.

For this to be possible I have guarantee the tokens vector is not
changed inside the ft_parse function, so I've rewriten it a little
to use const.

17 months agoAdd const version of ft_vec_access
Lukas Jiriste [Fri, 21 Jun 2024 09:48:16 +0000 (11:48 +0200)]
Add const version of ft_vec_access

17 months agoFix memory leak
Lukas Jiriste [Fri, 21 Jun 2024 09:22:40 +0000 (11:22 +0200)]
Fix memory leak

This leak was caused by carelessness when working with malloc and t_vec
at the same time.

17 months agoMake ft_parse_tree_print handle NULLs gracefully
Lukas Jiriste [Fri, 21 Jun 2024 09:09:49 +0000 (11:09 +0200)]
Make ft_parse_tree_print handle NULLs gracefully

17 months agoFix bug, where NULLs appear inside tree
Lukas Jiriste [Fri, 21 Jun 2024 08:57:50 +0000 (10:57 +0200)]
Fix bug, where NULLs appear inside tree

This bug was caused because the tree nodes are filled from the end
when reducing. Instead of just inserting to the start it was inserting
at the final position.
When inserting to vector outside of range all the nonexistent entries
are initialized to 0. If another insertion happes after that, the
0 entries are not filled but moved to make space for the new entry.

17 months agoImplement printing function for parsing tree
Lukas Jiriste [Fri, 21 Jun 2024 08:34:09 +0000 (10:34 +0200)]
Implement printing function for parsing tree

This is mainly done for debugging. This does not scale to arbitrary
large trees automatically - the output will be garbled.

17 months agoFix forward declaration to be usable by user
Lukas Jiriste [Fri, 21 Jun 2024 07:48:48 +0000 (09:48 +0200)]
Fix forward declaration to be usable by user

17 months agoFix the code to actually produce a tree
Lukas Jiriste [Fri, 21 Jun 2024 07:43:38 +0000 (09:43 +0200)]
Fix the code to actually produce a tree

As the previous commit was only checked to compile there were some
minor defects. Notably the parser stack was not initialized properly.
It has to return state_num 0 when empty, which was solved by inserting
a dummy state 0 wih no node attached.

17 months agoImplement the ft_parse function
Lukas Jiriste [Thu, 20 Jun 2024 15:54:43 +0000 (17:54 +0200)]
Implement the ft_parse function

I did not yet try whether it actually functions (it probably does not).
Because managing ft_parse_inner.h was harder than I imagined
and I wanted to focus on the ft_parse function, I returned
almost everything to ft_parse.h.

17 months agoAdd a stack structure
Lukas Jiriste [Thu, 20 Jun 2024 15:50:54 +0000 (17:50 +0200)]
Add a stack structure

Add a classic FILO stack with push, top, pop and some other functions.
It is basically just a wrapper for t_vec.

It is added into a new directory ft_struct. I should have made it
instead of the ft_arr dir. I may later move t_vec and t_mat to
ft_struct.

17 months agoFix indentation
Lukas Jiriste [Thu, 20 Jun 2024 11:58:48 +0000 (13:58 +0200)]
Fix indentation

17 months agoRefactor parsing table loading
Lukas Jiriste [Thu, 20 Jun 2024 11:57:51 +0000 (13:57 +0200)]
Refactor parsing table loading

17 months agoAlign the ft_parse style with that of f_arr
Lukas Jiriste [Thu, 20 Jun 2024 11:19:52 +0000 (13:19 +0200)]
Align the ft_parse style with that of f_arr

17 months agoAdd comment about the parsing table structure
Lukas Jiriste [Thu, 20 Jun 2024 08:48:40 +0000 (10:48 +0200)]
Add comment about the parsing table structure

Parsing table shoud not contain any non-ASCII whitespace as
getting rid of multi-character whitespace is more challeging.

I mention it as I have encountered this problem and it was
somewhat difficult to find the cause.

17 months agoFix logic bug
Lukas Jiriste [Thu, 20 Jun 2024 08:47:16 +0000 (10:47 +0200)]
Fix logic bug

17 months agoFix initialization and formatting of output
Lukas Jiriste [Thu, 20 Jun 2024 06:56:32 +0000 (08:56 +0200)]
Fix initialization and formatting of output

17 months agoRefactor to make functions comply with 42 Norm
Lukas Jiriste [Sun, 16 Jun 2024 08:27:37 +0000 (10:27 +0200)]
Refactor to make functions comply with 42 Norm

17 months agoAdd printing for parsing table, fix formatting
Lukas Jiriste [Sun, 16 Jun 2024 06:18:32 +0000 (08:18 +0200)]
Add printing for parsing table, fix formatting

The ft_print_parsing_table is useful for debugging.

17 months agoFix interpretting the end of row as 0
Lukas Jiriste [Sun, 16 Jun 2024 05:16:08 +0000 (07:16 +0200)]
Fix interpretting the end of row as 0

17 months agoFix some bugs
Lukas Jiriste [Sat, 15 Jun 2024 12:34:03 +0000 (14:34 +0200)]
Fix some bugs

These bugs include:
 infinite loop
 not freeing alocated memory
 not initializing a struct before it may be returned

17 months agoFix a logic bug
Lukas Jiriste [Sat, 15 Jun 2024 08:17:54 +0000 (10:17 +0200)]
Fix a logic bug

17 months agoImplement parse_header, minor fixes
Lukas Jiriste [Sat, 15 Jun 2024 07:39:27 +0000 (09:39 +0200)]
Implement parse_header, minor fixes

17 months agoImplement ft_remove_space function
Lukas Jiriste [Sat, 15 Jun 2024 07:37:30 +0000 (09:37 +0200)]
Implement ft_remove_space function

17 months agoImplement most of parsing table loading
Lukas Jiriste [Fri, 14 Jun 2024 13:57:01 +0000 (15:57 +0200)]
Implement most of parsing table loading

Also change Makefile to include ft_parse.c in compilation.
Minor changes to ft_parse.h.

17 months agoAdd description of the format of parsing table
Lukas Jiriste [Fri, 14 Jun 2024 10:36:31 +0000 (12:36 +0200)]
Add description of the format of parsing table

18 months agoAn draft of some parsing functions and structures
Lukas Jiriste [Thu, 30 May 2024 04:49:03 +0000 (06:49 +0200)]
An draft of some parsing functions and structures

18 months agoMake ft_strlen return 0 when NULL is an argument
Lukas Jiriste [Mon, 20 May 2024 18:47:35 +0000 (20:47 +0200)]
Make ft_strlen return 0 when NULL is an argument

18 months agoFix ft_mat_insert_col by switching comparison sign
Lukas Jiriste [Mon, 6 May 2024 18:59:51 +0000 (20:59 +0200)]
Fix ft_mat_insert_col by switching comparison sign

The function has to increase capacity in the case the matrix has
insufficient capacity (not the other way around...).

18 months agoFix ft_mat_fill by swapping rows and columns
Lukas Jiriste [Fri, 12 Apr 2024 15:27:05 +0000 (17:27 +0200)]
Fix ft_mat_fill by swapping rows and columns

19 months agoAdd ft_strcat_alloc
Lukas Jiriste [Thu, 2 May 2024 09:01:39 +0000 (11:01 +0200)]
Add ft_strcat_alloc

This function behaves in similar way to ft_strncat_alloc. The difference
is that it concatenates the whole (null terminated) src string.

19 months agoFix for "0" input to be recognized as valid int
Lukas Jiriste [Thu, 25 Apr 2024 09:17:47 +0000 (11:17 +0200)]
Fix for "0" input to be recognized as valid int

19 months agoMerge branch 'isint' into no_crash
Lukas Jiriste [Wed, 10 Apr 2024 11:25:14 +0000 (13:25 +0200)]
Merge branch 'isint' into no_crash

I've forgotten to pull the repo and made changes.
Then I was lazy to recreate them after pull and I thought
it would be easier to merge the changes.

19 months agoAdd ft_isint function
Lukas Jiriste [Wed, 10 Apr 2024 11:20:46 +0000 (13:20 +0200)]
Add ft_isint function

20 months agoAdd function for filling a matrix
Lukas Jiriste [Fri, 5 Apr 2024 08:07:59 +0000 (10:07 +0200)]
Add function for filling a matrix

20 months agoAdd function for filling matrix with zeros
Lukas Jiriste [Tue, 2 Apr 2024 09:29:44 +0000 (11:29 +0200)]
Add function for filling matrix with zeros

It has to be handed an empty (just initialized) matrix as I did not
think about non-empty matrices.

20 months agoChange string writting functions to accept const
Lukas Jiriste [Fri, 8 Mar 2024 23:13:13 +0000 (00:13 +0100)]
Change string writting functions to accept const

This change is done because the writting functions do not (to my
knowledge) change the input string so it can as well be const.

21 months agoAdd ft_dprintf for outputing to file descriptor
Lukas Jiriste [Tue, 5 Mar 2024 08:24:30 +0000 (09:24 +0100)]
Add ft_dprintf for outputing to file descriptor

21 months agoFix incorect memmove
Lukas Jiriste [Thu, 29 Feb 2024 16:22:45 +0000 (17:22 +0100)]
Fix incorect memmove

21 months agoAdd ft_min and ft_max functions for int and size_t
Lukas Jiriste [Fri, 23 Feb 2024 08:08:45 +0000 (09:08 +0100)]
Add ft_min and ft_max functions for int and size_t

21 months agoMake get_next_line able to free all its memory
Lukas Jiriste [Fri, 16 Feb 2024 23:10:04 +0000 (00:10 +0100)]
Make get_next_line able to free all its memory

Passing negative fd to get_next_line now signalizes to it that it should
close (free) every buffer.

22 months agoFix indentation of ft_sgn
Lukas Jiriste [Tue, 30 Jan 2024 17:10:13 +0000 (18:10 +0100)]
Fix indentation of ft_sgn

22 months agoAdd ft_sgn signum function
Lukas Jiriste [Thu, 18 Jan 2024 09:56:04 +0000 (10:56 +0100)]
Add ft_sgn signum function

22 months agoImprove matrix handling, remove VEC_INIT macro
Lukas Jiriste [Wed, 17 Jan 2024 13:56:09 +0000 (14:56 +0100)]
Improve matrix handling, remove VEC_INIT macro

Improve matrix insertion by patching bugs and adding bounds checking.
Insert VEC_INIT macro as it is forbidden by the Norm.
Add ft_mat_access as matrix analog to ft_vec_access.

22 months agoAdd a macro for t_vec initialization
Lukas Jiriste [Sun, 14 Jan 2024 16:16:47 +0000 (17:16 +0100)]
Add a macro for t_vec initialization

Add macro for static t_vec initialization, because it needs a
compilation-time constant, which functions cannot (?) achieve.
This macro resolves to compound literal and lacks a check but should
be good enough.

22 months agoPatch the issues of previous commit.
Lukas Jiriste [Sat, 13 Jan 2024 14:00:45 +0000 (15:00 +0100)]
Patch the issues of previous commit.

Patch ft_strcmp.c so that it actually compiles...
Add ft_strcmp to header file and the Makefile so that it is usable and
compiles to libft.a.

22 months agoAdd ft_strcmp function.
Lukas Jiriste [Sat, 13 Jan 2024 13:50:39 +0000 (14:50 +0100)]
Add ft_strcmp function.

Add ft_strcmp as it may be more ergonomic than ft_strncmp.
Add *.swp rule to .gitignore so that those won't bother me while vim is
opened.

22 months agoAdd functions for finding element in vector
Lukas Jiriste [Fri, 12 Jan 2024 20:27:38 +0000 (21:27 +0100)]
Add functions for finding element in vector

22 months agoImplement matrix t_mat as a wrapper around t_vec
Lukas Jiriste [Sat, 23 Dec 2023 11:47:27 +0000 (12:47 +0100)]
Implement matrix t_mat as a wrapper around t_vec

Implement new struct for matrix and some basic utilities. Everything
passes strict compilation and norminette, but may contain bugs in logic.
Testing recommended (though it will probably happen when this is
needed).
Extract ft_vec_forget from ft_vec_erase which functions as ft_vec_erase
with free_el = NULL.

23 months agoRemove void* arithmetic, conform to the Norm
Lukas Jiriste [Mon, 11 Dec 2023 19:07:39 +0000 (20:07 +0100)]
Remove void* arithmetic, conform to the Norm

Add -Wpedantic option for compilation to Makefile to catch all mistakes.
Cast void* to char* for any arithmetic done.
Split lines that are too long to fit the 80 char limit of the 42 Norm.

23 months agoAdd some t_vec functions and change name
Lukas Jiriste [Mon, 11 Dec 2023 09:27:36 +0000 (10:27 +0100)]
Add some t_vec functions and change name

Add functions for inserting and erasing multiple elements.
Rename dir ft_vec to ft_arr and rename ft_vec.h to ft_arr.h for future
implementation of other array structures (matrices).

23 months agoImprove ft_vec_erase and ft_vec_free
Lukas Jiriste [Sun, 10 Dec 2023 14:01:59 +0000 (15:01 +0100)]
Improve ft_vec_erase and ft_vec_free

Add function for freeing element to ft_vec_erase and ft_vec_free for the
ability to handle advanced elements (elements which may point to heap).

23 months agoAdd a ft_vec module for vector struct
Lukas Jiriste [Sat, 9 Dec 2023 17:26:53 +0000 (18:26 +0100)]
Add a ft_vec module for vector struct

Add vector struct and operations on it that are somewhat similar to C++
std::vector.

23 months agoMove all "public" header files to ./inc directory
Lukas Jiriste [Sat, 9 Dec 2023 17:03:13 +0000 (18:03 +0100)]
Move all "public" header files to ./inc directory

This makes compiling easier, as only one directory has to be given
through the -I compiler option.

23 months agoEnforce header inclusion rules
Lukas Jiriste [Sat, 9 Dec 2023 14:56:42 +0000 (15:56 +0100)]
Enforce header inclusion rules

The following rules are (to be) used:
 -Sort header inclusion from local to global
 -Always include header which declares the functions in file
 -Only include header when it is neccesary for compilation

23 months agoSet e-mail in the 42 header to the correct one
Lukas Jiriste [Sat, 9 Dec 2023 14:15:32 +0000 (15:15 +0100)]
Set e-mail in the 42 header to the correct one

Change e-mail address in 42 header to ljiriste@student.42prague.com
instead of marvin@42.fr that was the default.

23 months agoChange file structure of this library
Lukas Jiriste [Sat, 9 Dec 2023 12:43:15 +0000 (13:43 +0100)]
Change file structure of this library

Separate source files (functions) to folders by topic.
Create separate header file each folder.
Adjust Makefile and libft.h accordingly.

23 months agoPatch ft_lst_sorted_insert to actually insert
Lukas Jiriste [Thu, 7 Dec 2023 09:26:34 +0000 (10:26 +0100)]
Patch ft_lst_sorted_insert to actually insert

2 years agoAdd long and long long versions of ft_atoi.
Lukas Jiriste [Wed, 6 Dec 2023 09:45:45 +0000 (10:45 +0100)]
Add long and long long versions of ft_atoi.

Add the functions ft_atol and ft_atoll to the file ft_atoi.c.
Add prototypes of these functions to libft.h.

2 years agoChange permissions of files added in previous commit
Lukas Jiriste [Sun, 3 Dec 2023 20:28:28 +0000 (21:28 +0100)]
Change permissions of files added in previous commit

Remove execute permission from ft_strncat_alloc.c and get_next_line.c as
source files are not executable.

2 years agoAdd get_next_line to libft
Lukas Jiriste [Sun, 3 Dec 2023 19:41:16 +0000 (20:41 +0100)]
Add get_next_line to libft

Splice get_next_line project neatly fit it inside libft while conforming
the Norm.
Change libft.h and Makefile accordingly.

2 years agoChange subproject handling, add advanced list funcs
Lukas Jiriste [Fri, 3 Nov 2023 16:03:35 +0000 (17:03 +0100)]
Change subproject handling, add advanced list funcs

Turn submodules into standard folder.
- Submodules were probably not the correct choice int the first place
- Makefile handling of submodules was bad and hacky
Turn list handling to subproject ft_lst, add advanced list handling.
Change Makefile and header accordingly.

2 years agoUpdate ft_printf for its .gitignore
Lukas Jiriste [Wed, 1 Nov 2023 12:38:51 +0000 (13:38 +0100)]
Update ft_printf for its .gitignore

2 years agoAdded .gitignore not to disturb git status when built
Lukas Jiriste [Wed, 1 Nov 2023 11:47:58 +0000 (12:47 +0100)]
Added .gitignore not to disturb git status when built

2 years agoAdded ft_printf as a submodule.
Lukas Jiriste [Tue, 3 Oct 2023 16:46:16 +0000 (18:46 +0200)]
Added ft_printf as a submodule.
Quite some changes where made in Makefile to make it work
and it is not pretty.
Update to libft.h by the ft_printf function prototype.

2 years agoRemoved assigning to dest[n+1]. It should have been dest[n], but is redundant.
Lukas Jiriste [Wed, 27 Sep 2023 13:46:12 +0000 (15:46 +0200)]
Removed assigning to dest[n+1]. It should have been dest[n], but is redundant.

2 years agoAdded the function itoa_base fr unsigned integers. Changed libft.h accordingly.
Lukas Jiriste [Fri, 15 Sep 2023 16:48:24 +0000 (18:48 +0200)]
Added the function itoa_base fr unsigned integers. Changed libft.h accordingly.

2 years agoThis branch will contain functions that don't crash in cases in which the std functio...
Lukas Jiriste [Mon, 11 Sep 2023 11:17:47 +0000 (13:17 +0200)]
This branch will contain functions that don't crash in cases in which the std functions probably crash.
This functionality may be useful but is held on separate branch in order to have "pure" std functionality also.

2 years agoRepaired the function, so it can return "0" and doesn't write outside allocated memory.
Lukas Jiriste [Fri, 8 Sep 2023 10:11:54 +0000 (12:11 +0200)]
Repaired the function, so it can return "0" and doesn't write outside allocated memory.

2 years agoMerge branch '42Project' as it holds patched functions.
Lukas Jiriste [Wed, 6 Sep 2023 11:23:43 +0000 (13:23 +0200)]
Merge branch '42Project' as it holds patched functions.

2 years agoSetting errno for inappropriate input has been removed as Moulinette
Lukas Jiriste [Wed, 6 Sep 2023 11:07:57 +0000 (13:07 +0200)]
Setting errno for inappropriate input has been removed as Moulinette
deems functions around errno forbidden.

2 years agoft_strtrim now passes alelievr/libft-unit-test as do all other functions.
Lukas Jiriste [Wed, 6 Sep 2023 11:01:47 +0000 (13:01 +0200)]
ft_strtrim now passes alelievr/libft-unit-test as do all other functions.

2 years agoChanged the functions so that they pass the alelievr/libft-unit-test.
Lukas Jiriste [Tue, 5 Sep 2023 17:14:17 +0000 (19:14 +0200)]
Changed the functions so that they pass the alelievr/libft-unit-test.
ft_strtrim needs to also handle empty strings and strings containing only chars from set.

2 years agoft_ctoa forward declaration has not been included in libft.h in previous commit.
Lukas Jiriste [Tue, 5 Sep 2023 10:07:35 +0000 (12:07 +0200)]
ft_ctoa forward declaration has not been included in libft.h in previous commit.

2 years agoAdded functions abs, ctoa and itoa_base and changed header and Makefile accordingly.
Lukas Jiriste [Tue, 5 Sep 2023 09:48:50 +0000 (11:48 +0200)]
Added functions abs, ctoa and itoa_base and changed header and Makefile accordingly.

2 years agoRepaired ft_strndup. It duplicated n - 1 characters.
Lukas Jiriste [Thu, 24 Aug 2023 09:24:05 +0000 (11:24 +0200)]
Repaired ft_strndup. It duplicated n - 1 characters.

2 years agoErased mentions of bonus from Makefile and libft.h as it is no longer needed.
Lukas Jiriste [Thu, 24 Aug 2023 08:08:00 +0000 (10:08 +0200)]
Erased mentions of bonus from Makefile and libft.h as it is no longer needed.

2 years agoAdded ft_strndup, because it is usefull for ft_printf.
Lukas Jiriste [Thu, 24 Aug 2023 07:47:08 +0000 (09:47 +0200)]
Added ft_strndup, because it is usefull for ft_printf.
Changed libft.h accordingly.

2 years agoAdded bonus functions and changed libft.h and Makefile accordingly.
Lukas Jiriste [Wed, 16 Aug 2023 15:46:11 +0000 (17:46 +0200)]
Added bonus functions and changed libft.h and Makefile accordingly.

2 years agoFunction ft_strtrim now allocates exactly the memory needed for the resulting string.
Lukas Jiriste [Wed, 16 Aug 2023 15:41:49 +0000 (17:41 +0200)]
Function ft_strtrim now allocates exactly the memory needed for the resulting string.
?inor changes were also made to make the code more consistent.

2 years agoRepaired functions to pass the Tripouille libftTester (mostly - I don't think some...
Lukas Jiriste [Wed, 16 Aug 2023 09:28:16 +0000 (11:28 +0200)]
Repaired functions to pass the Tripouille libftTester (mostly - I don't think some KOs are reasonable).

2 years agoImplemented functions of Part 2 and repaired older functions.
Lukas Jiriste [Tue, 15 Aug 2023 15:15:58 +0000 (17:15 +0200)]
Implemented functions of Part 2 and repaired older functions.
Everything passes norminette, compiles and links, but there are issues to be resolved.

2 years agoImplemented every function from Part 1.
Lukas Jiriste [Tue, 15 Aug 2023 11:03:47 +0000 (13:03 +0200)]
Implemented every function from Part 1.
Added libft.h header and Makefile.
Everything passes norminette and compiles to libft.a on make command.

2 years agoAdded a couple of wanted functions.
Lukas Jiriste [Mon, 14 Aug 2023 11:45:12 +0000 (13:45 +0200)]
Added a couple of wanted functions.
Also added 2 additional functions - islower and isupper.
These functions naturaly fit in and are used for more readible implementation of other functions.
Each .c file includes the library header libft.h (libft.h is not added in this commit).