int main(int argc, char *argv[]) { bool found_tag = false; bool do_print = false; dstr line = ""; dstr prefix = ""; d_init(argc, argv); while (d_getline(line)) { if (d_match(line, "/[*] (Function|Type|Enum): (.*)")) { found_tag = true; do_print = false; d_assign(prefix, d_submatch(2)); continue; } if (found_tag && d_match(line, "^ ?\\*/")) { found_tag = false; do_print = true; continue; } if (d_match(line, "^\\{|^$")) { do_print = false; continue; } /* Prototype ends on blank line. */ /* TODO: Should the above regexp match it? If so it doesn't here... */ if (line[0] == 0) { do_print = false; continue; } if (do_print) { printf("%s: %s\n", prefix, line); } if (d_match(line, "\\{ *$|; *$")) { do_print = false; } } return 0; }
int main(int argc, char *argv[]) { dstr line; Aatree * root = &aa_nil; d_init(argc, argv); d_printf("# Index\n"); while ((d_getline(line))) { if (d_match(line, "^\\[([^\\]]*)")) { const char *ref = d_submatch(1); char *s = xstrdup(ref); root = aa_insert(root, s, s); } } pre_order_traversal(root, print_link); aa_destroy(root); return 0; }
static void load_prototypes(const char *filename) { dstr line; const char *name; const char *newtext; const char *file_name; const char *line_number; dstr text; d_open_input(filename); while (d_getline(line)) { if (d_match(line, "([^:]*): ([^:]*):([^:]*):([^:]*)")) { name = d_submatch(1); newtext = d_submatch(2); file_name = d_submatch(3); line_number = d_submatch(4); d_assign(text, lookup_prototype(name)); strcat(text, "\n"); strcat(text, newtext); protos = aa_insert(protos, name, text); d_assign(text, lookup_source(name)); if (strlen(text) == 0) { strcat(text, "https://github.com/liballeg/allegro5/blob/5.1/"); strcat(text, file_name); strcat(text, "#L"); strcat(text, line_number); sources = aa_insert(sources, name, text); } } } d_close_input(); }