]> granicus.if.org Git - openjpeg/commitdiff
[trunk] Properly handle PGM file generation when fullpath is specified in the cmd...
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 10 Mar 2014 10:52:09 +0000 (10:52 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 10 Mar 2014 10:52:09 +0000 (10:52 +0000)
This will break a very old behavior (since 2005), but avoid writing in un-expected places for users
This also make the behavior similar with PGX file generation

src/bin/jp2/convert.c

index c170db7191c946af5341c2c573693b799767a78a..e946ca18f444daebe944eba9d671943e72fdee65 100644 (file)
@@ -2106,8 +2106,15 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
 
     for (compno = 0; compno < ncomp; compno++)
     {
-        if (ncomp > 1)
-            sprintf(destname, "%d.%s", compno, outfile);
+    if (ncomp > 1)
+      {
+      /*sprintf(destname, "%d.%s", compno, outfile);*/
+      const size_t olen = strlen(outfile);
+      const size_t dotpos = olen - 4;
+
+      strncpy(destname, outfile, dotpos);
+      sprintf(destname+dotpos, "_%d.pgm", compno);
+      }
         else
             sprintf(destname, "%s", outfile);