aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornass1pro <nass1pro@gmail.com>2020-09-10 05:15:43 +0200
committernass1pro <nass1pro@gmail.com>2020-09-10 05:15:43 +0200
commitb6c235dd776ef8c873be1bb0d578dfa58d92f264 (patch)
tree869f32c808aae019d3c8bc8dca6814abaa45c5f6 /src
parentc8c72449733f064f86b8a7c0b1284b6196fff0e3 (diff)
downloadminishell-b6c235dd776ef8c873be1bb0d578dfa58d92f264.tar.gz
minishell-b6c235dd776ef8c873be1bb0d578dfa58d92f264.tar.bz2
minishell-b6c235dd776ef8c873be1bb0d578dfa58d92f264.zip
update escape
Diffstat (limited to 'src')
-rw-r--r--src/lexer/lexer.c14
-rw-r--r--src/lexer/trim.c24
2 files changed, 22 insertions, 16 deletions
diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c
index 3c7328e..60e77a3 100644
--- a/src/lexer/lexer.c
+++ b/src/lexer/lexer.c
@@ -6,11 +6,12 @@
/* By: nahaddac <nahaddac@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/16 08:18:25 by nahaddac #+# #+# */
-/* Updated: 2020/08/28 10:43:42 by charles ### ########.fr */
+/* Updated: 2020/09/10 05:06:11 by nahaddac ### ########.fr */
/* */
/* ************************************************************************** */
#include "lexer.h"
+#include <stdio.h>
int len_until_sep(char *input)
{
@@ -24,6 +25,8 @@ int len_until_sep(char *input)
i +=2;
if (input[i] == '\\')
i += len_until_sep(&input[i]);
+ i += lexer_space(&input[i]);
+ return i;
}
if (lexer_sep(input[i]))
return(i);
@@ -47,7 +50,10 @@ int check_input(char *input)
i = 0;
op = 1;
if (input[i] == '\\' && lexer_sep(input[i + 1]))
+ {
i += 2;
+ return (i + lexer_space(&input[i]));
+ }
if (input[i] == '(' || input[i] == ')')
{
i +=1;
@@ -58,12 +64,8 @@ int check_input(char *input)
}
if (lexer_sep(input[i]))
{
- /* src/lexer/lexer.c:62:12: warning: Although the value stored to 'i' is used in the enclosing expression, the value is never actually read from 'i' */
- /* return (i += lexer_space(&input[i + 1]) + 1); */
- /* ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
if (input[i] == ';')
- return (i += lexer_space(&input[i + 1]) + 1);
+ return (i + lexer_space(&input[i + 1]) + 1);
while(input[i] == input[i + 1] && op < 2)
{
i++;
diff --git a/src/lexer/trim.c b/src/lexer/trim.c
index 2cce38c..ebfb764 100644
--- a/src/lexer/trim.c
+++ b/src/lexer/trim.c
@@ -6,7 +6,7 @@
/* By: nahaddac <nahaddac@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/16 08:18:36 by nahaddac #+# #+# */
-/* Updated: 2020/08/27 17:30:11 by charles ### ########.fr */
+/* Updated: 2020/09/10 04:39:08 by nahaddac ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,18 +15,22 @@
char *del_space(t_tok_lst *tok)
{
- int i;
+ int i;
- i = 0;
- while (tok->content[i] != '\0')
+ i = ft_strlen(tok->content);
+ if(tok->content[i - 1] == ' ')
{
- if (tok->content[i] == '\\')
- return (tok->content);
- if (tok->content[i] == ' ')
- break ;
- i++;
+ i -= 1;
+ while(tok->content[i] == ' ')
+ {
+ if (tok->content[i - 1] == '\\')
+ break;
+ i--;
+ }
+ tok->content = ft_strsubf(tok->content, 0, i + 1);
+ return (tok->content);
}
- return (ft_strsubf(tok->content, 0, i));
+ return(tok->content);
}
char *del_quote(char *str)