Description: Sfftobmp does not append page index to output filenames anymore
 When converting a multipage fax, sfftobmp does not append the expected
 numerical page index to the output filename:

 File /var/spool/capisuite/received/fax.sff seems to
 have 2 page(s).
 - Destination File /tmp/buschfaxtmp/fax.jpg :
   Converting page 1 (1728x1140px / 203x98dpi), LowRes ...
 - Destination File /tmp/buschfaxtmp/fax.jpg :
   Converting page 2 (1728x1140px / 203x98dpi), LowRes ...

 It ought to be (and was in prior versions):

 - Destination File /tmp/buschfaxtmp/fax_001.jpg :
   Converting page 1 (1728x1140px / 203x98dpi), LowRes ...
 - Destination File /tmp/buschfaxtmp/fax_002.jpg :
   Converting page 2 (1728x1140px / 203x98dpi), LowRes ...

 The problem was identified to be associated with new behaviour introduced by
 boost::filesystem V3 (version 1.49 in Wheezy and up)
Author: Peter Schaefer <peter.schaefer@gmx.de>
Debian-Bug: https://bugs.debian.org/734805
Last-Update: 2014-06-04

--- a/src/main.cpp	2014-01-09 23:38:56.234110557 +0100
+++ b/src/main.cpp	2014-01-09 23:38:18.610108525 +0100
@@ -38,6 +38,8 @@
 #include <cassert>
 #include <vector>
 #include <iostream>
+#include <sstream>
+#include <iomanip>
 
 #include <boost/filesystem/path.hpp>
 #include <boost/filesystem/operations.hpp>
@@ -71,6 +73,7 @@
   fs::path pathInFileName;
   fs::path pathOutFileName;
   fs::path pathOutDirectory;
+  stringstream ssFilename;
 
   CCmdLineProcessor proc(argv, argc);
 
@@ -116,7 +119,6 @@
     {
       COutputFilter *pOut = NULL;
       CSffFile      *pInfile = NULL;
-      char           acNumber[10];
 
       try
       {
@@ -172,32 +174,32 @@
             if (pathOutFileName.string().length()) {
               // A fixed name was given, so use it as a base name
               outPath = pathOutFileName;
-              std::string orgExt = fs::extension(outPath);
+              std::string orgExt = outPath.extension().generic_string();
               if (nFileCountOut > 1) {
-                sprintf(acNumber, "_%03d", nPage+1);
-                outPath = fs::change_extension(outPath, acNumber);
-                if (orgExt.length()) {
-                  std::string strTemp = outPath.string();
-                  strTemp += orgExt;
-                  outPath = fs::path(strTemp);
-                }
+                outPath.replace_extension("");
+                ssFilename << outPath.generic_string();
+                ssFilename << "_" << setw(3) << setfill('0') << nPage+1;
+                ssFilename << orgExt;
+                outPath = fs::path(ssFilename.str());
               }
             } else {
               // Otherwise construct output filename from input filename
-              outPath = pathOutDirectory / pathInFileName.leaf();
+              outPath = pathOutDirectory / pathInFileName.filename();
               if (nFileCountOut > 1) {
-                sprintf(acNumber, "_%03d", nPage+1);
-                outPath = fs::change_extension(outPath, acNumber);
-                std::string strTemp = outPath.string();
-                strTemp += pOut->GetExtension();
-                outPath = fs::path(strTemp);
+                outPath.replace_extension("");
+                ssFilename << outPath.generic_string();
+                ssFilename << "_" << setw(3) << setfill('0') << nPage+1;
+                ssFilename << pOut->GetExtension();
+                outPath = fs::path(ssFilename.str());
               } else {
-                outPath = fs::change_extension(outPath, pOut->GetExtension());
+                outPath.replace_extension(pOut->GetExtension());
               }
             }
             if (!proc.doOverwrite() && !((nPage > 0) && (nFileCountOut == 1)) && fs::exists(outPath)) {
               throw CSimpleException(CSimpleException::err_outfileexists);
             }
+            ssFilename.str("");
+            ssFilename.clear();
           }
 
           bool bIsLowRes = pInfile->IsLowRes(nPage);
