aboutsummaryrefslogtreecommitdiff
path: root/test_mini/lexer_utils.c
diff options
context:
space:
mode:
authornass1pro <nass1pro@gmail.com>2020-06-10 18:02:58 +0200
committernass1pro <nass1pro@gmail.com>2020-06-13 11:34:45 +0200
commitc4c60ea0f74fc593b0181e1fc8c71c27f0497180 (patch)
treeb07464986ba6a80542c2409a1271c4a9da87a0f4 /test_mini/lexer_utils.c
parent579a26f5593039ffbbd1a81e45ecf0ef8797cb5d (diff)
downloadminishell-c4c60ea0f74fc593b0181e1fc8c71c27f0497180.tar.gz
minishell-c4c60ea0f74fc593b0181e1fc8c71c27f0497180.tar.bz2
minishell-c4c60ea0f74fc593b0181e1fc8c71c27f0497180.zip
Fixing quote detection
Create token list
Diffstat (limited to 'test_mini/lexer_utils.c')
-rw-r--r--test_mini/lexer_utils.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/test_mini/lexer_utils.c b/test_mini/lexer_utils.c
index 35050b3..d7fe8f4 100644
--- a/test_mini/lexer_utils.c
+++ b/test_mini/lexer_utils.c
@@ -56,26 +56,33 @@ int lexe_space(char *input)
return(i);
}
-int simple_cote(char *input, int i)
+static int lex_verif_simple_cote(char *input, int i)
{
- int cote;
-
- cote = 39;
- if (cote == input[i])
- return (1);
- return(0);
+ i++;
+ while(input[i] != '\0')
+ {
+ ++i;
+ if(input[i] == '\'')
+ break;
+ }
+ if (input[i + 1] == ' ')
+ while(input[i] == ' ')
+ i++;
+ return(i + 1);
}
-
-
int lexer_verif_entre_cote(char *input, int i)
{
- while((input[++i] != '"' || simple_cote(input,i)) && (input[i] != '\0'))
- ;
- //i++;
- //if(input[i] == '"' || simple_cote(input,i))
- // return(lexer_verif_entre_cote(input, i));
- //if (input[i] == ' ')
- // while(input[i] == ' ')
- // i++;
- return(i);
+ if(input[i] == '\'')
+ return(lex_verif_simple_cote(input, i));
+ i++;
+ while(input[i] != '"' && (input[i] != '\0'))
+ {
+ ++i;
+ if (input[i] == '\'')
+ break;
+ }
+ if (input[i + 1] == ' ')
+ while(input[i] == ' ')
+ i++;
+ return(i + 1);
}