completion triée #168
This commit is contained in:
parent
8b5c742002
commit
6935bc80db
3 changed files with 43 additions and 11 deletions
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_sstrsort.c :+: :+: :+: */
|
/* ft_sstrsort.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 18:03:37 by jhalford #+# #+# */
|
/* Created: 2016/11/03 18:03:37 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/23 14:46:54 by jhalford ### ########.fr */
|
/* Updated: 2017/03/23 14:40:25 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/09 15:50:24 by gwojda #+# #+# */
|
/* Created: 2017/03/09 15:50:24 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/22 12:29:40 by alao ### ########.fr */
|
/* Updated: 2017/03/23 15:35:59 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
|
|
||||||
|
void c_lst_id(t_comp *c);
|
||||||
/*
|
/*
|
||||||
** Create a new list node and add it by calling c_add_to_lst.
|
** Create a new list node and add it by calling c_add_to_lst.
|
||||||
*/
|
*/
|
||||||
|
|
@ -50,5 +51,6 @@ int c_seek_env(t_comp *c, char *current_word)
|
||||||
c_addnode(c, ft_strndup(env[i], ft_strchr(env[i], '=') - env[i]));
|
c_addnode(c, ft_strndup(env[i], ft_strchr(env[i], '=') - env[i]));
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
c_lst_id(c);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,33 +6,62 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/09 13:52:07 by alao #+# #+# */
|
/* Created: 2017/01/09 13:52:07 by alao #+# #+# */
|
||||||
/* Updated: 2017/03/21 14:46:39 by gwojda ### ########.fr */
|
/* Updated: 2017/03/23 15:34:53 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
|
|
||||||
|
void c_lst_id(t_comp *c)
|
||||||
|
{
|
||||||
|
t_clst *lst;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 1;
|
||||||
|
lst = c->lst;
|
||||||
|
if (!lst)
|
||||||
|
return ;
|
||||||
|
lst->cursor = 1;
|
||||||
|
if (!lst)
|
||||||
|
return ;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
lst->id = i;
|
||||||
|
lst = lst->next;
|
||||||
|
++i;
|
||||||
|
if (lst == c->lst)
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
** Add the matching element to the list
|
** Add the matching element to the list
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void c_add_to_lst(t_comp *c, t_clst *node)
|
void c_add_to_lst(t_comp *c, t_clst *node)
|
||||||
{
|
{
|
||||||
|
t_clst *lst;
|
||||||
|
|
||||||
|
lst = c->lst;
|
||||||
if (c->lst == NULL)
|
if (c->lst == NULL)
|
||||||
{
|
{
|
||||||
c->lst = node;
|
c->lst = node;
|
||||||
node->next = node;
|
node->next = node;
|
||||||
node->prev = node;
|
node->prev = node;
|
||||||
node->cursor = 1;
|
|
||||||
node->id = 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node->id = c->lst->prev->id + 1;
|
while (ft_strcmp(lst->name, node->name) < 0)
|
||||||
c->lst->prev->next = node;
|
{
|
||||||
node->prev = c->lst->prev;
|
lst = lst->next;
|
||||||
node->next = c->lst;
|
if (lst == c->lst)
|
||||||
c->lst->prev = node;
|
break ;
|
||||||
|
}
|
||||||
|
lst->prev->next = node;
|
||||||
|
node->prev = lst->prev;
|
||||||
|
node->next = lst;
|
||||||
|
lst->prev = node;
|
||||||
|
if (lst == c->lst && ft_strcmp(lst->name, node->name) > 0)
|
||||||
|
c->lst = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,5 +106,6 @@ int c_parser(t_comp *c, char *path, char *name)
|
||||||
while ((dirc = readdir(rep)))
|
while ((dirc = readdir(rep)))
|
||||||
c_storing(c, dirc->d_name, dirc->d_type);
|
c_storing(c, dirc->d_name, dirc->d_type);
|
||||||
closedir(rep);
|
closedir(rep);
|
||||||
|
c_lst_id(c);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue