diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-06 18:14:26 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-06 18:14:26 +0200 |
commit | 92f7b8562ddc1e8d0484f7ec212a12e3019a24a5 (patch) | |
tree | f0bc924baaa5d090f919b8d2fe0d0a887bdfee02 | |
parent | Better defines (diff) | |
download | 42-minishell-92f7b8562ddc1e8d0484f7ec212a12e3019a24a5.tar.gz 42-minishell-92f7b8562ddc1e8d0484f7ec212a12e3019a24a5.tar.bz2 42-minishell-92f7b8562ddc1e8d0484f7ec212a12e3019a24a5.tar.xz 42-minishell-92f7b8562ddc1e8d0484f7ec212a12e3019a24a5.tar.zst 42-minishell-92f7b8562ddc1e8d0484f7ec212a12e3019a24a5.zip |
Gitignore update
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | src/p_args.c | 39 | ||||
-rw-r--r-- | src/p_args_escape.c | 15 |
3 files changed, 36 insertions, 22 deletions
@@ -129,4 +129,6 @@ vgcore* qwe *.sh noread -.clang_complete
\ No newline at end of file +.clang_complete +/bash +/mini diff --git a/src/p_args.c b/src/p_args.c index 7d5a579..7f5302f 100644 --- a/src/p_args.c +++ b/src/p_args.c @@ -24,23 +24,36 @@ /* TODO: DELETE THIS */ /* ================= */ +/* static void */ +/* p_print(char *words[]) */ +/* { */ +/* char **ptr; */ + +/* ptr = words; */ +/* while (*ptr != NULL) */ +/* { */ +/* ft_printf("[%s]\n", *ptr); */ +/* ptr++; */ +/* } */ +/* } */ + +/* ================== */ +/* TODO: DELETE ABOVE */ +/* ================== */ + static void -p_print(char *words[]) + p_meet_bs(char *ptr, t_quote_mode mode) { - char **ptr; - - ptr = words; - while (*ptr != NULL) + if (mode != Q_SINGLE) { - ft_printf("[%s]\n", *ptr); - ptr++; + if (*(ptr + 1) == C_BACKS) + { + *ptr = C_SUB; + *(ptr + 1) = C_SUB; + } } } -/* ================== */ -/* TODO: DELETE ABOVE */ -/* ================== */ - static t_quote_mode p_meet_dquote(char *head, char *ptr, t_quote_mode mode) { @@ -116,6 +129,7 @@ static uint16_t while (*ptr != C_NUL) { if (*ptr == C_BACKS) + p_meet_bs(ptr, mode); if (*ptr == C_DQUOTE) mode = p_meet_dquote((char*)word, ptr, mode); else if (*ptr == C_SQUOTE) @@ -143,7 +157,6 @@ static char uint16_t to_del; argc = p_count_args(word, start); - ft_printf("argc: %hu\n", argc); if ((words = (char**)malloc((argc + 1) * sizeof(char*))) == NULL) return (NULL); words[argc] = NULL; @@ -153,7 +166,6 @@ static char return (NULL); } p_args_escape_chars_and_quotes(words); - p_print(words); return (words); } @@ -163,7 +175,6 @@ char char **words; words = NULL; - ft_printf("word at start: [%s]\n", word); if (redir == 0) { if ((words = p_split_words_no_rdr(word)) == NULL) diff --git a/src/p_args_escape.c b/src/p_args_escape.c index ae96bb0..834d9f7 100644 --- a/src/p_args_escape.c +++ b/src/p_args_escape.c @@ -77,11 +77,6 @@ static void { (void)ft_memmove(word + (ptr - word), ptr + 1, (ft_strlen(ptr + 1) + 1) * sizeof(char)); - if (*ptr == C_BACKS) - { - *(word + (ptr - word)) = 26; - ft_printf("%s\n", word); - } *(p) -= 1; } else if (mode == Q_DOUBLE) @@ -90,7 +85,6 @@ static void { (void)ft_memmove(word + (ptr - word), ptr + 1, (ft_strlen(ptr + 1) + 1) * sizeof(char)); - *(word + (ptr - word)) = 26; *(p) -= 1; } else if (*(ptr + 1) == C_DQUOTE) @@ -125,10 +119,17 @@ static void static void p_replace_bs(char *ptr) { + char *head; + + head = ptr; while (*ptr != C_NUL) { - if (*ptr == 26) + if (*ptr == C_SUB && *(ptr + 1) == C_SUB) + { + (void)ft_memmove(head + (ptr - head), ptr + 1, + (ft_strlen(ptr + 1) + 1) * sizeof(char)); *ptr = C_BACKS; + } ptr++; } } |