1
0
mirror of https://github.com/KeyZox71/ft_minipowershell.git synced 2025-05-13 16:08:45 +02:00

🔨」 fix: quote fixed

This commit is contained in:
2024-07-15 14:27:43 +02:00
parent 27ac717f67
commit 17bb4ce14e
4 changed files with 51 additions and 14 deletions

View File

@ -6,21 +6,57 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/03 10:50:52 by mmoussou #+# #+# */
/* Updated: 2024/07/14 17:39:18 by adjoly ### ########.fr */
/* Updated: 2024/07/15 14:25:01 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
size_t __get_size_in_quote(char *cmd)
{
char *tmp;
tmp = search_for_next_quote(cmd + 1, __is_quote(*cmd));
return (tmp - cmd);
}
char *format_quotes_string(char *cmd)
{
size_t inquote;
char *tmp;
char *ret;
if (!cmd)
return (NULL);
if (*cmd == DOUBLE || *cmd == SINGLE)
ft_strlcpy(cmd, cmd + 1, ft_strlen(cmd) - 1);
return (cmd);
tmp = cmd;
ret = ft_calloc(ft_strlen(cmd) + 1, sizeof(char));
while (*tmp)
{
if (*tmp == DOUBLE || *tmp == SINGLE)
{
inquote = __get_size_in_quote(tmp);
ft_strlcat(ret, tmp + 1, ft_strlen(ret) + inquote);
tmp += inquote;
}
else
{
ft_strlcat(ret, tmp, ft_strlen(ret) + 2);
tmp++;
}
}
free(cmd);
return (ret);
}
//char *format_quotes_string(char *cmd)
//{
// if (!cmd)
// return (NULL);
// if (*cmd == DOUBLE || *cmd == SINGLE)
// ft_strlcpy(cmd, cmd + 1, ft_strlen(cmd) - 1);
// return (cmd);
//}
int format_quotes_cmd(t_cmd *cmd)
{
uint i;