Skip to content

Commit e297ed1

Browse files
authored
Merge branch 'main' into feature/155-rm-dummy-func
2 parents d3807ae + 888b53d commit e297ed1

31 files changed

+455
-242
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# By: ttsubo <[email protected]> +#+ +:+ +#+ #
77
# +#+#+#+#+#+ +#+ #
88
# Created: 2025/04/03 12:55:20 by ttsubo #+# #+# #
9-
# Updated: 2025/04/25 21:59:36 by ttsubo ### ########.fr #
9+
# Updated: 2025/04/26 11:30:48 by ttsubo ### ########.fr #
1010
# #
1111
# **************************************************************************** #
1212

@@ -50,7 +50,8 @@ INVOKE_CMD_SRC = create_envp.c exec_pipeline.c execute_cmd.c \
5050
execute_cmd_helper.c invoke_command.c pipeline_helper.c
5151
TOKENIZER_SRC = tokenizer.c tokenizer_error.c read_token.c \
5252
is_quote_closed.c get_token_capa.c is_redirect_validate.c
53-
PARSER_SRC = allocate_cmds.c parser.c parser_utils.c setup_cmds.c
53+
PARSER_SRC = allocate_cmds.c parser.c parser_utils.c setup_cmds.c \
54+
expand_env.c expand_env_utils.c
5455
BUILTIN_SRC = cd.c exit.c pwd.c echo.c env.c unset.c \
5556
env_utils.c env_utils_2.c builtin_utils.c
5657

