Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minishell norminette 처리 #3

Merged
merged 1 commit into from
Jan 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions circle-03/minishell/includes/astree.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/23 14:38:26 by jseo #+# #+# */
/* Updated: 2021/12/31 21:10:19 by jseo ### ########.fr */
/* Updated: 2022/01/01 09:59:57 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -45,7 +45,7 @@
** =============================================================================
*/

typedef void (*t_as_exec_fn)();
typedef void (*t_as_exec_fn)();

/*
** =============================================================================
Expand Down
6 changes: 3 additions & 3 deletions circle-03/minishell/includes/rbtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/22 18:35:07 by jseo #+# #+# */
/* Updated: 2021/12/30 16:52:42 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:00:23 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -50,7 +50,7 @@
# define RB_INSERT "function rb_insert, "

# define GET_NODE "function get_node, "
# define GET_VAlUE "function get_value, "
# define GET_VALUE "function get_value, "

# define SET_COLOR "function set_color, "
# define GET_PARENT "function get_parent, "
Expand Down Expand Up @@ -81,7 +81,7 @@
** =============================================================================
*/

typedef int (*t_rb_cmp_fn)(void *key_a, void *key_b);
typedef int (*t_rb_cmp_fn)(void *key_a, void *key_b);

/*
** =============================================================================
Expand Down
6 changes: 3 additions & 3 deletions circle-03/minishell/srcs/astree/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/28 02:47:20 by jseo #+# #+# */
/* Updated: 2021/12/30 16:30:56 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:15:45 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -23,13 +23,13 @@

static inline void rollback(int fd0, int fd1)
{
int ret;
int ret;

ret = dup2(fd0, STDIN_FILENO);
as_assert(ret != ERROR, \
AASSERT "(ret != ERROR), " ROLLBACK AEXEC_FILE "line 20.");
ret = dup2(fd1, STDOUT_FILENO);
as_assert(ret != ERROR, \
as_assert(ret != ERROR, \
AASSERT "(ret != ERROR), " ROLLBACK AEXEC_FILE "line 23.");
close(fd0);
close(fd1);
Expand Down
4 changes: 2 additions & 2 deletions circle-03/minishell/srcs/builtin/cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/26 12:16:30 by jseo #+# #+# */
/* Updated: 2021/12/28 22:51:41 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:01:22 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -39,7 +39,7 @@ static inline int rollback(char *oldpath, char *newpath, int ret)
** newpath - Path after Change Directory
*/

