From: Diego Barrios Romero Date: Sat, 20 Feb 2010 15:34:31 +0000 (+0100) Subject: Proper parameter processing. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ac82dc73a5ed08bd695c70a3ac70caaa3e546302;p=synfig.git Proper parameter processing. --- diff --git a/synfig-core/src/tool/main.cpp b/synfig-core/src/tool/main.cpp index 38aa168..37f535b 100644 --- a/synfig-core/src/tool/main.cpp +++ b/synfig-core/src/tool/main.cpp @@ -167,9 +167,9 @@ void display_help(bool full) int process_global_flags(arg_list_t &arg_list) { - arg_list_t::iterator iter; + arg_list_t::iterator iter, next; - for(iter=arg_list.begin();iter!=arg_list.end();iter++) + for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++) { if(*iter == "--") return SYNFIGTOOL_OK; @@ -229,7 +229,7 @@ int process_global_flags(arg_list_t &arg_list) { Progress p(PACKAGE); synfig::Main synfig_main(dirname(progname),&p); - iter++; + iter=next++; if (iter==arg_list.end()) { error("The `%s' flag requires a value. Use --help for a list of options.", "--layer-info"); @@ -353,9 +353,9 @@ bool flag_requires_value(String flag) int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster) { - arg_list_t::iterator iter; + arg_list_t::iterator iter, next; - for(iter=arg_list.begin();iter!=arg_list.end();iter++) + for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++) { if(*iter->begin() != '-') { @@ -367,7 +367,7 @@ int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster) { cluster.push_back(*iter); arg_list.erase(iter); - 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()); @@ -387,13 +387,15 @@ int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster) * \param arg_list Argument list from wich the parameter is extracted. * \param iter Iterator pointing to the argument list parameter to be * extracted. + * \param next Iterator pointing to the next argument. */ string extract_parameter (arg_list_t& arg_list, - arg_list_t::iterator& iter) + arg_list_t::iterator& iter, + arg_list_t::iterator& next) { string parameter; arg_list.erase(iter); - iter++; + iter = next++; parameter = *iter; arg_list.erase(iter); return parameter; @@ -401,78 +403,78 @@ string extract_parameter (arg_list_t& arg_list, int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc) { - arg_list_t::iterator iter; + arg_list_t::iterator iter, next; int w=0,h=0; float span=0; - for(iter=arg_list.begin(); iter!=arg_list.end(); iter++) + for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++) { if(*iter=="-w") { - w = atoi(extract_parameter(arg_list, iter).c_str()); + w = atoi(extract_parameter(arg_list, iter, next).c_str()); } else if(*iter=="-h") { - h = atoi(extract_parameter(arg_list, iter).c_str()); + h = atoi(extract_parameter(arg_list, iter, next).c_str()); } else if(*iter=="-a") { int a; - a = atoi(extract_parameter(arg_list, iter).c_str()); + a = atoi(extract_parameter(arg_list, iter, next).c_str()); desc.set_antialias(a); VERBOSE_OUT(1)<