no more leaks :))),still have to look at weird permission displays like sticky bits n shit

This commit is contained in:
Jack Halford 2016-11-21 15:52:01 +01:00
parent f8d3967a8d
commit a341bcf800
13 changed files with 105 additions and 149 deletions

View file

@ -11,7 +11,7 @@ ft_error_dir src/lib_error.c /^void ft_error_dir(char *s)$/
ft_error_option src/lib_error.c /^void ft_error_option(char c)$/
ft_getopts src/lib_parse.c /^static int ft_getopts(char *str)$/
ft_ls_dirs src/ft_ls.c /^void ft_ls_dirs(t_list *dir, int opts)$/
ft_ls_files src/ft_ls.c /^void ft_ls_files(t_list *ent, t_list *dir, int opt/
ft_ls_files src/ft_ls.c /^void ft_ls_files(t_list **ent, t_list **dir, t_lsd/
ft_ls_long src/ft_ls_long.c /^int ft_ls_long(t_list *ent, t_lsdata *topdir)$/
ft_ls_long_date src/lib_ls_long.c /^void ft_ls_long_date(struct stat *stat)$/
ft_ls_long_lnk src/lib_ls_long2.c /^int ft_ls_long_lnk(t_lsdata *data)$/

View file

@ -14,7 +14,7 @@ D_INC = includes libft/includes
O_INC = $(addprefix -I, $(D_INC))
W_FLAGS = -Wall -Wextra -Werror
D_FLAGS =
D_FLAGS = -g
MKDIR = mkdir -p
RM = /bin/rm -rf

View file

@ -9,45 +9,49 @@ if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
endif
set shortmess=aoO
badd +98 src/lib_ls_long2.c
badd +27 src/ft_ls_long.c
badd +15 includes/ft_ls.h
badd +23 src/ft_ls_long.c
badd +7 includes/ft_ls.h
badd +60 ~/.tmux.conf
badd +52 src/lib_ls_long.c
badd +35 src/lib_lsdata.c
badd +76 src/lib_parse.c
badd +92 src/lib_parse.c
badd +22 libft/src/ft_printf/lib_pad.c
badd +19 libft/src/ft_printf/lib_pad_sharp.c
badd +9 libft/src/lst/ft_lst_filter.c
badd +14 libft/src/lst/ft_lst_filter.c
badd +14 src/lib_dirents.c
badd +21 src/main.c
badd +32 src/ft_ls.c
badd +21 src/ft_ent_free.c
badd +25 src/main.c
badd +43 src/ft_ls.c
badd +23 src/ft_ent_free.c
badd +1 Makefile
badd +16 src/lib_error.c
badd +22 src/lib_error.c
badd +32 src/lib_dirs.c
badd +19 src/ft_dir_get_ents.c
badd +33 libft/src/ft_printf/ft_printf.c
badd +31 src/ft_dir_get_ents.c
badd +9 libft/src/ft_printf/ft_printf.c
badd +43 libft/includes/ft_printf.h
badd +2 libft/src/printing/ft_putstr_fd.c
badd +11 libft/includes/libft.h
badd +2 libft/src/ft_printf/lib_fmt.c
badd +0 src/.lib_dirents.c.swo
badd +1 src/.lib_dirents.c.swo
badd +1 ft_ls
badd +1 libft/src/dlst/ft_dlstdel.c
badd +19 libft/src/lst/ft_lstdel.c
badd +20 libft/src/lst/ft_lstdel.c
badd +21 libft/src/path/ft_path_notdir.c
badd +0 libft/src/mem/ft_memcpy.c
badd +1 libft/src/mem/ft_memcpy.c
badd +19 libft/src/mem/ft_memdel.c
badd +11 libft/src/lst/ft_lst_delif.c
badd +32 libft/src/lst/ft_lst_delif.c
badd +22 libft/src/lst/ft_lstdelone.c
badd +25 libft/src/lst/ft_lst_removeif.c
badd +42 ~/.vimrc
badd +12 src/ft_ent_has_dir.c
badd +15 src/ft_ent_get_dirs.c
badd +17 src/lib_ent.c
badd +35 src/ft_ent_get_dirs.c
badd +20 src/lib_ent.c
badd +11 .Makefile.swp
badd +18 ~/dotfiles/vim.symlink/plugins.vim
badd +22 libft/src/str/ft_strsub.c
badd +0 libft/Makefile
badd +14 libft/src/btree/btree_print.c
badd +14 libft/src/printing/ft_putaddr.c
badd +0 ~/ft_ls/libft/src/str/ft_strinsert.c
args src/lib_ls_long2.c
edit includes/ft_ls.h
set splitbelow splitright
@ -59,8 +63,8 @@ set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
exe 'vert 1resize ' . ((&columns * 104 + 104) / 209)
exe 'vert 2resize ' . ((&columns * 104 + 104) / 209)
exe 'vert 1resize ' . ((&columns * 101 + 101) / 202)
exe 'vert 2resize ' . ((&columns * 100 + 101) / 202)
argglobal
setlocal fdm=manual
setlocal fde=0
@ -71,15 +75,15 @@ setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 25 - ((17 * winheight(0) + 40) / 80)
let s:l = 61 - ((44 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
25
normal! 019l
61
normal! 067l
wincmd w
argglobal
edit src/main.c
edit Makefile
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
@ -89,16 +93,38 @@ setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 19 - ((18 * winheight(0) + 40) / 80)
let s:l = 17 - ((16 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
19
normal! 01l
17
normal! 011l
wincmd w
exe 'vert 1resize ' . ((&columns * 104 + 104) / 209)
exe 'vert 2resize ' . ((&columns * 104 + 104) / 209)
tabedit src/ft_dir_get_ents.c
exe 'vert 1resize ' . ((&columns * 101 + 101) / 202)
exe 'vert 2resize ' . ((&columns * 100 + 101) / 202)
tabedit src/main.c
set splitbelow splitright
set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 23 - ((22 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
23
normal! 011l
tabedit src/lib_ent.c
set splitbelow splitright
wincmd _ | wincmd |
vsplit
@ -108,8 +134,8 @@ set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
exe 'vert 1resize ' . ((&columns * 104 + 104) / 209)
exe 'vert 2resize ' . ((&columns * 104 + 104) / 209)
exe 'vert 1resize ' . ((&columns * 101 + 101) / 202)
exe 'vert 2resize ' . ((&columns * 100 + 101) / 202)
argglobal
setlocal fdm=manual
setlocal fde=0
@ -120,12 +146,12 @@ setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 31 - ((30 * winheight(0) + 40) / 80)
let s:l = 38 - ((37 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
31
normal! 054l
38
normal! 011l
wincmd w
argglobal
edit src/ft_ls.c
@ -138,16 +164,16 @@ setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 30 - ((29 * winheight(0) + 40) / 80)
let s:l = 49 - ((48 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
30
normal! 01l
49
normal! 026l
wincmd w
exe 'vert 1resize ' . ((&columns * 104 + 104) / 209)
exe 'vert 2resize ' . ((&columns * 104 + 104) / 209)
tabedit src/lib_ent.c
exe 'vert 1resize ' . ((&columns * 101 + 101) / 202)
exe 'vert 2resize ' . ((&columns * 100 + 101) / 202)
tabedit ~/ft_ls/libft/src/str/ft_strinsert.c
set splitbelow splitright
set nosplitbelow
set nosplitright
@ -163,83 +189,12 @@ setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 18 - ((17 * winheight(0) + 40) / 80)
let s:l = 1 - ((0 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
18
1
normal! 0
tabedit libft/src/lst/ft_lstdel.c
set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
exe 'vert 1resize ' . ((&columns * 104 + 104) / 209)
exe 'vert 2resize ' . ((&columns * 104 + 104) / 209)
argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 19 - ((18 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
19
normal! 0
wincmd w
argglobal
edit libft/src/lst/ft_lst_delif.c
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 31 - ((30 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
31
normal! 0
wincmd w
exe 'vert 1resize ' . ((&columns * 104 + 104) / 209)
exe 'vert 2resize ' . ((&columns * 104 + 104) / 209)
tabedit src/ft_ent_get_dirs.c
set splitbelow splitright
set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 35 - ((34 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
35
normal! 03l
tabnext 4
if exists('s:wipebuf')
silent exe 'bwipe ' . s:wipebuf

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 15:10:03 by jhalford #+# #+# */
/* Updated: 2016/11/16 17:09:56 by jhalford ### ########.fr */
/* Updated: 2016/11/21 14:30:51 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -58,7 +58,7 @@ typedef struct s_pads t_pads;
int ft_ls_parse(int ac, char **av, t_list **dir, t_list **ent);
void ft_ls_dirs(t_list *dir, int opts);
void ft_ls_files(t_list *ent, t_list *dir, int opts);
void ft_ls_files(t_list **ent, t_list **dir, t_lsdata *topdir, int *opts);
void ft_lsdata_filename(t_lsdata *data);
int ft_lsdata_cmp_name(t_lsdata *dat1, t_lsdata *dat2);

@ -1 +1 @@
Subproject commit 1550a6dd5dca7c20e27ace800a797f3181b69772
Subproject commit 1267b92442d2358700a145164392dd07f4da6e0e

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 14:58:49 by jhalford #+# #+# */
/* Updated: 2016/11/16 18:21:48 by jhalford ### ########.fr */
/* Updated: 2016/11/21 14:23:30 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,7 +28,6 @@ t_list *ft_dir_get_ents(t_lsdata *topdir)
data.dirent = ft_memalloc(sizeof(*dirent) + 1);
ft_memcpy(data.dirent, dirent, sizeof(*dirent));
ft_lstadd(&ent, ft_lstnew(&data, sizeof(data)));
ft_printf("malloc'd ent at %p (%s)\n", ent, data.path);
}
closedir(stream);
return (ent);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/08 11:10:13 by jhalford #+# #+# */
/* Updated: 2016/11/16 12:28:28 by jhalford ### ########.fr */
/* Updated: 2016/11/21 14:22:57 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 14:57:21 by jhalford #+# #+# */
/* Updated: 2016/11/16 18:22:06 by jhalford ### ########.fr */
/* Updated: 2016/11/21 14:44:54 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,26 +28,24 @@ void ft_ls_dirs(t_list *dir, int opts)
dir = dir->next;
ft_lstdel(&ent, &ft_ent_free);
ent = ft_dir_get_ents(dirdata);
ft_ent_sort(&ent, opts);
ft_ent_filter(&ent, opts);
ft_ent_print(ent, &opts, dirdata, dir);
ft_ls_files(&ent, &dir, dirdata, &opts);
ft_lstdelone(&tmp, &ft_ent_free);
if (opts & OPTS_UR)
{
dir_r = ft_ent_get_dirs(&ent);
ft_lst_merge(&dir_r, dir);
dir = dir_r;
}
ft_lstdelone(&tmp, &ft_ent_free);
}
ft_lstdel(&ent, &ft_ent_free);
}
void ft_ls_files(t_list *ent, t_list *dir, int opts)
void ft_ls_files(t_list **ent, t_list **dir, t_lsdata *topdir, int *opts)
{
if (ent)
{
ft_ent_sort(&ent, opts);
ft_ent_filter(&ent, opts);
ft_ent_print(ent, &opts, NULL, dir);
ft_ent_filter(ent, *opts);
ft_ent_sort(ent, *opts);
ft_ent_print(*ent, opts, topdir, *dir);
}
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 14:58:05 by jhalford #+# #+# */
/* Updated: 2016/11/08 11:01:33 by jhalford ### ########.fr */
/* Updated: 2016/11/21 14:25:24 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 15:00:05 by jhalford #+# #+# */
/* Updated: 2016/11/16 18:22:22 by jhalford ### ########.fr */
/* Updated: 2016/11/21 14:34:29 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,6 +14,8 @@
void ft_ent_filter(t_list **ent, int opts)
{
/* (void)ent; */
/* (void)opts; */
if (!(opts & OPTS_LA))
ft_lst_delif(ent, ".", &ft_lsdata_cmp0, &ft_ent_free);
}
@ -33,13 +35,13 @@ void ft_ent_sort(t_list **ent, int opts)
void ft_ent_print(t_list *ent, int *opts, t_lsdata *topdir, t_list *nextdir)
{
if (*opts & OPTS_HEAD)
{
if (topdir)
{
if (*opts & OPTS_HEAD)
ft_printf("%s:\n", topdir->path);
}
else
*opts |= OPTS_HEAD;
}
if (ent)
{
if (*opts & OPTS_LL)
@ -47,6 +49,6 @@ void ft_ent_print(t_list *ent, int *opts, t_lsdata *topdir, t_list *nextdir)
else
ft_ls_short(ent);
}
if (nextdir || ((*opts & OPTS_UR) && ft_ent_has_dir(ent)))
if (ent && (nextdir || ((*opts & OPTS_UR) && ft_ent_has_dir(ent))))
ft_putchar('\n');
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 14:57:43 by jhalford #+# #+# */
/* Updated: 2016/11/16 11:05:56 by jhalford ### ########.fr */
/* Updated: 2016/11/21 13:21:32 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 15:02:46 by jhalford #+# #+# */
/* Updated: 2016/11/16 17:46:05 by jhalford ### ########.fr */
/* Updated: 2016/11/21 14:39:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,20 +19,22 @@ static void ft_ls_parse_files(int ac, char **av, t_list **dir, t_list **ent)
int i;
data.dirent = NULL;
i = 0;
while (i < ac)
i = -1;
while (++i < ac)
{
if (lstat(av[i], &data.stat) < 0)
{
ft_error_dir(av[i]);
continue ;
}
data.path = ft_strdup(av[i]);
if (lstat(data.path, &data.stat) < 0)
ft_error_dir(data.path);
else if (!(stream = opendir(data.path)))
ft_lstadd(ent, ft_lstnew(&data, sizeof(data)));
else
if ((stream = opendir(data.path)))
{
ft_lstadd(dir, ft_lstnew(&data, sizeof(data)));
closedir(stream);
}
i++;
else
ft_lstadd(ent, ft_lstnew(&data, sizeof(data)));
}
}
@ -87,7 +89,7 @@ int ft_ls_parse(int ac, char **av, t_list **dir, t_list **ent)
opts = 0;
i = ft_ls_parse_options(ac, av, &opts);
opts &= ((ac - i <= 1) ? ~0 : ~OPTS_HEAD);
opts |= (ac - i > 1) ? OPTS_HEAD : 0;
if (i == ac)
ft_ls_parse_files(1, (char*[2]){"."}, dir, ent);
else

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 15:00:15 by jhalford #+# #+# */
/* Updated: 2016/11/16 17:08:37 by jhalford ### ########.fr */
/* Updated: 2016/11/21 14:33:22 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,7 +21,7 @@ int main(int ac, char **av)
dir = NULL;
ent = NULL;
opts = ft_ls_parse(ac, av, &dir, &ent);
ft_ls_files(ent, dir, opts);
ft_ls_files(&ent, &dir, NULL, &opts);
ft_lstdel(&ent, &ft_ent_free);
ft_ls_dirs(dir, opts);
return (errno);