fix bugs completion...
This commit is contained in:
parent
316194d860
commit
580c5e3ec3
5 changed files with 24 additions and 40 deletions
|
|
@ -6,14 +6,14 @@
|
||||||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||||
# Updated: 2017/03/21 17:18:57 by ariard ### ########.fr #
|
# Updated: 2017/03/22 14:59:33 by gwojda ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
NAME = 42sh
|
NAME = 42sh
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
FLAGS = -Wall -Wextra -Werror -fvisibility=hidden #-fsanitize=address
|
FLAGS = -Wall -Wextra -Werror #-fvisibility=hidden# -fsanitize=address
|
||||||
D_FLAGS = -g
|
D_FLAGS = -g
|
||||||
|
|
||||||
DELTA = $$(echo "$$(tput cols)-47"|bc)
|
DELTA = $$(echo "$$(tput cols)-47"|bc)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/09 16:54:59 by gwojda #+# #+# */
|
/* Created: 2017/03/09 16:54:59 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/21 14:47:18 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 15:14:41 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ void c_seek_abs_path(t_comp *c, char *current_word)
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = ft_strrchr(c->rcmd, '/') - current_word + 1;
|
len = ft_strrchr(current_word, '/') - current_word + 1;
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return ;
|
return ;
|
||||||
if (c->cpath)
|
if (c->cpath)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/09 11:21:16 by alao #+# #+# */
|
/* Created: 2017/01/09 11:21:16 by alao #+# #+# */
|
||||||
/* Updated: 2017/03/22 14:21:51 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 15:12:03 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -36,6 +36,8 @@ static char *c_trimmer(char *cmd, int st, int nd)
|
||||||
rt = ft_strsub(cmd, st, nd - st);
|
rt = ft_strsub(cmd, st, nd - st);
|
||||||
data_singleton()->comp->cutpoint = st;
|
data_singleton()->comp->cutpoint = st;
|
||||||
st = 0;
|
st = 0;
|
||||||
|
while (rt[st] == ' ')
|
||||||
|
st++;
|
||||||
tmp = ft_strsub(rt, st, ft_strlen(rt) - st);
|
tmp = ft_strsub(rt, st, ft_strlen(rt) - st);
|
||||||
if (st)
|
if (st)
|
||||||
data_singleton()->comp->between = ft_strsub(rt, 0, st);
|
data_singleton()->comp->between = ft_strsub(rt, 0, st);
|
||||||
|
|
|
||||||
|
|
@ -6,36 +6,12 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
|
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
|
||||||
/* Updated: 2017/03/22 14:21:45 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 15:13:12 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
/*
|
|
||||||
** Failsafe by checking if the nearby char are not a < or > for aggregation.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
static int c_chevron(t_comp *c)
|
|
||||||
{
|
|
||||||
size_t pos;
|
|
||||||
size_t input_len;
|
|
||||||
|
|
||||||
pos = c->ircmd;
|
|
||||||
input_len = ft_strlen(data_singleton()->line.input);
|
|
||||||
if (pos >= ft_strlen(c->rcmd))
|
|
||||||
pos = ft_strlen(c->rcmd) - (input_len - pos);
|
|
||||||
while (pos)
|
|
||||||
{
|
|
||||||
if (c->rcmd[pos] == '<' || c->rcmd[pos] == '>')
|
|
||||||
return (1);
|
|
||||||
--pos;
|
|
||||||
}
|
|
||||||
if (c->rcmd[pos] == '<' || c->rcmd[pos] == '>')
|
|
||||||
return (1);
|
|
||||||
return (0);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Seek the current word.
|
** Seek the current word.
|
||||||
*/
|
*/
|
||||||
|
|
@ -43,15 +19,20 @@ static int c_chevron(t_comp *c)
|
||||||
static char *c_current_words(t_comp *c)
|
static char *c_current_words(t_comp *c)
|
||||||
{
|
{
|
||||||
size_t pos;
|
size_t pos;
|
||||||
|
char *str;
|
||||||
|
|
||||||
pos = c->ircmd;
|
(void)c;
|
||||||
while (pos && c->rcmd[pos] != ' ' && c->rcmd[pos] != '<'
|
pos = data_singleton()->line.pos;
|
||||||
&& c->rcmd[pos] != '>' && c->rcmd[pos] != '\n')
|
str = data_singleton()->line.input;
|
||||||
|
DG("pos = \"%zu\"", pos);
|
||||||
|
while (pos && str[pos] != ' ' && str[pos] != '<'
|
||||||
|
&& str[pos] != '>' && str[pos] != '\n' && str[pos] != ';')
|
||||||
--pos;
|
--pos;
|
||||||
if (c->rcmd[pos] == ' ' || c->rcmd[pos] == '<'
|
if (str[pos] == ' ' || str[pos] == '<'
|
||||||
|| c->rcmd[pos] == '>' || c->rcmd[pos] == '\n')
|
|| str[pos] == '>' || str[pos] == '\n' || str[pos] == ';')
|
||||||
++pos;
|
++pos;
|
||||||
return (c->rcmd + pos);
|
DG("pos = \"%zu\"", pos);
|
||||||
|
return (str + pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -62,13 +43,14 @@ int c_matching(t_data *s, t_comp *c)
|
||||||
{
|
{
|
||||||
char *current_word;
|
char *current_word;
|
||||||
|
|
||||||
|
DG("c->rcmd = \"%s\"", c->rcmd);
|
||||||
current_word = c_current_words(c);
|
current_word = c_current_words(c);
|
||||||
|
DG("current_word = \"%s\"", current_word);
|
||||||
if (ft_strchr(c->rcmd, '/'))
|
if (ft_strchr(c->rcmd, '/'))
|
||||||
c_seek_abs_path(c, current_word);
|
c_seek_abs_path(c, current_word);
|
||||||
else if (ft_strchr(c->rcmd, '$'))
|
else if (ft_strchr(c->rcmd, '$'))
|
||||||
c_seek_env(c, current_word);
|
c_seek_env(c, current_word);
|
||||||
else if (c->rcmd[0] != '.' && !(ft_strchr(c->rcmd, ' ')))
|
else if (c->rcmd[0] != '.' && !(ft_strchr(c->rcmd, ' ')))
|
||||||
// else if (c->rcmd[0] != '.' && !(ft_strchr(c->rcmd, ' ')) && !c_chevron(c))
|
|
||||||
c_seek_binary(s, c);
|
c_seek_binary(s, c);
|
||||||
else
|
else
|
||||||
c_seek_files(s, c, current_word);
|
c_seek_files(s, c, current_word);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 17:20:01 by gwojda #+# #+# */
|
/* Created: 2017/03/08 17:20:01 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/22 11:52:18 by alao ### ########.fr */
|
/* Updated: 2017/03/22 14:51:44 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ int c_glob_matching(void)
|
||||||
if ((pos = c_glob_pos(NULL, 0)) == -1)
|
if ((pos = c_glob_pos(NULL, 0)) == -1)
|
||||||
return (0);
|
return (0);
|
||||||
current_word = ft_strdupi_w(str + pos);
|
current_word = ft_strdupi_w(str + pos);
|
||||||
if (current_word[0] == '$')
|
if (current_word[0] == '$' || current_word[0] == '~')
|
||||||
{
|
{
|
||||||
free(current_word);
|
free(current_word);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue