diff --git a/main.cpp b/main.cpp index 51bb372..3536e1f 100644 --- a/main.cpp +++ b/main.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -18,8 +17,11 @@ static volatile bool g_interrupted = false; -static void noop_log(enum ggml_log_level level, const char * text, void * user_data) { - (void)level; (void)text; (void)user_data; +static void noop_log(const ggml_log_level level, const char *text, + void *user_data) { + (void)level; + (void)text; + (void)user_data; } static void sigint_handler(const int signo) { @@ -102,7 +104,7 @@ static std::vector read_clipboard() { while ((n = fread(buf, 1, sizeof(buf), pipe)) > 0) { data.insert(data.end(), buf, buf + n); } - int st = pclose(pipe); + const int st = pclose(pipe); if (st != 0 || data.empty()) { data.clear(); // fallback for X11: try without explicit target @@ -124,7 +126,8 @@ static std::string capture_screenshot(bool quiet) { tmpdir = "/tmp"; std::string path = std::string(tmpdir) + "/ocr_screenshot.png"; - if (!quiet) fprintf(stderr, "Select a screen region to OCR...\n"); + if (!quiet) + fprintf(stderr, "Select a screen region to OCR...\n"); auto check = [&]() -> bool { struct stat st {}; @@ -173,7 +176,7 @@ static void print_usage(const char *prog) { "\n" "Options:\n" " -m, --model model file path (GGUF)\n" - " --mmproj,--mm mmproj file path\n" + " --mmproj mmproj file path\n" " -p OCR prompt (default: OCR)\n" " -t number of threads (default: cpu cores)\n" " --ngl GPU layers (-1 = all, default: -1)\n" @@ -212,19 +215,11 @@ int main(int argc, char **argv) { bool json_output = false; bool quiet = false; - // pre-process -mm to --mmproj so getopt handles it correctly - for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "-mm") == 0) { - argv[i] = (char *)"--mmproj"; - } - } - while (true) { static option long_opts[] = { {"temp", required_argument, nullptr, 0}, {"json", no_argument, nullptr, 1}, {"mmproj", required_argument, nullptr, 2}, - {"mm", required_argument, nullptr, 2}, {"ngl", required_argument, nullptr, 3}, {"model", required_argument, nullptr, 'm'}, {"chat-template", required_argument, nullptr, 4}, @@ -284,7 +279,7 @@ int main(int argc, char **argv) { } if (model_path.empty() || mmproj_path.empty()) { - fprintf(stderr, "ERROR: -m/--model and --mmproj/--mm are required\n"); + fprintf(stderr, "ERROR: -m/--model and --mmproj are required\n"); return 1; } @@ -367,7 +362,8 @@ int main(int argc, char **argv) { return 1; } } else { - if (!quiet) fprintf(stderr, "Reading image from clipboard...\n"); + if (!quiet) + fprintf(stderr, "Reading image from clipboard...\n"); auto clip = read_clipboard(); if (clip.empty()) { fprintf(stderr,