Fix g++ 4.3 issues; add missing <cstring> includes, remove storage class on explicit...
[synfig.git] / synfig-core / trunk / src / tool / main.cpp
index 412a5ba..66efb3c 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -34,6 +35,7 @@
 #include <list>
 #include <ETL/clock>
 #include <algorithm>
+#include <cstring>
 
 #include <synfig/loadcanvas.h>
 #include <synfig/savecanvas.h>
@@ -56,18 +58,21 @@ using namespace synfig;
 
 /* === M A C R O S ========================================================= */
 
+#undef _
+#define _(x) gettext(x)
+
 enum exit_code
 {
-       SYNFIGTOOL_OK                           =0,
-       SYNFIGTOOL_FILENOTFOUND         =1,
-       SYNFIGTOOL_BORRED                       =2,
-       SYNFIGTOOL_HELP                         =3,
-       SYNFIGTOOL_UNKNOWNARGUMENT      =4,
-       SYNFIGTOOL_UNKNOWNERROR         =5,
-       SYNFIGTOOL_INVALIDTARGET                =6,
-       SYNFIGTOOL_RENDERFAILURE                =7,
-       SYNFIGTOOL_BLANK                                =8,
-       SYNFIGTOOL_BADVERSION           =9,
+       SYNFIGTOOL_OK                           = 0,
+       SYNFIGTOOL_FILENOTFOUND         = 1,
+       SYNFIGTOOL_BORED                        = 2,
+       SYNFIGTOOL_HELP                         = 3,
+       SYNFIGTOOL_UNKNOWNARGUMENT      = 4,
+       SYNFIGTOOL_UNKNOWNERROR         = 5,
+       SYNFIGTOOL_INVALIDTARGET        6,
+       SYNFIGTOOL_RENDERFAILURE        7,
+       SYNFIGTOOL_BLANK                        8,
+       SYNFIGTOOL_BADVERSION           = 9,
        SYNFIGTOOL_MISSINGARGUMENT      =10
 };
 
@@ -122,7 +127,7 @@ public:
        }
 
        virtual bool
-       amount_complete(int current, int total)
+       amount_complete(int /*current*/, int /*total*/)
        {
                return true;
        }
@@ -682,10 +687,10 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
                else if(*iter=="-g")
                {
                        synfig::warning("Gamma argument is currently ignored");
-                       //arg_list.erase(iter);
-                       //iter=next++;
+                       arg_list.erase(iter);
+                       iter=next++;
                        //desc.set_gamma(Gamma(atof(iter->c_str())));
-                       //arg_list.erase(iter);
+                       arg_list.erase(iter);
                }
        }
        if(w&&h)
@@ -835,6 +840,10 @@ int main(int argc, char *argv[])
        arg_list_t arg_list;
        job_list_t job_list;
 
+       setlocale(LC_ALL, "");
+       bindtextdomain("synfig", LOCALEDIR);
+       textdomain("synfig");
+
        progname=argv[0];
        Progress p(argv[0]);
 
@@ -955,19 +964,15 @@ int main(int argc, char *argv[])
                        // If the target type is not yet defined,
                        // try to figure it out from the outfile.
                        if(target_name.empty() && !job_list.front().outfilename.empty())
-                       try
                        {
                                VERBOSE_OUT(3)<<_("Target name undefined, attempting to figure it out")<<endl;
-                               string ext=string(find(job_list.front().outfilename.begin(),job_list.front().outfilename.end(),'.')+1,job_list.front().outfilename.end());
+                               string ext = filename_extension(job_list.front().outfilename);
+                               if (ext.length()) ext = ext.substr(1);
                                if(Target::ext_book().count(ext))
                                        target_name=Target::ext_book()[ext];
                                else
                                        target_name=ext;
                        }
-                       catch(std::length_error)
-                       {
-                               synfig::warning("Length error caught when attempting to figure out target name");
-                       }
 
                        // If the target type is STILL not yet defined, then
                        // set it to a some sort of default
@@ -982,9 +987,7 @@ int main(int argc, char *argv[])
                        // given input filename. (ie: change the extension)
                        if(job_list.front().outfilename.empty())
                        {
-                               job_list.front().outfilename=job_list.front().filename;
-                               job_list.front().outfilename.erase(find(job_list.front().outfilename.begin(),job_list.front().outfilename.end(),'.'),job_list.front().outfilename.end());
-                               job_list.front().outfilename+='.';
+                               job_list.front().outfilename = filename_sans_extension(job_list.front().filename) + '.';
                                if(Target::book().count(target_name))
                                        job_list.front().outfilename+=Target::book()[target_name].second;
                                else
@@ -1055,7 +1058,7 @@ int main(int argc, char *argv[])
        if(!job_list.size())
        {
                cerr<<_("Nothing to do!")<<endl;
-               return SYNFIGTOOL_BORRED;
+               return SYNFIGTOOL_BORED;
        }
 
        for(;job_list.size();job_list.pop_front())