feat(ui,db,cmd): reduce dublicate code in window subwin logic, unify SQLite helpers, NULL checks added

window.c: add _get_subwin_cols, _apply_split_resize, _check_subwin_width; refactor show/hide/resize/refresh/update
database.c: add _db_prepare_ctx, _db_teardown; safer init/queries with fallback timestamp
cmd_defs.c: guard fopen in docgen; inputwin.c: replace assert with runtime check
This commit is contained in:
2025-11-10 15:09:09 +03:00
parent a9c21ce487
commit 9b292a6100
4 changed files with 83 additions and 52 deletions

View File

@@ -2988,8 +2988,19 @@ command_docgen(void)
cmds = g_list_insert_sorted(cmds, (gpointer)pcmd, (GCompareFunc)_cmp_command);
}
FILE* toc_fragment = fopen("toc_fragment.html", "w");
FILE* main_fragment = fopen("main_fragment.html", "w");
FILE* toc_fragment = fopen("toc_fragment.html", "w");
if (!toc_fragment) {
log_error("command_docgen(): unable to open toc_fragment.html for writing: %s", g_strerror(errno));
g_list_free(cmds);
return;
}
FILE* main_fragment = fopen("main_fragment.html", "w");
if (!main_fragment) {
log_error("command_docgen(): unable to open main_fragment.html for writing: %s", g_strerror(errno));
fclose(toc_fragment);
g_list_free(cmds);
return;
}
fputs("<ul><li><ul><li>\n", toc_fragment);
fputs("<hr>\n", main_fragment);
@@ -3057,8 +3068,8 @@ command_docgen(void)
fputs("</ul></ul>\n", toc_fragment);
fclose(toc_fragment);
fclose(main_fragment);
fclose(toc_fragment);
fclose(main_fragment);
printf("\nProcessed %d commands.\n\n", g_list_length(cmds));
g_list_free(cmds);
}
@@ -3093,7 +3104,12 @@ command_mangen(void)
log_error("command_mangen(): could not allocate memory");
return;
}
FILE* manpage = fopen(filename, "w");
FILE* manpage = fopen(filename, "w");
if (!manpage) {
log_error("command_mangen(): unable to open %s for writing: %s", filename, g_strerror(errno));
curr = g_list_next(curr);
continue;
}
fprintf(manpage, "%s\n", header);
fputs(".SH NAME\n", manpage);
@@ -3128,7 +3144,7 @@ command_mangen(void)
}
}
fclose(manpage);
fclose(manpage);
curr = g_list_next(curr);
}