From 149098f5ba7087e54884f564130d882431c1b972 Mon Sep 17 00:00:00 2001 From: qfeuilla Date: Sat, 25 Jul 2020 19:31:17 +0200 Subject: [PATCH] adding space preprocessing on envvar --- .../launch_commands/minishell_launch_utils.o | Bin 5936 -> 5376 bytes .../srcs/redirections/redirections_utils.o | Bin 3824 -> 4488 bytes working/srcs/token_expansion/get_env.c | 31 ++++++++++++++++-- working/srcs/token_expansion/get_env.o | Bin 3872 -> 4344 bytes 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/working/srcs/launch_commands/minishell_launch_utils.o b/working/srcs/launch_commands/minishell_launch_utils.o index 5e0efd3f9c386ca52647d7603c3b1688cb2ec0c2..939e96ddbaeeff08f68f972ed09907a561c192c4 100644 GIT binary patch delta 1388 zcmZ`(O=uHQ5ZY?IwJ{*ct4Hs&Cti18qrdh=jQ1jRx{sySFnQ%Wsb5fbp{ z;-$@a@{bloL@XGhMJR$uFBWSl_9#*ju@}KmC`By#=IvV?0~wfkdEb2B?CiX^dA`4t z8c(VvVuQA5XGDT@on6i(rX!FjZ%n6POHO-D~k(@Qj@yqqS;4F!_BI0)u zH$>D?%c3G~7cn8KwaaRos`Dt1taey%xX=PHVZl3W^bTXw_}TviLH3KACUWHk^Nei?UnmgsOWLS z)!dNiI%?7(`8L>-&E4&(TjHn+68toL(e2_0QEemHu?DJJ4e)XU{B8sMnS&PTs98`X4^<@4G8l&`szxY<3$A!;Z}mPMB~$ z!Z7Fjf+@p>CoS2S`=?Uk95n0^eGOQ|RyS4XhQ9aFUl`A{ze-8ETb} delta 1918 zcmZ{ke`p*<6vt;bcbEIsxVa16EJ|~!#$HlUqv*vSjV%&csihXI)Ka)^FBgnS?(AjN zRw`$~2-gs)edZ6X4J}xz66uxD;vfAZLaQK!Hh;7f3Y8Ru{!zhys`*2S@6FEOJ2Sg?b#>LP z-EeEa+{KWXo;rX+kN8uFO=7bU@9mUa?Pqsp6U8Ou)~0q*+H}y(JVOy(p&^KMX-%PF zwa$-$wryqDe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ri`z%lXKDJTrOSlw4&5hhUDCo z_>%niqQtb4)FQC4lb3U?tp5yVGBB_JX#pVq^B)58pr(VwMUliMn1CE00EvqOF-(0W z4)Iw?;u1*ek3qzvFbsNvL&Gm5aY-bD5}APJ6vIek91_qE( zAPfv5-up~RER(bN%(z}~Kx8*CPF}@l#H9){VIg{U< zX(h|#Mf`S5=b%dYHJC22OjZ)G +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/29 16:49:23 by frthierr #+# #+# */ -/* Updated: 2020/07/22 18:56:58 by qfeuilla ### ########.fr */ +/* Updated: 2020/07/25 19:30:58 by qfeuilla ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" +char *preprocess_env(char *env_val) +{ + char *preproc_env; + int i; + int j; + int prev_is_space; + + if (!env_val) + return (NULL); + i = -1; + j = 0; + prev_is_space = 0; + preproc_env = (char *)malloc(ft_strlen(env_val) * sizeof(char)); + while (env_val[++i]) + { + if (!(env_val[i] == ' ' && prev_is_space == 1)) + preproc_env[j++] = env_val[i]; + if (env_val[i] == ' ') + prev_is_space = 1; + else + prev_is_space = 0; + } + preproc_env[j] = '\0'; + free(env_val); + return (preproc_env); +} + char *get_env(char *key) { char *value; @@ -31,7 +58,7 @@ char *get_env(char *key) { if (!(value = ft_strdup(&g_env[i][ft_strlen(key) + 1]))) return (NULL); - return (value); + return (preprocess_env(value)); } i++; } diff --git a/working/srcs/token_expansion/get_env.o b/working/srcs/token_expansion/get_env.o index 85a2616dbff88893aaad76436bec64ca758e830c..a3532cad50cf1f870807fecddbd0d7d5075168b1 100644 GIT binary patch delta 1428 zcmZWpUr19?7(eH3bG!3il`XtVIgKo4PX>}mQcZ_<_D zJ?$1o<@kPA*b~XtdnQ8}Pb8Epd|w>+z+TAE!&_QFBeOC=%Mlfqk53N)lpfZmJVcp2=y^eR&UlRyvPwfa5;_5vpP+ zwQkkRN7O7XjEgP=qadoufm-@SL7Oo(|7t1Tx)(d*y)Ne)(2H4U|9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