From 2b7d50e91412caed55699c2572d9861b37b80307 Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Wed, 8 Jun 2022 15:26:14 +0500 Subject: [PATCH] Minor --- ctpv.c | 13 +++++++++---- error.c | 2 ++ lexer.h | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ctpv.c b/ctpv.c index 9b59d80..13e58d0 100644 --- a/ctpv.c +++ b/ctpv.c @@ -257,8 +257,8 @@ static int list(void) width_name += 2, width_ext += 2; - puts("List of available previews:"); - printf("\t%-*s %-*s %s\n", width_name, header_name, width_ext, header_ext, + puts("List of available previews:\n"); + printf("\t%-*s %-*s %s\n\n", width_name, header_name, width_ext, header_ext, header_mime); for (size_t i = 0; i < len; i++) { @@ -281,7 +281,7 @@ static int list(void) s); } - puts("\nNote: '" ANY_TYPE "' means that it matches any."); + puts("\nNote: '" ANY_TYPE "' means that it matches any.\n"); return OK; } @@ -290,6 +290,11 @@ static int mime(int argc, char *argv[]) { const char *f, *mimetype; + if (argc <= 0) { + print_error("files are not specified"); + return ERR; + } + for (int i = 0; i < argc; i++) { f = argv[i]; ERRCHK_RET_OK(check_file(f)); @@ -300,7 +305,7 @@ static int mime(int argc, char *argv[]) ERRCHK_RET(!mimetype); if (argc > 1) - printf("%s: ", f); + printf("%s:\t", f); printf(".%s ", get_ext(f)); puts(mimetype); diff --git a/error.c b/error.c index 10194b7..3fba05e 100644 --- a/error.c +++ b/error.c @@ -5,6 +5,8 @@ void print_error(const char *error_msg) { + /* We print errors to stdout because lf file manager + * doesn't print stderr in the preview window. */ fprintf(stdout, "%s: %s\n", program, error_msg); } diff --git a/lexer.h b/lexer.h index 08a6a17..678d01d 100644 --- a/lexer.h +++ b/lexer.h @@ -5,7 +5,7 @@ #include #define PARSEERROR(c, format, ...) \ - print_errorf("config:%u:%u " format, (c).line, \ + print_errorf("config:%u:%u: " format, (c).line, \ (c).col __VA_OPT__(, ) __VA_ARGS__) typedef struct Lexer Lexer;