task

creates a plain-text task file in the current directory
git clone git://brookjeynes.dev/bjeynes/task.git
Log | Files | Refs | README | LICENSE

commit bc4a265e4487004f24804900ab55b2879c45cd01
parent c04a3d6846cb3ef7bad9300519a5bb4e1c2a2568
Author: brookjeynes <me@brookjeynes.dev>
Date:   Thu, 11 Jun 2026 14:15:23 +1000

refactor: simplify validation and filename buffer

Diffstat:
Mmain.c | 19++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/main.c b/main.c @@ -71,23 +71,20 @@ int main(int argc, char *argv[]) { } if (cli_args.priority != '\0') { - char *alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - int is_uppercase_letter = 0; - for (int idx = 0; idx < 26; idx++) { - if (cli_args.priority == alphabet[idx]) { - is_uppercase_letter = 1; - break; - } - } - if (!is_uppercase_letter) { + if (cli_args.priority < 'A' || cli_args.priority > 'Z') { fprintf(stderr, "err: priority must be between [A-Z]\n"); exit(1); } } size_t title_len = strlen(cli_args.title); - char title_to_file[title_len + 5]; - for (int idx = 0; idx < title_len; idx++) { + if (title_len > 251) { + fprintf(stderr, "err: title too long for file name\n"); + exit(1); + } + + char title_to_file[256]; + for (size_t idx = 0; idx < title_len; idx++) { if (cli_args.title[idx] == ' ') { title_to_file[idx] = '_'; } else {