From d781646c2942ad86a4912babc9bacd9f3b797409 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 1 Apr 2024 19:34:17 -0700 Subject: [PATCH] vwebp: fix window title when options are given Options can precede the file name. This still won't be correct for Unicode file names, but an approximation will be displayed (with '?'s) rather than the first character if kParams.file_name were used. glutCreateWindow() looks like it will prohibit correcting this as it expects an ASCII string. Change-Id: I96986a178a0bbce6971d2ac415222d4a456ce1a3 --- examples/vwebp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/vwebp.c b/examples/vwebp.c index 4c80bdf3..fa5fadb1 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -498,7 +498,7 @@ static void Help(void) { } int main(int argc, char* argv[]) { - int c; + int c, file_name_argv_index = 1; WebPDecoderConfig* const config = &kParams.config; WebPIterator* const curr = &kParams.curr_frame; @@ -545,7 +545,10 @@ int main(int argc, char* argv[]) { } else if (!strcmp(argv[c], "-mt")) { config->options.use_threads = 1; } else if (!strcmp(argv[c], "--")) { - if (c < argc - 1) kParams.file_name = (const char*)GET_WARGV(argv, ++c); + if (c < argc - 1) { + kParams.file_name = (const char*)GET_WARGV(argv, ++c); + file_name_argv_index = c; + } break; } else if (argv[c][0] == '-') { printf("Unknown option '%s'\n", argv[c]); @@ -553,6 +556,7 @@ int main(int argc, char* argv[]) { FREE_WARGV_AND_RETURN(-1); } else { kParams.file_name = (const char*)GET_WARGV(argv, c); + file_name_argv_index = c; } if (parse_error) { @@ -632,7 +636,7 @@ int main(int argc, char* argv[]) { #ifdef FREEGLUT glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); #endif - StartDisplay(argv[1]); + StartDisplay(argv[file_name_argv_index]); if (kParams.has_animation) glutTimerFunc(0, decode_callback, 0); glutMainLoop();