maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
loc_env_var_handler_heredoc_utils.c File Reference
#include "shell.h"
#include "tokens.h"
#include "redirection.h"
#include "execute.h"
#include <fcntl.h>
#include <sys/wait.h>
#include "signals.h"
Include dependency graph for loc_env_var_handler_heredoc_utils.c:

Go to the source code of this file.

Functions

char * token_adj (char *arg)
 

Function Documentation

◆ token_adj()

char * token_adj ( char *  arg)

Definition at line 21 of file loc_env_var_handler_heredoc_utils.c.

22{
23 char *ptr;
24 char *new_arg;
25
26 if (*arg == '\"')
27 {
28 ptr = arg + 1;
29 while (*ptr && *ptr != '\"')
30 {
31 if (!ft_isdigit(*ptr))
32 return (ft_strdup(arg));
33 ptr++;
34 }
35 if (*ptr == '\0')
36 {
37 new_arg = malloc(ft_strlen(arg) + 2);
38 if (!new_arg)
39 return (NULL);
40 ft_strcpy(new_arg, arg);
41 ft_strcat(new_arg, "\"");
42 return (new_arg);
43 }
44 if (*ptr == '\"' && *(ptr + 1) == '\0')
45 return (ft_strdup(arg));
46 }
47 return (ft_strdup(arg));
48}
int ft_isdigit(int c)
Definition ft_isdigit.c:13
char * ft_strcpy(char *dest, const char *src)
Definition ft_strcpy.c:25
size_t ft_strlen(const char *s)
Definition ft_strlen.c:15
char * ft_strcat(char *dest, char *src)
Definition ft_strcat.c:26
char * ft_strdup(const char *s)
Definition ft_strdup.c:23

References ft_isdigit(), ft_strcat(), ft_strcpy(), ft_strdup(), and ft_strlen().

Referenced by finalize_token().

Here is the call graph for this function:
Here is the caller graph for this function: