Commit 9a4ef8c95dd00d276d36d8e56f4cc6e1c75774fc

Authored by Jay Berkenbilt
1 parent c74d79ae

Separate copyright notice from --version option

qpdf/qpdf.cc
@@ -225,6 +225,9 @@ provided last take precedence.\n\ @@ -225,6 +225,9 @@ provided last take precedence.\n\
225 Basic Options\n\ 225 Basic Options\n\
226 -------------\n\ 226 -------------\n\
227 \n\ 227 \n\
  228 +--version show version of qpdf\n\
  229 +--copyright show qpdf's copyright and license information\n\
  230 +--help show command-line argument help\n\
228 --password=password specify a password for accessing encrypted files\n\ 231 --password=password specify a password for accessing encrypted files\n\
229 --verbose provide additional informational output\n\ 232 --verbose provide additional informational output\n\
230 --linearize generated a linearized (web optimized) file\n\ 233 --linearize generated a linearized (web optimized) file\n\
@@ -1188,16 +1191,23 @@ static void read_args_from_file(char const* filename, @@ -1188,16 +1191,23 @@ static void read_args_from_file(char const* filename,
1188 1191
1189 static void handle_help_version(int argc, char* argv[]) 1192 static void handle_help_version(int argc, char* argv[])
1190 { 1193 {
  1194 + // Make sure the outpu looks right on an 80-column display.
  1195 +
1191 if ((argc == 2) && 1196 if ((argc == 2) &&
1192 ((strcmp(argv[1], "--version") == 0) || 1197 ((strcmp(argv[1], "--version") == 0) ||
1193 (strcmp(argv[1], "-version") == 0))) 1198 (strcmp(argv[1], "-version") == 0)))
1194 { 1199 {
1195 - // make_dist looks for the line of code here that actually  
1196 - // prints the version number, so read make_dist if you change  
1197 - // anything other than the version number. Don't worry about  
1198 - // the numbers. That's just a guide to 80 columns so that the  
1199 - // help message looks right on an 80-column display. 1200 + std::cout
  1201 + << whoami << " version " << QPDF::QPDFVersion() << std::endl
  1202 + << "Run " << whoami << " --copyright to see copyright and license information."
  1203 + << std::endl;
  1204 + exit(0);
  1205 + }
1200 1206
  1207 + if ((argc == 2) &&
  1208 + ((strcmp(argv[1], "--copyright") == 0) ||
  1209 + (strcmp(argv[1], "-copyright") == 0)))
  1210 + {
1201 // 1 2 3 4 5 6 7 8 1211 // 1 2 3 4 5 6 7 8
1202 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 1212 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
1203 std::cout 1213 std::cout
qpdf/qtest/qpdf.test
@@ -250,12 +250,17 @@ foreach my $d (@bug_tests) @@ -250,12 +250,17 @@ foreach my $d (@bug_tests)
250 show_ntests(); 250 show_ntests();
251 # ---------- 251 # ----------
252 $td->notify("--- Library version ---"); 252 $td->notify("--- Library version ---");
253 -$n_tests += 2; 253 +$n_tests += 3;
254 254
255 $td->runtest("qpdf version", 255 $td->runtest("qpdf version",
256 {$td->COMMAND => "qpdf --version"}, 256 {$td->COMMAND => "qpdf --version"},
257 {$td->REGEXP => "qpdf version \\S+\n.*", $td->EXIT_STATUS => 0}, 257 {$td->REGEXP => "qpdf version \\S+\n.*", $td->EXIT_STATUS => 0},
258 $td->NORMALIZE_NEWLINES); 258 $td->NORMALIZE_NEWLINES);
  259 +$td->runtest("qpdf copyright contains version too",
  260 + {$td->COMMAND => "qpdf --copyright"},
  261 + {$td->REGEXP => "(?s)qpdf version \\S+\n.*Apache.*",
  262 + $td->EXIT_STATUS => 0},
  263 + $td->NORMALIZE_NEWLINES);
259 $td->runtest("C API: qpdf version", 264 $td->runtest("C API: qpdf version",
260 {$td->COMMAND => "qpdf-ctest --version"}, 265 {$td->COMMAND => "qpdf-ctest --version"},
261 {$td->REGEXP => "qpdf-ctest version \\S+\n", 266 {$td->REGEXP => "qpdf-ctest version \\S+\n",