aboutsummaryrefslogtreecommitdiff
path: root/src/lexer/token.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-06-23 09:09:17 +0200
committerCharles <sircharlesaze@gmail.com>2020-06-23 10:31:27 +0200
commit11b258841f4a15c514c49af7d378b51cd6a8ab79 (patch)
tree0df3f625f49fc1a8ca0e74f81272120f07a35feb /src/lexer/token.c
parent58fc321ec43be4c3f7976769733116232361857a (diff)
downloadminishell-11b258841f4a15c514c49af7d378b51cd6a8ab79.tar.gz
minishell-11b258841f4a15c514c49af7d378b51cd6a8ab79.tar.bz2
minishell-11b258841f4a15c514c49af7d378b51cd6a8ab79.zip
Fixing builtin which needed to not be run in a child process, Added exit builtin
Diffstat (limited to 'src/lexer/token.c')
-rw-r--r--src/lexer/token.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lexer/token.c b/src/lexer/token.c
index 966a443..5465b6b 100644
--- a/src/lexer/token.c
+++ b/src/lexer/token.c
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/09 13:38:08 by charles #+# #+# */
-/* Updated: 2020/06/15 11:38:24 by charles ### ########.fr */
+/* Updated: 2020/06/23 08:55:32 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,13 +14,22 @@
t_token *token_new(enum e_token_tag tag, char *content)
{
+ size_t len;
+
+ if (content != NULL)
+ len = ft_strlen(content);
+ return (token_new_until(tag, content, len));
+}
+
+t_token *token_new_until(enum e_token_tag tag, char *content, int n)
+{
t_token *token;
if ((token = (t_token*)malloc(sizeof(t_token))) == NULL)
return (NULL);
if (content == NULL)
token->content = NULL;
- else if ((token->content = ft_strdup(content)) == NULL)
+ else if ((token->content = ft_strndup(content, n)) == NULL)
{
free(token);
return (NULL);