diff options
Diffstat (limited to 'src/ft_get_tex.c')
-rw-r--r-- | src/ft_get_tex.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c index 652f4af..0e394dc 100644 --- a/src/ft_get_tex.c +++ b/src/ft_get_tex.c @@ -11,20 +11,25 @@ ft_get_tex_no(int fd, t_win *wlist) get_next_line(fd, &line); if (!(words = ft_split(line, ' '))) + { + ft_memdel(line); return (ft_exit(5, wlist)); + } if (!(*words) || ft_strcmp(*words, "NO") || !(*(words + 1)) || (*(words + 2))) { - ft_free_words(words); + ft_free_words(words, line); return (ft_map_error(2, wlist)); } ft_memdel(wlist->clist->no_tex_path); len = ft_strlen(*(words + 1)); if (!(wlist->clist->no_tex_path = (char*)malloc((len + 1) * sizeof(char)))) + { + ft_free_words(words, line); return (-1); + } ft_strlcpy(wlist->clist->no_tex_path, *(words + 1), len + 1); - ft_free_words(words); - ft_memdel(line); + ft_free_words(words, line); return (0); } @@ -37,20 +42,25 @@ ft_get_tex_so(int fd, t_win *wlist) get_next_line(fd, &line); if (!(words = ft_split(line, ' '))) + { + ft_memdel(line); return (ft_exit(5, wlist)); + } if (!(*words) || ft_strcmp(*words, "SO") || !(*(words + 1)) || (*(words + 2))) { - ft_free_words(words); + ft_free_words(words, line); return (ft_map_error(3, wlist)); } ft_memdel(wlist->clist->so_tex_path); len = ft_strlen(*(words + 1)); if (!(wlist->clist->so_tex_path = (char*)malloc((len + 1) * sizeof(char)))) + { + ft_free_words(words, line); return (-1); + } ft_strlcpy(wlist->clist->so_tex_path, *(words + 1), len + 1); - ft_free_words(words); - ft_memdel(line); + ft_free_words(words, line); return (0); } @@ -63,20 +73,25 @@ ft_get_tex_we(int fd, t_win *wlist) get_next_line(fd, &line); if (!(words = ft_split(line, ' '))) + { + ft_memdel(line); return (ft_exit(5, wlist)); + } if (!(*words) || ft_strcmp(*words, "WE") || !(*(words + 1)) || (*(words + 2))) { - ft_free_words(words); + ft_free_words(words, line); return (ft_map_error(4, wlist)); } ft_memdel(wlist->clist->we_tex_path); len = ft_strlen(*(words + 1)); if (!(wlist->clist->we_tex_path = (char*)malloc((len + 1) * sizeof(char)))) + { + ft_free_words(words, line); return (-1); + } ft_strlcpy(wlist->clist->we_tex_path, *(words + 1), len + 1); - ft_free_words(words); - ft_memdel(line); + ft_free_words(words, line); return (0); } @@ -89,20 +104,25 @@ ft_get_tex_ea(int fd, t_win *wlist) get_next_line(fd, &line); if (!(words = ft_split(line, ' '))) + { + ft_memdel(line); return (ft_exit(5, wlist)); + } if (!(*words) || ft_strcmp(*words, "EA") || !(*(words + 1)) || (*(words + 2))) { - ft_free_words(words); + ft_free_words(words, line); return (ft_map_error(5, wlist)); } ft_memdel(wlist->clist->ea_tex_path); len = ft_strlen(*(words + 1)); if (!(wlist->clist->ea_tex_path = (char*)malloc((len + 1) * sizeof(char)))) + { + ft_free_words(words, line); return (-1); + } ft_strlcpy(wlist->clist->ea_tex_path, *(words + 1), len + 1); - ft_free_words(words); - ft_memdel(line); + ft_free_words(words, line); return (0); } |