Adding files for normed
This commit is contained in:
parent
ef7677f2ee
commit
4c00800ad3
3 changed files with 24 additions and 19 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/07 14:22:50 by rparodi #+# #+# */
|
||||
/* Updated: 2024/08/18 22:54:31 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/30 17:53:25 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,7 +16,8 @@
|
|||
#include "me/str/str.h"
|
||||
#include "me/types.h"
|
||||
|
||||
static t_error _append_key_to_vec(t_usize _idx, const t_str *key, t_str *value, void *vec)
|
||||
static t_error _append_key_to_vec(\
|
||||
t_usize _idx, const t_str *key, t_str *value, void *vec)
|
||||
{
|
||||
(void)(value);
|
||||
(void)(_idx);
|
||||
|
|
@ -26,10 +27,10 @@ static t_error _append_key_to_vec(t_usize _idx, const t_str *key, t_str *value,
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
static bool _sort_str(t_str *_lhs, t_str *_rhs)
|
||||
static bool _sort_str(t_str *_lhs, t_str *_rhs)
|
||||
{
|
||||
t_str lhs;
|
||||
t_str rhs;
|
||||
t_str lhs;
|
||||
t_str rhs;
|
||||
|
||||
if (_lhs == NULL && _rhs != NULL)
|
||||
return (true);
|
||||
|
|
@ -47,12 +48,13 @@ static bool _sort_str(t_str *_lhs, t_str *_rhs)
|
|||
return (*lhs < *rhs);
|
||||
}
|
||||
|
||||
t_error builtin_env___(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
||||
t_error builtin_env___(\
|
||||
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
||||
{
|
||||
t_vec_str keys;
|
||||
t_vec_str keys_uniq;
|
||||
t_usize i;
|
||||
t_str *value;
|
||||
t_vec_str keys;
|
||||
t_vec_str keys_uniq;
|
||||
t_usize i;
|
||||
t_str *value;
|
||||
|
||||
keys = vec_str_new(16, NULL);
|
||||
hmap_env_iter(state->env, _append_key_to_vec, &keys);
|
||||
|
|
@ -64,13 +66,13 @@ t_error builtin_env___(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
|||
vec_str_sort(&keys, _sort_str);
|
||||
while (i < keys.len)
|
||||
{
|
||||
while (i < keys.len - 1 && str_compare(keys.buffer[i], keys.buffer[i + 1]))
|
||||
while (i < keys.len - 1 && \
|
||||
str_compare(keys.buffer[i], keys.buffer[i + 1]))
|
||||
i++;
|
||||
vec_str_push(&keys_uniq, keys.buffer[i]);
|
||||
i++;
|
||||
}
|
||||
vec_str_free(keys);
|
||||
|
||||
i = 0;
|
||||
while (i < keys_uniq.len)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/07 13:58:37 by rparodi #+# #+# */
|
||||
/* Updated: 2024/08/14 18:15:16 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/30 17:54:31 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,9 +16,10 @@
|
|||
#include "me/types.h"
|
||||
#include <errno.h>
|
||||
|
||||
t_error builtin_pwd___(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
||||
t_error builtin_pwd___(\
|
||||
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
||||
{
|
||||
t_string s;
|
||||
t_string s;
|
||||
|
||||
(void)(state);
|
||||
s = string_new(1024);
|
||||
|
|
@ -27,7 +28,8 @@ t_error builtin_pwd___(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
|||
if (errno == ERANGE)
|
||||
string_reserve(&s, s.capacity * 3);
|
||||
else
|
||||
return (*exit_code = 1, string_free(s), me_printf_fd(info.stderr, "cd: Unable to get current directory\n"), NO_ERROR);
|
||||
return (*exit_code = 1, string_free(s), me_printf_fd(\
|
||||
info.stderr, "cd: Unable to get current directory\n"), NO_ERROR);
|
||||
}
|
||||
me_printf_fd(info.stdout, "%s\n", s.buf);
|
||||
string_free(s);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/14 18:15:19 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/30 17:54:55 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,9 +17,10 @@
|
|||
#include "me/string/string.h"
|
||||
#include "me/types.h"
|
||||
|
||||
t_error builtin_unset_(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
||||
t_error builtin_unset_(\
|
||||
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
||||
{
|
||||
t_usize i;
|
||||
t_usize i;
|
||||
|
||||
(void)(state);
|
||||
i = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue