-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from Haliris/dollar_string_fixes
Dollar string fixes
- Loading branch information
Showing
10 changed files
with
70 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: bthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/06/27 19:30:56 by bthomas #+# #+# */ | ||
/* Updated: 2024/07/29 10:24:37 by bthomas ### ########.fr */ | ||
/* Updated: 2024/07/30 13:21:30 by bthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -15,6 +15,8 @@ | |
|
||
# include "minishell.h" | ||
|
||
# define DOLLAR_LITERAL ";:/,.~^=+-@*" | ||
|
||
typedef struct s_data t_data; | ||
typedef enum e_tokentype | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: bthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/07/12 20:32:33 by bthomas #+# #+# */ | ||
/* Updated: 2024/07/29 16:02:44 by bthomas ### ########.fr */ | ||
/* Updated: 2024/07/30 13:27:36 by bthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -70,10 +70,13 @@ static char *get_export_val(t_data *data, char *key, char **cmd, int cmd_len) | |
i = 0; | ||
while (ret[i]) | ||
{ | ||
if (invalid_path_char(ret[i])) | ||
if (!is_space(ret[i]) && !ft_isalnum(ret[i])) | ||
{ | ||
free(ret); | ||
return (NULL); | ||
if (!in(ret[i], DOLLAR_LITERAL)) | ||
{ | ||
free(ret); | ||
return (NULL); | ||
} | ||
} | ||
i++; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: bthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/07/20 12:36:56 by bthomas #+# #+# */ | ||
/* Updated: 2024/07/29 14:12:46 by bthomas ### ########.fr */ | ||
/* Updated: 2024/07/30 11:34:21 by bthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -43,8 +43,7 @@ static bool space_before_last_equals(char *input, size_t idx) | |
{ | ||
while (input[idx] != '=') | ||
idx--; | ||
idx--; | ||
if (is_space(input[idx - 1])) | ||
if (is_space(input[idx - 1]) || is_space(input[idx + 1])) | ||
return (true); | ||
return (false); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: bthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/07/28 16:23:45 by bthomas #+# #+# */ | ||
/* Updated: 2024/07/29 12:17:02 by bthomas ### ########.fr */ | ||
/* Updated: 2024/07/30 12:44:05 by bthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -65,6 +65,9 @@ static void change_start_idx(t_data *data, t_token **token) | |
quote = 0; | ||
while ((*token)->startidx > 1) | ||
{ | ||
if (in(data->input[(*token)->startidx], "\'\"") | ||
&& data->input[(*token)->startidx - 1] == '$') | ||
(*token)->startidx -= 1; | ||
if (in(data->input[(*token)->startidx - 1], "\'\"")) | ||
quote = data->input[(*token)->startidx - 1]; | ||
if (data->input[(*token)->startidx - 2] == quote) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: bthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/07/19 10:41:19 by bthomas #+# #+# */ | ||
/* Updated: 2024/07/28 15:36:48 by bthomas ### ########.fr */ | ||
/* Updated: 2024/07/30 13:21:41 by bthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -20,7 +20,7 @@ char *extract_key_from_str(char *str, size_t start) | |
return (ft_strdup("$")); | ||
end = start + 1; | ||
while (str[end] && (!is_delim(str[end], false) | ||
&& !in(str[end], ";:/,.~^="))) | ||
&& !in(str[end], DOLLAR_LITERAL))) | ||
end++; | ||
if (end == start + 1) | ||
return (NULL); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,21 +6,26 @@ | |
/* By: bthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/07/25 10:40:12 by bthomas #+# #+# */ | ||
/* Updated: 2024/07/29 14:44:11 by bthomas ### ########.fr */ | ||
/* Updated: 2024/07/30 12:41:11 by bthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "lexer.h" | ||
|
||
t_token *get_doll_str_tk(t_data *data, char *input, size_t *start_idx) | ||
{ | ||
t_token *doll_tk; | ||
char *outstr; | ||
|
||
outstr = ft_substr(input, *start_idx, 2); | ||
(*start_idx) += 2; | ||
if (!outstr) | ||
return (NULL); | ||
return (get_token(data, outstr, NULL, TK_STRING)); | ||
doll_tk = get_token(data, outstr, NULL, TK_STRING); | ||
if (!doll_tk) | ||
return (NULL); | ||
doll_tk->startidx = *start_idx; | ||
(*start_idx) += 2; | ||
return (doll_tk); | ||
} | ||
|
||
static size_t get_word_len(t_data *data, size_t startidx, bool echo_str) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: bthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/06/28 17:48:06 by bento #+# #+# */ | ||
/* Updated: 2024/07/29 14:56:01 by bthomas ### ########.fr */ | ||
/* Updated: 2024/07/30 13:22:05 by bthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -33,8 +33,8 @@ static void skip_invalid_chars(t_data *data, size_t input_len, size_t *i) | |
&& !in(input[(*i) + 1], "$?") | ||
&& !is_space(input[(*i) + 1]) | ||
&& (!ft_isalpha(input[(*i) + 1]) | ||
&& !in(input[(*i) + 1], ":/,.~^=_"))) | ||
(*i) += 1 + (1 * (!in(input[(*i) + 1], "\"\'"))); | ||
&& !in(input[(*i) + 1], DOLLAR_LITERAL))) | ||
(*i) += 1 + (1 * ft_isdigit(input[*i + 1])); | ||
else | ||
return ; | ||
} | ||
|
@@ -50,7 +50,7 @@ static t_token *build_tokenlist2(t_data *data, size_t *i) | |
else if (data->input[*i] == '=') | ||
curr_tk = get_token(data, ft_strdup("="), NULL, TK_OPERATOR); | ||
else if (data->input[*i] == '$' && data->input[(*i) + 1] | ||
&& in(data->input[(*i) + 1], ":/,.~^=")) | ||
&& in(data->input[(*i) + 1], DOLLAR_LITERAL)) | ||
return (get_doll_str_tk(data, data->input, i)); | ||
else if (data->input[*i] == '$' | ||
&& (!data->input[*i + 1] || is_space(data->input[*i + 1]))) | ||
|
@@ -74,7 +74,7 @@ static int build_tokenlist1(t_data *data, size_t input_len) | |
while (i < input_len) | ||
{ | ||
if (is_invalid_export(data, i)) | ||
return (PANIC); | ||
return (1); | ||
skip_invalid_chars(data, input_len, &i); | ||
if (i >= input_len) | ||
break ; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters