faubackup2/src/regexp regexp.cpp,1.2,1.3

Erik Merkel <[email protected]> Thu, 09 Jun 2005 16:12:43 +0000
Newsgroups gmane.comp.sysutils.backup.faubackup.cvs
Message-ID <[email protected]>
Update of /cvsroot/faubackup/faubackup2/src/regexp
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22404/src/regexp

Modified Files:
	regexp.cpp 
Log Message:
allow alternate syntax for filter times without year


Index: regexp.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/regexp/regexp.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** regexp.cpp	8 Jun 2005 19:29:05 -0000	1.2
--- regexp.cpp	9 Jun 2005 16:12:41 -0000	1.3
***************
*** 199,203 ****
  	if(boost::regex_match(String.begin(), String.end(), what, expression, boost::match_default)) {
  		list.push_back(getTimeStamp(String));
! 	} else {
  		static const boost::regex replace_expression_first("([\\*-/\\d\\s\\w]+),[\\*-,/\\d\\s\\w]+");
  		static const boost::regex replace_expression_remain("[\\*-/\\d\\s\\w]+,([\\*-,/\\d\\s\\w]+)");
--- 199,204 ----
  	if(boost::regex_match(String.begin(), String.end(), what, expression, boost::match_default)) {
  		list.push_back(getTimeStamp(String));
! 	}
! 	else {
  		static const boost::regex replace_expression_first("([\\*-/\\d\\s\\w]+),[\\*-,/\\d\\s\\w]+");
  		static const boost::regex replace_expression_remain("[\\*-/\\d\\s\\w]+,([\\*-,/\\d\\s\\w]+)");
***************
*** 239,243 ****
  		stamp.year_end = 2000 + atoi(what[2].str().c_str());
  		stamp.year_mod = 1;
! 	} else if(what[3] == "*")
  	{
  		stamp.year_begin = -1;
--- 240,245 ----
  		stamp.year_end = 2000 + atoi(what[2].str().c_str());
  		stamp.year_mod = 1;
! 	}
! 	else if(what[3] == "*")
  	{
  		stamp.year_begin = -1;
***************
*** 247,251 ****
  		else
  			stamp.year_mod = 1;
! 	} else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.year_begin = 2000 + atoi(what[6].str().c_str());
--- 249,254 ----
  		else
  			stamp.year_mod = 1;
! 	}
! 	else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.year_begin = 2000 + atoi(what[6].str().c_str());
***************
*** 299,303 ****
  		stamp.month_end = atoi(what[2].str().c_str());
  		stamp.month_mod = 1;
! 	} else if(what[3] == "*")
  	{
  		stamp.month_begin = -1;
--- 302,307 ----
  		stamp.month_end = atoi(what[2].str().c_str());
  		stamp.month_mod = 1;
! 	}
! 	else if(what[3] == "*")
  	{
  		stamp.month_begin = -1;
***************
*** 307,311 ****
  		else
  			stamp.month_mod = 1;
! 	} else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.month_begin = atoi(what[6].str().c_str());
--- 311,316 ----
  		else
  			stamp.month_mod = 1;
! 	}
! 	else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.month_begin = atoi(what[6].str().c_str());
***************
*** 352,356 ****
  		stamp.day_end = atoi(what[2].str().c_str());
  		stamp.day_mod = 1;
! 	} else if(what[3] == "*")
  	{
  		stamp.day_begin = -1;
--- 357,362 ----
  		stamp.day_end = atoi(what[2].str().c_str());
  		stamp.day_mod = 1;
! 	}
! 	else if(what[3] == "*")
  	{
  		stamp.day_begin = -1;
***************
*** 360,364 ****
  		else
  			stamp.day_mod = 1;
! 	} else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.day_begin = atoi(what[6].str().c_str());
--- 366,371 ----
  		else
  			stamp.day_mod = 1;
! 	}
! 	else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.day_begin = atoi(what[6].str().c_str());
***************
*** 416,420 ****
  		stamp.weekday_end = atoi(what[2].str().c_str());
  		stamp.weekday_mod = 1;
! 	} else if(what[3] == "*")
  	{
  		stamp.weekday_begin = -1;
--- 423,428 ----
  		stamp.weekday_end = atoi(what[2].str().c_str());
  		stamp.weekday_mod = 1;
! 	}
! 	else if(what[3] == "*")
  	{
  		stamp.weekday_begin = -1;
***************
*** 424,428 ****
  		else
  			stamp.weekday_mod = 1;
! 	} else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.weekday_begin = atoi(what[6].str().c_str());
--- 432,437 ----
  		else
  			stamp.weekday_mod = 1;
! 	}
! 	else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.weekday_begin = atoi(what[6].str().c_str());
***************
*** 468,472 ****
  		stamp.hour_end = atoi(what[2].str().c_str());
  		stamp.hour_mod = 1;
! 	} else if(what[3] == "*")
  	{
  		stamp.hour_begin = -1;
--- 477,482 ----
  		stamp.hour_end = atoi(what[2].str().c_str());
  		stamp.hour_mod = 1;
! 	}
! 	else if(what[3] == "*")
  	{
  		stamp.hour_begin = -1;
***************
*** 476,480 ****
  		else
  			stamp.hour_mod = 1;
! 	} else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.hour_begin = atoi(what[6].str().c_str());
--- 486,491 ----
  		else
  			stamp.hour_mod = 1;
! 	}
! 	else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.hour_begin = atoi(what[6].str().c_str());
***************
*** 518,522 ****
  		stamp.minute_end = atoi(what[2].str().c_str());
  		stamp.minute_mod = 1;
! 	} else if(what[3] == "*")
  	{
  		stamp.minute_begin = -1;
--- 529,534 ----
  		stamp.minute_end = atoi(what[2].str().c_str());
  		stamp.minute_mod = 1;
! 	}
! 	else if(what[3] == "*")
  	{
  		stamp.minute_begin = -1;
***************
*** 526,530 ****
  		else
  			stamp.minute_mod = 1;
! 	} else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.minute_begin = atoi(what[6].str().c_str());
--- 538,543 ----
  		else
  			stamp.minute_mod = 1;
! 	}
! 	else if((what[6] != "") && (what[7] != ""))
  	{
  		stamp.minute_begin = atoi(what[6].str().c_str());
***************
*** 559,574 ****
  	        "([\\*-/\\d\\s\\w]+$)"//minute
  	);
  	struct TimeStamp2 time;
  	boost::match_results<string::iterator> what;
  
! 	if(!boost::regex_search(String.begin(), String.end(), what, expression,
! 	                        boost::match_default | boost::format_all))
  		throw -1;
- 	getTimeStamp_year(what[1], time);
- 	getTimeStamp_month(what[2], time);
- 	getTimeStamp_day(what[3], time);
- 	getTimeStamp_weekday(what[4], time);
- 	getTimeStamp_hour(what[5], time);
- 	getTimeStamp_minute(what[6], time);
  	return time;
  }
--- 572,614 ----
  	        "([\\*-/\\d\\s\\w]+$)"//minute
  	);
+ 
+ 	static const boost::regex expression_without_year(
+ 	        "[\\s]*" //trailing spaces
+ 	        "([\\*-/\\d\\s\\w]+:)" //month
+ 	        "([\\*-/\\d\\s\\w]+:)" //day of month
+ 	        "([\\*-/\\d\\s\\w]+:)" //day of week
+ 	        "([\\*-/\\d\\s\\w]+:)" //hour
+ 	        "([\\*-/\\d\\s\\w]+$)"//minute
+ 	);
+ 
  	struct TimeStamp2 time;
  	boost::match_results<string::iterator> what;
  
! 	if(boost::regex_search(String.begin(), String.end(), what, expression,
! 	                       boost::match_default | boost::format_all))
! 	{
! 		getTimeStamp_year(what[1], time);
! 		getTimeStamp_month(what[2], time);
! 		getTimeStamp_day(what[3], time);
! 		getTimeStamp_weekday(what[4], time);
! 		getTimeStamp_hour(what[5], time);
! 		getTimeStamp_minute(what[6], time);
! 	}
! 	else if(boost::regex_search(String.begin(), String.end(), what,
! 	                            expression_without_year,
! 	                            boost::match_default | boost::format_all))
! 	{
! 		/* ignore year */
! 		time.year_begin = -1;
! 		time.year_end = -1;
! 		time.year_mod = 1;
! 		getTimeStamp_month(what[1], time);
! 		getTimeStamp_day(what[2], time);
! 		getTimeStamp_weekday(what[3], time);
! 		getTimeStamp_hour(what[4], time);
! 		getTimeStamp_minute(what[5], time);
! 	}
! 	else
  		throw -1;
  	return time;
  }



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20