[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
This commit is contained in:
Mathieu Malaterre 2014-03-10 10:52:09 +00:00
parent 76af73bc72
commit 9a52b30c3d
1 changed files with 9 additions and 2 deletions

View File

@ -2107,7 +2107,14 @@ 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);
{
/*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);