summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>2014-03-10 10:52:09 +0000
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2014-03-10 10:52:09 +0000
commit9a52b30c3d9aba4de5c21c555b0c159da7f423f4 (patch)
treed450ba4c6e3adf1aba2124e9b3ccfeffaa244556
parent76af73bc7257ce09ff35c32439bc7714c4164a4a (diff)
[trunk] Properly handle PGM file generation when fullpath is specified in the cmd line
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
-rw-r--r--src/bin/jp2/convert.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c
index c170db71..e946ca18 100644
--- a/src/bin/jp2/convert.c
+++ b/src/bin/jp2/convert.c
@@ -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);