diff options
Diffstat (limited to 'src/lexer/trim.c')
| -rw-r--r-- | src/lexer/trim.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/lexer/trim.c b/src/lexer/trim.c index 9fbb6cc..0f2cde1 100644 --- a/src/lexer/trim.c +++ b/src/lexer/trim.c @@ -1,7 +1,60 @@ #include "lexer.h" +char *del_space(char *str) +{ + int i; + char *s; + + i = 0; + while(str[++i] != '\0') + { + if(str[i] == '\\' && str[i + 1] == ' ') + i += 2; + if(str[i] == ' ') + break; + } + s = ft_strsubf(str, 0, i); + return(s); +} + +char *del_quote(char *str) +{ + int i; + char *s; + + i = 1; + while(str[++i] != '\0') + if (str[i] == '\'' || str[i] == '"') + break; + s = ft_strsubf(str, 1, i - 1); + return (s); +} + t_ftlst *lexe_trim_out(t_ftlst *lst) { - return (lst); + t_ftlst *first; + t_token *tk; + + first = lst; + while(lst != NULL) + { + tk = lst->data; + if (tk->tag >= TAG_STR_DOUBLE || tk->tag >= TAG_STR_SINGLE) + { + tk->content = del_quote(tk->content); + if(lst->next == NULL) + if (tk->tag & TAG_STICK) + tk->tag -= TAG_STICK; + } + else + { + tk->content = del_space(tk->content); + if(lst->next == NULL) + if (tk->tag & TAG_STICK) + tk->tag -= TAG_STICK; + } + lst = lst->next; + } + return (first); } |
