A quick fix for the mysterious non working isnan on macosx builds.
[synfig.git] / synfig-core / trunk / src / tool / main.cpp
index c7120de..c37a2b7 100644 (file)
@@ -5,16 +5,17 @@
 **     $Id: main.cpp,v 1.9 2005/01/23 04:41:10 darco Exp $
 **
 **     \legal
-**     Copyright (c) 2002 Robert B. Quattlebaum Jr.
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **
-**     This software and associated documentation
-**     are CONFIDENTIAL and PROPRIETARY property of
-**     the above-mentioned copyright holder.
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
 **
-**     You may not copy, print, publish, or in any
-**     other way distribute this software without
-**     a prior written agreement with
-**     the copyright holder.
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
 **     \endlegal
 */
 /* ========================================================================= */
@@ -66,7 +67,8 @@ enum exit_code
        SYNFIGTOOL_INVALIDTARGET                =6,     
        SYNFIGTOOL_RENDERFAILURE                =7,     
        SYNFIGTOOL_BLANK                                =8,
-       SYNFIGTOOL_BADVERSION           =9
+       SYNFIGTOOL_BADVERSION           =9,
+       SYNFIGTOOL_MISSINGARGUMENT      =10
 };
 
 #ifndef VERSION
@@ -484,14 +486,12 @@ int process_global_flags(arg_list_t &arg_list)
                        cerr<<PACKAGE<<" "<<VERSION<<endl;
                        cout<<SYNFIG_COPYRIGHT<<endl<<endl;
                        cerr<<"\
-**     This software and associated documentation\n\
-**     are CONFIDENTIAL and PROPRIETARY property of\n\
-**     the above-mentioned copyright holder.\n\
+**     This package is free software; you can redistribute it and/or\n\
+**     modify it under the terms of the GNU General Public License as\n\
+**     published by the Free Software Foundation; either version 2 of\n\
+**     the License, or (at your option) any later version.\n\
 **\n\
-**     You may not use, copy, print, publish, or in\n\
-**     any other way distribute or exploit this software\n\
-**     without a prior written agreement with the\n\
-**     copyright holder. " << endl << endl;    
+**     " << endl << endl;      
                        arg_list.erase(iter);
                        
                        return SYNFIGTOOL_HELP;
@@ -566,6 +566,10 @@ int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster)
                        cluster.push_back(*iter);
                        arg_list.erase(iter);
                        iter=next++;
+                       if (iter==arg_list.end()) {
+                               error("The `%s' flag requires a value.  Use --help for a list of options.", cluster.back().c_str());
+                               return SYNFIGTOOL_MISSINGARGUMENT;
+                       }
                }
                        
                cluster.push_back(*iter);
@@ -589,14 +593,14 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
                        w=atoi(iter->c_str());
                        arg_list.erase(iter);
                }
-               if(*iter=="-h")
+               else if(*iter=="-h")
                {
                        arg_list.erase(iter);
                        iter=next++;
                        h=atoi(iter->c_str());
                        arg_list.erase(iter);
                }
-               if(*iter=="-a")
+               else if(*iter=="-a")
                {
             int a;
                        arg_list.erase(iter);
@@ -606,7 +610,7 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
                        VERBOSE_OUT(1)<<strprintf(_("Antialiasing set to %d, (%d samples per pixel)"),a,a*a)<<endl;
                        arg_list.erase(iter);
                }
-               if(*iter=="-s")
+               else if(*iter=="-s")
                {
                        arg_list.erase(iter);
                        iter=next++;
@@ -614,7 +618,7 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
                        VERBOSE_OUT(1)<<strprintf(_("Span set to %d units"),span)<<endl;
                        arg_list.erase(iter);
                }
-               if(*iter=="--fps")
+               else if(*iter=="--fps")
                {
                        arg_list.erase(iter);
                        iter=next++;
@@ -623,7 +627,7 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
                        arg_list.erase(iter);
                        VERBOSE_OUT(1)<<strprintf(_("Frame rate set to %d frames per second"),fps)<<endl;
                }
-               if(*iter=="--dpi")
+               else if(*iter=="--dpi")
                {
                        arg_list.erase(iter);
                        iter=next++;
@@ -633,7 +637,7 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
                        arg_list.erase(iter);
                        VERBOSE_OUT(1)<<strprintf(_("Physical resolution set to %f dpi"),dpi)<<endl;
                }
-               if(*iter=="--dpi-x")
+               else if(*iter=="--dpi-x")
                {
                        arg_list.erase(iter);
                        iter=next++;
@@ -643,7 +647,7 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
                        arg_list.erase(iter);
                        VERBOSE_OUT(1)<<strprintf(_("Physical X resolution set to %f dpi"),dpi)<<endl;
                }
-               if(*iter=="--dpi-y")
+               else if(*iter=="--dpi-y")
                {
                        arg_list.erase(iter);
                        iter=next++;
@@ -653,21 +657,21 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
                        arg_list.erase(iter);
                        VERBOSE_OUT(1)<<strprintf(_("Physical Y resolution set to %f dpi"),dpi)<<endl;
                }
-               if(*iter=="--start-time" || *iter=="--begin-time")
+               else if(*iter=="--start-time" || *iter=="--begin-time")
                {
                        arg_list.erase(iter);
                        iter=next++;
                        desc.set_time_start(Time(*iter,desc.get_frame_rate()));
                        arg_list.erase(iter);
                }
-               if(*iter=="--end-time")
+               else if(*iter=="--end-time")
                {
                        arg_list.erase(iter);
                        iter=next++;
                        desc.set_time_end(Time(*iter,desc.get_frame_rate()));
                        arg_list.erase(iter);
                }
-               if(*iter=="--time")
+               else if(*iter=="--time")
                {
                        arg_list.erase(iter);
                        iter=next++;
@@ -675,7 +679,7 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
                        VERBOSE_OUT(1)<<_("Rendering frame at ")<<desc.get_time_start().get_string(desc.get_frame_rate())<<endl;
                        arg_list.erase(iter);
                }
-               if(*iter=="-g")
+               else if(*iter=="-g")
                {
                        synfig::warning("Gamma argument is currently ignored");
                        //arg_list.erase(iter);
@@ -856,9 +860,11 @@ int main(int argc, char *argv[])
        
        {
                arg_list_t defaults, imageargs;
+               int ret;
                
                // Grab the defaults before the first file
-               extract_arg_cluster(arg_list,defaults);
+               if ((ret = extract_arg_cluster(arg_list,defaults)) != SYNFIGTOOL_OK)
+                 return ret;
                
                while(arg_list.size())
                {
@@ -870,7 +876,8 @@ int main(int argc, char *argv[])
                        job_list.front().filename=arg_list.front();
                        arg_list.pop_front();
 
-                       extract_arg_cluster(arg_list,imageargs);                        
+                       if ((ret = extract_arg_cluster(arg_list,imageargs)) != SYNFIGTOOL_OK)
+                         return ret;
                        
                        // Open the composition
                        {