mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
tests: some fixes
This commit is contained in:
parent
ea3ecaaf31
commit
f0755cd6c4
3 changed files with 29 additions and 13 deletions
19
src/env/env_manip.c
vendored
19
src/env/env_manip.c
vendored
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* env_manip.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/12 18:29:12 by jguelen #+# #+# */
|
||||
/* Updated: 2025/03/14 10:52:39 by jguelen ### ########.fr */
|
||||
/* Created: 2025/03/19 17:55/24 by khais #+# #+# */
|
||||
/* Updated: 2025/03/19 17:55:24 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -97,8 +97,8 @@ static void env_add_back(t_env **env, t_env *new)
|
|||
** freed. In case a node matching the given key is found the provided key value
|
||||
** is freed.
|
||||
**
|
||||
** If key is null, both key and value are freed and NULL is returned. ft_errno
|
||||
** is set to FT_EINVAL. We therefore allow for a value to be NULL.
|
||||
** If key or value is null, both key and value are freed and NULL is returned.
|
||||
** ft_errno is set to FT_EINVAL. We therefore allow for a value to be NULL.
|
||||
**
|
||||
** If key is an empty string, key and value are freed, ft_errno is set to
|
||||
** FT_EBADID, and NULL is returned.
|
||||
|
|
@ -111,12 +111,19 @@ static void env_add_back(t_env **env, t_env *new)
|
|||
** Warning: does not check for validity of a key beyond what is described above.
|
||||
**
|
||||
** Implementation notes: free2 always returns NULL
|
||||
**
|
||||
** Note: once you pass a key to this function, if you pass it a second time, it
|
||||
** will cause bad behaviour.
|
||||
**
|
||||
** Once you passed key and/or value to this function, env is the owner of these
|
||||
** values and is responsible for freeing them. Do not pass multiple times the
|
||||
** same pointers to this function!
|
||||
*/
|
||||
t_env *env_set_entry(t_env **env, char *key, char *value)
|
||||
{
|
||||
t_env *node;
|
||||
|
||||
if (key == NULL)
|
||||
if (key == NULL || value == NULL)
|
||||
return (ft_errno(FT_EINVAL), free2(key, value));
|
||||
if (*key == '\0')
|
||||
return (ft_errno(FT_EBADID), free2(key, value));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue