エスケープ処理の実装
Closed this issue · 3 comments
kefujiwa commented
トークン解析後のエスケープ処理を実装する。
tkomatsu commented
export test=hello
echo \\$test
kefujiwa commented
上記エラー改修の影響範囲
parse_tokens.c
convert_quotes.c
convert_dquotes.c
convert_words.c
tkomatsu commented
char *convert_quotes(char *src);
char *convert_dquotes(char *src);
char *convert_words(char *src);
static char* strjoin_free(char **s1, char **s2)
{
// s1 + s2をs1に入れて、s1,s2をfree
}
char *parse_tokens(t_token *tokens)
{
int flag;
char *new;
char *str;
flag = 0;
new = ft_strdup("");
str = tokens->word;
while (*str)
{
if (*str == '\'' && !flag)
strcat_free(&new, &convert_quotes(str + 1));
else if (*str == '\"' && !flag)
strcat_free(&new, &convert_dquotes(str + 1));
else
strcat_free(&new, &convert_words(str));
if (!str)
return (NULL);
if (*str == '\\')
flag ^= ESC;
else
flag = 0;
}
ft_free(tokens->word);
return (new);
}