Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(923)

Unified Diff: samples/pdfium_test.cc

Issue 477173003: Check if user provided more than one option for pdfium_test. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Tue 08/19/2014 14:38:22.91 Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/pdfium_test.cc
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index e92d7a1250124be24345b55686f573b8493bb068..72c8c5dcd104c85c75dcadbb4cd15c2d971382d4 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");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698