mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
libwebp: Unicode command tools on Windows
Define macros in examples/unicode.h to use Unicode argv on Windows. Keep char everywhere on Unix since it handles UTF-8 without any change. Impact: - All fopen () and SHCreateStreamOnFile(), - All fprintf() printing file paths, - All strcmp() used with "-", - File path parsing, - Gif reading. Concerned executables from examples/ and extras/: anim_diff, anim_dump, vwebp, vwebp_sdl, cwebp, dwebp, gif2webp, img2webp, webpmux, webpinfo, webp_quality, get_disto When compiled on Windows with Unicode enabled, webpmux and img2webp will not work when used with an argument file and will print "Reading arguments from a file is a feature unavailable with Unicode binaries." BUG=webp:398 Change-Id: Ic55d222a3ce1a715f9c4cce57ecbe2705d5ce317
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#include "../imageio/imageio_util.h"
|
||||
#include "./unicode.h"
|
||||
#include "webp/decode.h"
|
||||
#include "webp/format_constants.h"
|
||||
#include "webp/mux_types.h"
|
||||
@ -1119,19 +1120,21 @@ int main(int argc, const char* argv[]) {
|
||||
WebPInfoStatus webp_info_status = WEBP_INFO_OK;
|
||||
WebPInfo webp_info;
|
||||
|
||||
INIT_WARGV(argc, argv);
|
||||
|
||||
if (argc == 1) {
|
||||
HelpShort();
|
||||
return WEBP_INFO_OK;
|
||||
FREE_WARGV_AND_RETURN(WEBP_INFO_OK);
|
||||
}
|
||||
|
||||
// Parse command-line input.
|
||||
for (c = 1; c < argc; ++c) {
|
||||
if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) {
|
||||
HelpShort();
|
||||
return WEBP_INFO_OK;
|
||||
FREE_WARGV_AND_RETURN(WEBP_INFO_OK);
|
||||
} else if (!strcmp(argv[c], "-H") || !strcmp(argv[c], "-longhelp")) {
|
||||
HelpLong();
|
||||
return WEBP_INFO_OK;
|
||||
FREE_WARGV_AND_RETURN(WEBP_INFO_OK);
|
||||
} else if (!strcmp(argv[c], "-quiet")) {
|
||||
quiet = 1;
|
||||
} else if (!strcmp(argv[c], "-diag")) {
|
||||
@ -1144,7 +1147,7 @@ int main(int argc, const char* argv[]) {
|
||||
const int version = WebPGetDecoderVersion();
|
||||
printf("WebP Decoder version: %d.%d.%d\n",
|
||||
(version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff);
|
||||
return 0;
|
||||
FREE_WARGV_AND_RETURN(0);
|
||||
} else { // Assume the remaining are all input files.
|
||||
break;
|
||||
}
|
||||
@ -1152,27 +1155,28 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
if (c == argc) {
|
||||
HelpShort();
|
||||
return WEBP_INFO_INVALID_COMMAND;
|
||||
FREE_WARGV_AND_RETURN(WEBP_INFO_INVALID_COMMAND);
|
||||
}
|
||||
|
||||
// Process input files one by one.
|
||||
for (; c < argc; ++c) {
|
||||
WebPData webp_data;
|
||||
const char* in_file = NULL;
|
||||
const W_CHAR* in_file = NULL;
|
||||
WebPInfoInit(&webp_info);
|
||||
webp_info.quiet_ = quiet;
|
||||
webp_info.show_diagnosis_ = show_diag;
|
||||
webp_info.show_summary_ = show_summary;
|
||||
webp_info.parse_bitstream_ = parse_bitstream;
|
||||
in_file = argv[c];
|
||||
if (in_file == NULL || !ReadFileToWebPData(in_file, &webp_data)) {
|
||||
in_file = GET_WARGV(argv, c);
|
||||
if (in_file == NULL ||
|
||||
!ReadFileToWebPData((const char*)in_file, &webp_data)) {
|
||||
webp_info_status = WEBP_INFO_INVALID_COMMAND;
|
||||
fprintf(stderr, "Failed to open input file %s.\n", in_file);
|
||||
WFPRINTF(stderr, "Failed to open input file %s.\n", in_file);
|
||||
continue;
|
||||
}
|
||||
if (!webp_info.quiet_) printf("File: %s\n", in_file);
|
||||
if (!webp_info.quiet_) WPRINTF("File: %s\n", in_file);
|
||||
webp_info_status = AnalyzeWebP(&webp_info, &webp_data);
|
||||
WebPDataClear(&webp_data);
|
||||
}
|
||||
return webp_info_status;
|
||||
FREE_WARGV_AND_RETURN(webp_info_status);
|
||||
}
|
||||
|
Reference in New Issue
Block a user