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

✏️」 norm: Normed everything and leak erased from the surface of the earth and what the fuck am i doing at this hour coding i shoud be sleeping 1:30am wtf god damn please give me a bed and fuck you yosyo 🖕

This commit is contained in:
2024-07-10 01:22:28 +02:00
parent b1f77b386a
commit 54e01e9bc3
19 changed files with 359 additions and 220 deletions

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/03 10:50:52 by mmoussou #+# #+# */
/* Updated: 2024/07/06 17:47:53 by mmoussou ### ########.fr */
/* Updated: 2024/07/09 21:21:16 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,44 +14,12 @@
char *format_quotes_string(char *cmd)
{
uint i;
uint i_offset;
i = 0;
i_offset = 0;
while (cmd[i])
{
if (cmd[i] == SINGLE)
{
i_offset++;
i++;
while (cmd[i] && cmd[i] != SINGLE)
{
cmd[i - i_offset] = cmd[i];
i++;
}
i_offset++;
}
else if (cmd[i] == DOUBLE)
{
i_offset++;
i++;
while (cmd[i] && cmd[i] != DOUBLE)
{
cmd[i - i_offset] = cmd[i];
i++;
}
i_offset++;
}
else
cmd[i - i_offset] = cmd[i];
i++;
}
cmd[i - i_offset] = 0;
if (*cmd == DOUBLE || *cmd == SINGLE)
ft_strlcpy(cmd, cmd + 1, ft_strlen(cmd) - 1);
return (cmd);
}
int format_quotes_cmd(t_cmd *cmd)
int format_quotes_cmd(t_cmd *cmd, t_env *env)
{
uint i;
@ -59,19 +27,20 @@ int format_quotes_cmd(t_cmd *cmd)
i = 0;
while (cmd->argv[i])
{
format_quotes_string(cmd->argv[i]);
cmd->argv[i] = format_quotes_string(cmd->argv[i]);
cmd->argv[i] = env_var_replace(cmd->argv[i], env);
i++;
}
return (0);
}
int format_quotes(t_list *list_cmd)
int format_quotes(t_list *list_cmd, t_env *env)
{
if (!list_cmd)
return (0);
while (list_cmd)
{
format_quotes_cmd(list_cmd->content);
format_quotes_cmd(list_cmd->content, env);
list_cmd = list_cmd->next;
}
return (0);