MiniDevil
As beautiful as a shell
Expansion utilities: identifies variables & handles special patterns. More...
Include dependency graph for expander_utils.c:Expansion utilities: identifies variables & handles special patterns.
Definition in file expander_utils.c.
Functions | |
| int | is_dollar_quote (t_token *token) |
Check if a token is a $ connected to a quoted token. More... | |
| int | is_var_char (char c) |
| Check if a character is valid in a variable name. More... | |
| char * | extract_var_name (char *str, int *len) |
Extract a variable name from after the $ More... | |
| char * | append_char (char *str, char c) |
| Append a single character to an allocated string. More... | |
| char * | append_str (char *s1, char *s2) |
| Concatenates 2 strings and frees the first. More... | |
| int is_dollar_quote | ( | t_token * | token | ) |
Check if a token is a $ connected to a quoted token.
Detects the pattern: $"TOKEN_WORD" or $'TOKEN_WORD' + connected + next has quotes
| token | Token to inspect |
Definition at line 25 of file expander_utils.c.
References t_token::connected, t_token::next, QUOTE_NONE, and t_token::value.
Referenced by expand_all_tokens().
Here is the caller graph for this function:| int is_var_char | ( | char | c | ) |
Check if a character is valid in a variable name.
| c | Character to check |
_ and 0 otherwise Definition at line 40 of file expander_utils.c.
Referenced by extract_var_name(), and handle_dollar_sign().
Here is the caller graph for this function:| char* extract_var_name | ( | char * | str, |
| int * | len | ||
| ) |
Extract a variable name from after the $
If the first char is a digit, it returns the only digit (matching BASH). Otherwise it scans for valid variable characters (alphanumeric and _)
| str | String starting after $ |
| len | Number of characters consumed |
Definition at line 55 of file expander_utils.c.
References is_var_char().
Referenced by process_dollar().
Here is the call graph for this function:
Here is the caller graph for this function:| char* append_char | ( | char * | str, |
| char | c | ||
| ) |
Append a single character to an allocated string.
| str | Original string |
| c | Character to append |
Definition at line 79 of file expander_utils.c.
Referenced by expand_variables(), handle_dollar_sign(), and process_dollar().
Here is the caller graph for this function:| char* append_str | ( | char * | s1, |
| char * | s2 | ||
| ) |
Concatenates 2 strings and frees the first.
If s2 is NULL it returns s1 unchanged
| s1 | First string |
| s2 | Second string |
Definition at line 113 of file expander_utils.c.
Referenced by get_append_value(), handle_special_var(), and process_dollar().
Here is the caller graph for this function: