Add the actual split to fields
authorLukas Jiriste <ljiriste@student.42prague.com>
Sun, 21 Jul 2024 17:56:18 +0000 (19:56 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Sun, 21 Jul 2024 18:00:27 +0000 (20:00 +0200)
I forgot to implement it 2 commits back and compiler does not warn
because the vec is void pointer.

src/execution.c

index 118b0709fa1b7ba284c886cfed277b03f511a349..f3a95dc6cc251d8227aa0cb33fc4e3d9f7c461bc 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <ljiriste@student.42prague.com>   +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/07/21 08:57:54 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/07/21 19:47:22 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/07/21 20:00:06 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -410,9 +410,12 @@ int        expand_cmd(t_vec *exp_str, const t_parse_tree_node *node, const t_execution_
        return (0);
 }
 
+static const char      null_char = '\0';
+
 char   **expand(t_parse_tree_node *simple_command, const t_execution_env *env)
 {
        size_t                          i;
+       char                            **res;
        t_vec                           expanded_str;
        t_parse_tree_node       *subnode;
 
@@ -432,7 +435,19 @@ char       **expand(t_parse_tree_node *simple_command, const t_execution_env *env)
                        }
                ++i;
        }
-       return (expanded_str.vec);
+       if (ft_vec_append(&expanded_str, &null_char) != success)
+       {
+               ft_vec_free(&expanded_str, NULL);
+               return (NULL);
+       }
+       res = ft_split(expanded_str.vec, ' ');
+       ft_vec_free(&expanded_str, NULL);
+       return (res);
+}
+
+int    assignments_to_env(const t_vec *assignments, t_execution_env *env)
+{
+
 }
 
 int    ex_simple_command(t_parse_tree_node *simple_command, t_execution_env *env)