inc/env_utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2025/04/17 10:25:47 by dayano #+# #+# */
9-
/* Updated: 2025/04/20 19:01:56 by ttsubo ### ########.fr */
9+
/* Updated: 2025/04/26 10:19:56 by ttsubo ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -15,6 +15,7 @@
1515

1616
# include "struct.h"
1717

18+
char *get_env_value(t_env *current, const char *key);
1819
void free_env_content(char *value);
1920
void remove_env_node(t_env **env_lst, t_env *target);
2021

inc/expand_env.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* expand_env.h :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2025/04/26 11:24:25 by ttsubo #+# #+# */
9+
/* Updated: 2025/04/26 11:50:18 by ttsubo ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#ifndef EXPAND_ENV_H
14+
# define EXPAND_ENV_H
15+
16+
# include "env_utils.h"
17+
# include "struct.h"
18+
# include <stdbool.h>
19+
20+
typedef struct s_expand_env
21+
{
22+
size_t pre_len;
23+
size_t key_st;
24+
size_t key_len;
25+
} t_expand_env;
26+
27+
typedef struct s_expand_temp
28+
{
29+
char *key;
30+
char *value;
31+
char *prefix;
32+
char *suffix;
33+
char *result;
34+
} t_expand_temp;
35+
36+
char *expand_env(char *token, t_minish *minish);
37+
bool is_key_start(int c);
38+
bool is_key_char(int c);
39+
40+
#endif

inc/parser.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2025/04/21 14:14:59 by ttsubo #+# #+# */
9-
/* Updated: 2025/04/25 18:16:23 by ttsubo ### ########.fr */
9+
/* Updated: 2025/04/26 11:48:11 by ttsubo ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -15,12 +15,13 @@
1515

1616
# include "cmd.h"
1717
# include "libft.h"
18+
# include "expand_env.h"
1819

19-
t_cmd **parser(char **tokens);
20+
t_cmd **parser(char **tokens, t_minish *minish);
2021
size_t cmds_len(t_cmd **cmds);
2122
int is_separator(char *token);
2223
void free_cmds(t_cmd **cmds, size_t count);
2324
t_cmd **allocate_cmds(char **tokens);
24-
t_cmd **setup_cmds(t_cmd **cmds, char **tokens);
25+
t_cmd **setup_cmds(t_cmd **cmds, char **tokens, t_minish *minish);
2526

2627
#endif

lib/libft/ft_memmove.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/10/28 13:44:03 by ttsubo #+# #+# */
9-
/* Updated: 2024/12/23 19:56:10 by ttsubo ### ########.fr */
9+
/* Updated: 2025/04/27 15:10:56 by ttsubo ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "libft.h"
1414

1515
/**
16-
* @brief src領域をdst領域にオーバーラップを考慮したコピーを行います。
16+
* @brief Copy the src area to the dst area considering overlap.
1717
*
18-
* @param [out] dst : コピー先のメモリ領域
19-
* @param [in] src : コピー元のメモリ領域
20-
* @param [in] len : コピーする領域の長さ
21-
* @return void* : dstを返します
18+
* @param [out] dst :
19+
* @param [in] src :
20+
* @param [in] len :
21+
* @return void* : return dst
2222
* @note :
23-
* dstとsrcのメモリアドレス番地の位置で挙動が変わります。
24-
* dst < src なら前方からコピー
25-
* dst == src ならdをそのまま返す(内容が同じのため)
26-
* それ以外は後方コピーを行います
23+
* The behavior of this function changes with the position of dst and src.
24+
* If dst < src, copy from the front.
25+
* If dst == src, returns dst as is.
26+
* Otherwise, copy from behind.
2727
*/
2828
void *ft_memmove(void *dst, const void *src, size_t len)
2929
{

lib/libft/ft_memset.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/10/28 11:54:35 by ttsubo #+# #+# */
9-
/* Updated: 2024/12/23 19:38:03 by ttsubo ### ########.fr */
9+
/* Updated: 2025/04/27 15:14:49 by ttsubo ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "libft.h"
1414

1515
/**
16-
* @brief メモリ領域bを文字cで穴埋めします
16+
* @brief Fill memory area b with letter c.
1717
*
18-
* @param [out] b : メモリ領域
19-
* @param [in] c : 穴埋めする文字
20-
* @param [in] len : 穴埋めする長さ
21-
* @retval void* : 穴埋めしたメモリ領域
22-
* @retval NULL : bがNULLの場合
18+
* @param [out] b : memory area
19+
* @param [in] c : fill letter
20+
* @param [in] len : length
21+
* @retval void* : return b;
22+
* @retval NULL : If b is NULL.
2323
* @note :
24-
* 内部でuchar型にキャストするので、
25-
* 0-255の範囲外の数字は上位ビットが無視された値で使われます。
24+
* This function internally casts int c to uchar.
25+
* Therefore, upper bits outside the range 0-255 are ignored in its operation.
2626
*/
2727
void *ft_memset(void *b, int c, size_t len)
2828
{

lib/libft/ft_printf/srcs/ft_printf.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@
66
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/11 14:24:10 by ttsubo #+# #+# */
9-
/* Updated: 2025/01/24 10:58:19 by ttsubo ### ########.fr */
9+
/* Updated: 2025/04/27 15:35:04 by ttsubo ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "ft_printf.h"
1414

1515
/**
16-
* @brief strが%の場合それに応じたフォーマットを出力します
17-
*
18-
* @param str : %[csdiu%]
19-
* @param args : formatに関する引数
20-
* @return int : 出力した文字列の長さ
21-
* @note pre: %からはじまること
16+
* @brief If str is %, output format accordingly
17+
*
18+
* @param str
19+
* @param args
20+
* @return int
2221
*/
2322
static int _format(const char **str, va_list *args)
2423
{
@@ -50,11 +49,12 @@ static int _format(const char **str, va_list *args)
5049
}
5150

5251
/**
53-
* @brief 渡された引数をフォーマットに従って変換し標準出力に出力します
54-
*
55-
* @param [in] str : 出力する文字列(フォーマットを含む場合もある)
56-
* @param [in] ... : フォーマットに与える変数
57-
* @return int : 出力した文字列の長さ
52+
* @brief Outputs str to standard output.
53+
* If arguments are present, they are converted to match the format.
54+
*
55+
* @param str
56+
* @param ...
57+
* @return int
5858
*/
5959
int ft_printf(const char *str, ...)
6060
{

lib/libft/ft_printf/srcs/ft_printf_utils1.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/12/05 15:09:58 by ttsubo #+# #+# */
9-
/* Updated: 2025/01/24 10:58:19 by ttsubo ### ########.fr */
9+
/* Updated: 2025/04/27 15:28:10 by ttsubo ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "ft_printf_utils.h"
1414

1515
/**
16-
* @brief fdに文字cを出力します
16+
* @brief Outputs the letter c to fd.
1717
*
18-
* @param c : 文字
19-
* @param fd : ファイルディスクリプタ
20-
* @return size_t : 文字の長さ(おおよそ1)
18+
* @param c : char
19+
* @param fd : file descriptor
20+
* @return size_t : char length.(approximately 1)
2121
*/
2222
size_t ptf_putchar_fd(char c, int fd)
2323
{
2424
return (write(fd, &c, 1));
2525
}
2626

2727
/**
28-
* @brief 文字列sをfdに出力します
28+
* @brief Outputs the string s to fd.
2929
*
30-
* @param s : 文字列
31-
* @param fd : ファイルディスクリプタ
32-
* @return size_t : 文字列の長さ
30+
* @param s : string
31+
* @param fd : file descriptor
32+
* @return size_t : string length
3333
*/
3434
size_t ptf_putstr_fd(char *s, int fd)
3535
{
@@ -44,11 +44,11 @@ size_t ptf_putstr_fd(char *s, int fd)
4444
}
4545

4646
/**
47-
* @brief 符号ありの数字numをfdに出力します
47+
* @brief Outputs the signed n num to fd.
4848
*
49-
* @param num : 符号あり整数
50-
* @param fd : ファイルディスクリプタ
51-
* @return size_t : 符号なし数値の長さ
49+
* @param num : int
50+
* @param fd : file descriptor
51+
* @return size_t : n length
5252
*/
5353
size_t ptf_putnum_fd(int n, int fd)
5454
{
@@ -73,11 +73,11 @@ size_t ptf_putnum_fd(int n, int fd)
7373
}
7474

7575
/**
76-
* @brief 符号なしの数字unumをfdに出力します
76+
* @brief Output unsigned number n to fd.
7777
*
78-
* @param unum : 符号なし数値
79-
* @param fd : ファイルディスクリプタ
80-
* @return size_t : 符号なし数値の長さ
78+
* @param n : ungigned number
79+
* @param fd : file descriptor
80+
* @return size_t : n length
8181
*/
8282
size_t ptf_putunum_fd(unsigned int n, int fd)
8383
{
@@ -94,13 +94,13 @@ size_t ptf_putunum_fd(unsigned int n, int fd)
9494
}
9595

9696
/**
97-
* @brief 符号なし整数を16進数形式の文字列で出力します
97+
* @brief Output unsigned integer as string in hexadecimal format.
9898
*
99-
* @param num : 変換する符号なし整数
100-
* @param fd : ファイルディスクリプタ
101-
* @param is_upper : 大文字表記にするかのフラグ(1だと有効)
102-
* @return char* : 変換後の文字列の先頭ポインタ
103-
* @note : pre: 負の数は呼び出し元で変換すること
99+
* @param num : Unsigned integer to convert
100+
* @param fd : file descriptor
101+
* @param is_upper : Flag for capitalization (1 means valid)
102+
* @return char* : First pointer of converted string
103+
* @note : pre: Negative numbers must be converted at the caller
104104
*/
105105
size_t ptf_puthex_fd(unsigned int n, int fd, int is_upper)
106106
{

lib/libft/ft_printf/srcs/ft_printf_utils2.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/12/05 15:09:58 by ttsubo #+# #+# */
9-
/* Updated: 2025/01/24 10:58:19 by ttsubo ### ########.fr */
9+
/* Updated: 2025/04/27 15:31:43 by ttsubo ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "ft_printf_utils.h"
1414

1515
/**
16-
* @brief ptf_putptr_fdのアドレス出力用の再帰関数
17-
*
18-
* @param hex : 16進数のアドレス
19-
* @param fd : ファイルディスクリプタ
20-
* @return size_t : 出力した文字の長さ
16+
* @brief Recursive function for ptf_putptr_fd address output
17+
*
18+
* @param hex
19+
* @param fd
20+
* @return size_t
2121
*/
2222
static size_t _ptf_putptr_fd_rec(uintptr_t hex, int fd)
2323
{
@@ -34,11 +34,11 @@ static size_t _ptf_putptr_fd_rec(uintptr_t hex, int fd)
3434
}
3535

3636
/**
37-
* @brief ポインタを16進数形式で出力します
38-
*
39-
* @param ptr : アドレスを出力したいポインタ
40-
* @param fd : ファイルディスクリプタ
41-
* @return size_t : 出力した文字列の長さ
37+
* @brief Output pointer in hexadecimal format
38+
*
39+
* @param ptr
40+
* @param fd
41+
* @return size_t
4242
*/
4343
size_t ptf_putptr_fd(void *ptr, int fd)
4444
{
@@ -52,12 +52,12 @@ size_t ptf_putptr_fd(void *ptr, int fd)
5252
}
5353

5454
/**
55-
* @brief メモリ領域bをcで長さlenまで埋めます
55+
* @brief Fill memory area b with letter c.
5656
*
57-
* @param b : メモリ領域
58-
* @param c : 埋める形式 (0-255までの数値)
59-
* @param len : 埋める長さ
60-
* @return void* : 適用後のメモリ領域の先頭アドレス
57+
* @param b
58+
* @param c
59+
* @param len
60+
* @return void*
6161
*/
6262
void *ftp_memset(void *b, int c, size_t len)
6363
{

lib/libft/ft_strlen_until.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2025/02/15 15:38:39 by ttsubo #+# #+# */
9-
/* Updated: 2025/02/15 15:42:27 by ttsubo ### ########.fr */
9+
/* Updated: 2025/04/27 15:16:08 by ttsubo ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "libft.h"
1414

1515
/**
16-
* @brief 文字stopまでの文字列sの長さを返します。
16+
* @brief Returns the length of string s up to character stop.
1717
*
1818
* @param s
1919
* @param stop
2020
* @return size_t
21-
* @note stopが見つからない場合、文字列sの長さが返されます。
21+
* @note If stop not found, return s length.
2222
*/
2323
size_t ft_strlen_until(const char *s, char stop)
2424
{

0 commit comments

Comments
 (0)