cjpeg/djpeg/jpegtran: Restore jpeg-6b arg abbrevs

There are two approaches to handling abbreviated command-line options:

1. If a new option is introduced that begins with the same letters as an
existing option, require a longer abbreviation for the existing option
in order to ensure that abbreviations are always unique.

2. Require a unique abbreviation only for new options, and match all
non-unique abbreviations with existing options, thus maintaining
backward compatibility.

keymatch() supports either approach, and Tom Lane historically seemed to
prefer Approach 2, whereas both approaches have been applied
inconsistently in the years since.  This commit consistently applies
Approach 2.

More specific notes:

We unnecessarily required 'cjpeg -progressive' to be abbreviated as
'cjpeg -pro' rather than 'cjpeg -p' when the -precision option was
introduced in libjpeg-turbo 3.0 beta.

The IJG unnecessarily required 'cjpeg -scans' to be abbreviated as
'cjpeg -scan' rather than 'cjpeg -sc' when the -scale option was
introduced in jpeg-7.  We even more unnecessarily adopted that
requirement, even though we never adopted the -scale option.

We unnecessarily required 'djpeg -scale' to be abbreviated as
'djpeg -sc' rather than 'djpeg -s' when the -skip option was introduced
in libjpeg-turbo 1.5 beta.

The IJG unnecessarily required 'jpegtran -copy' to be abbreviated as
'jpegtran -co' rather than 'jpegtran -c' when the -crop option was
introduced in jpeg-7.

The IJG unnecessarily required 'jpegtran -progressive' to be abbreviated
as 'jpegtran -pr' rather than 'jpegtran -p' when the -perfect option was
introduced in jpeg-7.
This commit is contained in:
DRC
2024-08-19 16:18:37 -04:00
parent 562ad7612e
commit a9723f8a98
3 changed files with 5 additions and 5 deletions

View File

@@ -456,7 +456,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
usage();
cinfo->data_precision = val;
} else if (keymatch(arg, "progressive", 3)) {
} else if (keymatch(arg, "progressive", 1)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = TRUE;
@@ -526,7 +526,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
* default sampling factors.
*/
} else if (keymatch(arg, "scans", 4)) {
} else if (keymatch(arg, "scans", 2)) {
/* Set scan script. */
#ifdef C_MULTISCAN_FILES_SUPPORTED
if (++argn >= argc) /* advance to next argument */

View File

@@ -392,7 +392,7 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
} else if (keymatch(arg, "report", 2)) {
report = TRUE;
} else if (keymatch(arg, "scale", 2)) {
} else if (keymatch(arg, "scale", 1)) {
/* Scale the output image by a fraction M/N. */
if (++argn >= argc) /* advance to next argument */
usage();

View File

@@ -183,7 +183,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
exit(EXIT_FAILURE);
#endif
} else if (keymatch(arg, "copy", 2)) {
} else if (keymatch(arg, "copy", 1)) {
/* Select which extra markers to copy. */
if (++argn >= argc) /* advance to next argument */
usage();
@@ -320,7 +320,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
* handle. */
transformoption.perfect = TRUE;
} else if (keymatch(arg, "progressive", 2)) {
} else if (keymatch(arg, "progressive", 1)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = TRUE;