Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow -foo options with a warning instead of exiting

  • Loading branch information...
commit 6333f40746265751108d3a4593fad30d226aa7d7 1 parent ae430b2
@pornel authored
Showing with 9 additions and 22 deletions.
  1. +1 −0  CHANGELOG
  2. +8 −22 pngquant.c
View
1  CHANGELOG
@@ -4,6 +4,7 @@ version 1.7
- change of optional SSE3 code to SSE2 that is always enabled on x86-64
- optional OpenMP-based parallelisation of remapping
- significantly improved performance thanks to custom partial sorting
+ - changed long options to use double hyphen (-force to --force) [thanks to Jari Aalto]
version 1.6
-----------
View
30 pngquant.c
@@ -112,11 +112,9 @@ inline static int is_sse2_available()
}
#endif
-void exit_obsolete(const char *option)
+void warn_obsolete(const char *option)
{
- fprintf(stderr, "ERROR: option '%s' is obsoleted by '-%s'\n",
- option, option);
- exit(1);
+ fprintf(stderr, " warning: option '%s' has been replaced with '%s'\n", option+1, option);
}
int main(int argc, char *argv[])
@@ -139,21 +137,8 @@ int main(int argc, char *argv[])
*
* ***********************************************************************/
- const char *obsolete[] =
- {
- "-fs"
- "-floyd",
- "-nofloyd",
- "-ordered",
- "-force",
- "-noforce",
- "-verbose",
- "-noquiet",
- "-help",
- "-ext",
- "-speed",
- NULL
- };
+ char *obsolete[] = { "--fs", "--nofs", "--floyd", "--nofloyd", "--ordered", "--force", "--noforce",
+ "--verbose", "--noquiet", "--help", "--version", "--ext", "--speed", NULL };
int index = 1; /* skip program name */
@@ -169,13 +154,14 @@ int main(int argc, char *argv[])
continue;
const char *str = argv[index];
- const char *option;
+ char *option;
int i = 0;
while ( (option = obsolete[i++]) ) {
- if ( strcmp(str, option) == 0 ) {
- exit_obsolete(option);
+ if ( strcmp(str, option+1) == 0 ) { // option is --foo, compares -foo
+ warn_obsolete(option);
+ argv[index] = option; // replace -foo with --foo
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.