int get_history(t_shprop *shell, int fd) { int ret; char *line; t_hist *hist; hist = NULL; line = NULL; ret = 1; if (fd == -1) ret = -1; while (get_next_line(fd, &line) > 0) { if (ft_strlen(line)) { line = ft_replace(line, "\033", ""); t_hist_push(&hist, t_hist_new(line, 1)); } ft_strdel(&line); } if (line) ft_strdel(&line); t_hist_push(&hist, t_hist_new(NULL, 0)); shell->hist = hist; return (ret); }
char *unprotect(char *line) { char *syntax; char protect[2]; char *tmp; char *tmp2; if (!line) return (line); if (!ft_strchr(line, '\033')) return (line); syntax = SYNTAX; protect[0] = *syntax; protect[1] = '\0'; while (protect[0]) { tmp2 = ft_itoa((int)protect[0]); tmp = ft_strjoin("\033@", tmp2); line = ft_replace(line, tmp, protect); ft_strdel(&tmp); ft_strdel(&tmp2); syntax++; protect[0] = *syntax; } return (line); }
void ft_putendl_c(char const *s, char *color) { char *palet_color; palet_color = ft_strjoin("\033[%sm", s); palet_color = ft_replace(palet_color, "%s", ft_itoa(putcolor(color))); ft_putendl(palet_color); ft_putstr(C_NONE); ft_strdel(&palet_color); }
int main(int argc, char **argv) { if (argc == 4) { if (!(argv[3][1] != '\0' || argv[2][1] != '\0')) { ft_replace(argv[1], argv[2][0], argv[3][0]); } } ft_putchar('\n'); return (0); }
double ft_put_cu(t_ba *ba, t_obj *obj) { double det[12]; double ray[3]; double cam[3]; int tmp[6]; ft_save(ba, obj, tmp, det); rotate(ba, obj, ray, cam); ft_ini_cub(ba, obj, cam, ray); ft_put_cu2(ba, obj); return (ft_replace(ba, obj, det, tmp)); }
void build_cd(t_data *d) { char **av; if (!build_cd_check_for_env(d)) return ; ft_replace('\t', ' ', d->toexec); av = ft_strsplit(d->toexec, ' '); if (av[1] != NULL && ft_strcmp(av[1], ".") != 0) { if (ft_strcmp(av[1], "-") == 0) cd_dash(d, av[1]); else build_cd2(d, av); } if (av[1] == NULL) cd_only(d, av[1]); free_tabtab(av); }
char *protect_all(char *line) { static char *syntax = SYNTAX; char protect[2]; char *tmp; int i; if (!has_syntax_in(line)) return (line); protect[1] = '\0'; i = 0; while (syntax[i]) { if (ft_strchr(line, syntax[i])) { protect[0] = syntax[i]; tmp = ft_strf("\033@%d", (int)protect[0]); line = ft_replace(line, protect, tmp); ft_strdel(&tmp); } i++; } return (line); }