diff options
author | Vitaly Buka <vitalybuka@chromium.org> | 2014-08-20 10:32:36 -0700 |
---|---|---|
committer | Vitaly Buka <vitalybuka@chromium.org> | 2014-08-20 10:32:36 -0700 |
commit | 8f2c3dc95a6a42ea52d923457a688a6db1c4aace (patch) | |
tree | 2d726bfa56727ea9349488fd52a1aa488b84fbf2 /samples/pdfium_test.cc | |
parent | 93d081110279c309433a397bfba71b46533a710d (diff) | |
download | pdfium-8f2c3dc95a6a42ea52d923457a688a6db1c4aace.tar.xz |
Check if user provided more than one option for pdfium_test.
R=bo_xu@foxitsoftware.com
Review URL: https://codereview.chromium.org/477173003
Diffstat (limited to 'samples/pdfium_test.cc')
-rw-r--r-- | samples/pdfium_test.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index e92d7a1250..72c8c5dcd1 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -189,20 +189,23 @@ bool ParseCommandLine(int argc, const char* argv[], OutputFormat* output_format, files->clear(); int cur_arg = 1; - if (cur_arg < argc) { + for (; cur_arg < argc; ++cur_arg) { if (strcmp(argv[cur_arg], "--ppm") == 0) *output_format = OUTPUT_PPM; #ifdef _WIN32 - if (strcmp(argv[cur_arg], "--emf") == 0) + else if (strcmp(argv[cur_arg], "--emf") == 0) *output_format = OUTPUT_EMF; - if (strcmp(argv[cur_arg], "--bmp") == 0) + else if (strcmp(argv[cur_arg], "--bmp") == 0) *output_format = OUTPUT_BMP; #endif - if (*output_format != OUTPUT_NONE) - cur_arg++; + else + break; } - if (cur_arg >= argc) + if (cur_arg > 2) // Multiple options. + return false; + + if (cur_arg >= argc) // No input files. return false; for (int i = cur_arg; i < argc; i++) @@ -356,7 +359,7 @@ int main(int argc, const char* argv[]) { OutputFormat format = OUTPUT_NONE; std::list<const char*> files; if (!ParseCommandLine(argc, argv, &format, &files)) { - printf("Usage: pdfium_test [OPTIONS] [FILE]\n"); + printf("Usage: pdfium_test [OPTION] [FILE]...\n"); printf("--ppm write page images <pdf-name>.<page-number>.ppm\n"); #ifdef _WIN32 printf("--bmp write page images <pdf-name>.<page-number>.bmp\n"); |