t_line *edit_concatlist(t_line *p1, t_line *p2, int n) { t_line *t1; t_line *t2; t1 = p1; t2 = p2; if (p1 == NULL || p2 == NULL) return (special_case(p1, p2)); (n > edit_listlen(p1)) ? (n = edit_listlen(p1)) : (n = n); if (!n) { while (t2->next) t2 = t2->next; t2->next = p1; return (p2); } while (--n) t1 = t1->next; t1->status = 0; p2->prev = t1; while (t2->next) t2 = t2->next; t2->next = t1->next; t1->next = p2; return (p1); }
void opts_print_help(bl* opts, FILE* fid, void (*special_case)(an_option_t* opt, bl* allopts, int index, FILE* fid, void* extra), void* extra) { int i; for (i=0; i<bl_size(opts); i++) { an_option_t* opt = bl_access(opts, i); int nw = 0; sl* words; int j; if (opt->help) { if ((opt->shortopt >= 'a' && opt->shortopt <= 'z') || (opt->shortopt >= 'A' && opt->shortopt <= 'Z') || (opt->shortopt >= '0' && opt->shortopt <= '9')) nw += fprintf(fid, " -%c / --%s", opt->shortopt, opt->name); else nw += fprintf(fid, " --%s", opt->name); if (opt->has_arg == optional_argument) nw += fprintf(fid, " [<%s>]", opt->argname); else if (opt->has_arg == required_argument) nw += fprintf(fid, " <%s>", opt->argname); nw += fprintf(fid, ": "); if (!opt->help) continue; words = split_long_string(opt->help, 80-nw, 70, NULL); for (j=0; j<sl_size(words); j++) fprintf(fid, "%s%s\n", (j==0 ? "" : " "), sl_get(words, j)); } else if (special_case) special_case(opt, opts, i, fid, extra); } }