int builtin_cd(char **args, t_rb *envmap)
int builtin_cd(char **args, t_rb *envmap)
{
int ret;
char *oldpath;
Expand Down
4 changes: 2 additions & 2 deletions circle-03/minishell/srcs/builtin/echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/26 12:16:33 by jseo #+# #+# */
/* Updated: 2021/12/28 22:47:35 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:01:06 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -30,7 +30,7 @@ int builtin_echo(char **args)
jputchar('\n', STDOUT_FILENO);
return (VALID);
}
if (!jstrncmp("-n", *(++args), BUFFER_SIZE))
if (!jstrncmp("-n", *(++args), BUFFER_SIZE))
++option;
args += option;
while (*args != NULL)
Expand Down
8 changes: 4 additions & 4 deletions circle-03/minishell/srcs/jfunction/jatoi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/09 17:56:47 by jseo #+# #+# */
/* Updated: 2021/12/26 22:54:41 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:02:58 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -15,9 +15,9 @@
static inline bool overflowed(int former, int latter)
{
if (((former >= 0) != ((former << 1) >= 0))
|| ((former >= 0) != ((former << 2) >= 0))
|| ((former >= 0) != ((former << 3) >= 0))
|| ((former >= 0) != (latter >= 0)))
|| ((former >= 0) != ((former << 2) >= 0))
|| ((former >= 0) != ((former << 3) >= 0))
|| ((former >= 0) != (latter >= 0)))
return (true);
return (false);
}
Expand Down
6 changes: 3 additions & 3 deletions circle-03/minishell/srcs/jfunction/jgnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/19 17:45:45 by jseo #+# #+# */
/* Updated: 2021/12/26 22:54:45 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:01:54 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -86,8 +86,8 @@ int jgnl(int fd, char **line)
int ret;
static char *mem[OPEN_MAX + 3];

if (fd < 0 || !line || BUFFER_SIZE < 1 || OPEN_MAX <= fd ||
!jcalloc((void **)(&buf), BUFFER_SIZE + 1, sizeof(char)))
if (fd < 0 || !line || BUFFER_SIZE < 1 || OPEN_MAX <= fd
|| !jcalloc((void **)(&buf), BUFFER_SIZE + 1, sizeof(char)))
return (ERROR);
while (true)
{
Expand Down
4 changes: 2 additions & 2 deletions circle-03/minishell/srcs/jfunction/jsplit.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/05 17:45:48 by jseo #+# #+# */
/* Updated: 2021/12/26 22:55:14 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:02:16 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

#include "jfunction.h"

static inline char **wordfree(char **s, int i)
static inline char **wordfree(char **s, int i)
{
while (--i >= 0 && s[i])
jfree((void **)(&(s[i])));
Expand Down
4 changes: 2 additions & 2 deletions circle-03/minishell/srcs/jfunction/jstrtrim.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/09 17:56:34 by jseo #+# #+# */
/* Updated: 2021/12/26 22:55:17 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:02:42 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

#include "jfunction.h"

void jstrtrim(char **s)
{
size_t len;
size_t len;

while (jisspace(**s))
++(*s);
Expand Down
4 changes: 2 additions & 2 deletions circle-03/minishell/srcs/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/22 17:41:44 by jseo #+# #+# */
/* Updated: 2021/12/30 18:39:00 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:24:27 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -25,7 +25,7 @@
** envmap - Variable for Maps the Environment Variables
*/

int main(int argc, char **argv, char **envp)
int main(int argc, char **argv, char **envp)
{
char *input;
t_lst *chunks;
Expand Down
6 changes: 3 additions & 3 deletions circle-03/minishell/srcs/parse/expand_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/27 12:00:58 by jseo #+# #+# */
/* Updated: 2021/12/28 14:18:13 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:22:59 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -98,7 +98,8 @@ static inline char *expand_brace(t_lst *brace)
** brace - Chunks of the Separated String after Expansion
*/

static inline char *expand_middle(char *input, char *iter, char *last, t_rb *envmap)
static inline char *expand_middle(char *input, char *iter, char *last, \
t_rb *envmap)
{
char *key;
char *value;
Expand Down Expand Up @@ -175,4 +176,3 @@ char *expand_internal(char *input, char *iter, t_rb *envmap, bool d_quote)
jfree((void **)(&former));
return (input);
}

6 changes: 3 additions & 3 deletions circle-03/minishell/srcs/parse/tokenize.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/27 12:01:52 by jseo #+# #+# */
/* Updated: 2021/12/27 12:53:11 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:03:33 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -63,8 +63,8 @@ void tokenize(char *input, t_lst **chunks)
{
if (jstrchr("\'\"", *end))
end = jstrchr(end + 1, *end);
if (jstrchr("><|", *(end + 1)) ||
(*end != '\\' && *(end + 1) == ' '))
if (jstrchr("><|", *(end + 1))
|| (*end != '\\' && *(end + 1) == ' '))
break ;
++end;
}
Expand Down
4 changes: 2 additions & 2 deletions circle-03/minishell/srcs/rbtree/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/23 21:51:48 by jseo #+# #+# */
/* Updated: 2021/12/27 12:18:00 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:23:39 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -78,7 +78,7 @@ bool is_red(t_node *node)
** key_b - Key Second
*/

int compare(void *key_a, void *key_b)
int compare(void *key_a, void *key_b)
{
return (jstrncmp((char *)key_a, (char *)key_b, BUFFER_SIZE));
}
34 changes: 17 additions & 17 deletions circle-03/minishell/srcs/rbtree/delete_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/24 21:55:42 by jseo #+# #+# */
/* Updated: 2021/12/28 03:15:52 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:20:13 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -52,19 +52,19 @@ static inline void case_4(t_rb *tree, t_node *node)

static inline void case_3(t_rb *tree, t_node *node)
{
if (node == get_parent(node)->left &&
get_color(get_sibling(node)) == BLACK &&
get_color(get_sibling(node)->left) == RED &&
get_color(get_sibling(node)->right) == BLACK)
if (node == get_parent(node)->left
&& get_color(get_sibling(node)) == BLACK
&& get_color(get_sibling(node)->left) == RED
&& get_color(get_sibling(node)->right) == BLACK)
{
set_color(get_sibling(node), RED);
set_color(get_sibling(node)->left, BLACK);
right_rotate(tree, get_sibling(node));
}
else if (node == get_parent(node)->right &&
get_color(get_sibling(node)) == BLACK &&
get_color(get_sibling(node)->left) == BLACK &&
get_color(get_sibling(node)->right) == RED)
else if (node == get_parent(node)->right
&& get_color(get_sibling(node)) == BLACK
&& get_color(get_sibling(node)->left) == BLACK
&& get_color(get_sibling(node)->right) == RED)
{
set_color(get_sibling(node), RED);
set_color(get_sibling(node)->right, BLACK);
Expand All @@ -83,10 +83,10 @@ static inline void case_3(t_rb *tree, t_node *node)

static inline void case_2(t_rb *tree, t_node *node)
{
if (get_color(get_parent(node)) == RED &&
get_color(get_sibling(node)) == BLACK &&
get_color(get_sibling(node)->left) == BLACK &&
get_color(get_sibling(node)->right) == BLACK)
if (get_color(get_parent(node)) == RED
&& get_color(get_sibling(node)) == BLACK
&& get_color(get_sibling(node)->left) == BLACK
&& get_color(get_sibling(node)->right) == BLACK)
{
set_color(get_sibling(node), RED);
set_color(get_parent(node), BLACK);
Expand Down Expand Up @@ -116,10 +116,10 @@ static inline void case_1(t_rb *tree, t_node *node)
else
right_rotate(tree, get_parent(node));
}
if (get_color(get_parent(node)) == BLACK &&
get_color(get_sibling(node)) == BLACK &&
get_color(get_sibling(node)->left) == BLACK &&
get_color(get_sibling(node)->right) == BLACK)
if (get_color(get_parent(node)) == BLACK
&& get_color(get_sibling(node)) == BLACK
&& get_color(get_sibling(node)->left) == BLACK
&& get_color(get_sibling(node)->right) == BLACK)
{
set_color(get_sibling(node), RED);
case_1(tree, get_parent(node));
Expand Down
3 changes: 1 addition & 2 deletions circle-03/minishell/srcs/rbtree/insert_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/24 13:53:24 by jseo #+# #+# */
/* Updated: 2021/12/28 03:15:15 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:21:14 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -64,7 +64,6 @@ static inline void case_2(t_rb *tree, t_node **node, \
static inline void case_1(t_rb *tree, t_node **node, \
t_node **parent, t_node **grandparent)
{

t_node *uncle;

uncle = (*grandparent)->right;
Expand Down
4 changes: 2 additions & 2 deletions circle-03/minishell/srcs/rbtree/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/24 15:06:53 by jseo #+# #+# */
/* Updated: 2021/12/31 17:06:54 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:24:04 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -51,7 +51,7 @@ void rb_node(t_node *node, int level)
{
rb_node(node->right, level + 1);
padding('\t', level);
if(get_color(node) == BLACK)
if (get_color(node) == BLACK)
{
jputstr("(", STDOUT_FILENO);
jputstr((char *)(node->key), STDOUT_FILENO);
Expand Down
3 changes: 1 addition & 2 deletions circle-03/minishell/srcs/rbtree/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jseo <jseo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/24 10:45:11 by jseo #+# #+# */
/* Updated: 2021/12/28 14:14:39 by jseo ### ########.fr */
/* Updated: 2022/01/01 10:20:33 by hyson ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -45,7 +45,6 @@ t_node *get_node(t_rb *tree, void *key, t_node **parent)
else
current = current->right;
}

}
return (NULL);
}
Expand Down