28 lines
415 B
C
28 lines
415 B
C
|
#include "utils.h"
|
||
|
|
||
|
char *ft_getstr(char *str, size_t n)
|
||
|
{
|
||
|
size_t start;
|
||
|
size_t stop;
|
||
|
char c;
|
||
|
int quote;
|
||
|
|
||
|
start = n;
|
||
|
stop = n;
|
||
|
quote = ft_is_in_quote(str, n);
|
||
|
if (quote == 0)
|
||
|
c = ' ';
|
||
|
else
|
||
|
{
|
||
|
if (quote == 1)
|
||
|
c = '\'';
|
||
|
else
|
||
|
c = '"';
|
||
|
}
|
||
|
while (str[start - 1] != c && start > 0)
|
||
|
start--;
|
||
|
while (str[stop] != c && str[stop] != '\0')
|
||
|
stop++;
|
||
|
return (ft_strndup(str + start, stop - start));
|
||
|
}
|