diff src/context.cpp @ 21:09564d4acd9e stable-1-0-8

patches from Marco d'Itri for postfix
author Carl Byington <carl@five-ten-sg.com>
date Fri, 24 Dec 2010 15:13:18 -0800
parents b24369330483
children
line wrap: on
line diff
--- a/src/context.cpp	Thu Jun 12 18:19:42 2008 -0700
+++ b/src/context.cpp	Fri Dec 24 15:13:18 2010 -0800
@@ -33,15 +33,13 @@
 bool CONFIG::find(const char *needle, string_set &haystack) {
 	string_set::iterator i = haystack.find(needle);
 	if (i != haystack.end()) return true;		   // found user@domain.tld key
-	char *x = strchr(needle, '@');
+	const char *x = strchr(needle, '@');
 	if (x) {
 		x++;
 		i = haystack.find(x);
 		if (i != haystack.end()) return true;	   // found domain.tld key
-		char y = *x;
-		*x = '\0';
-		i = haystack.find(needle);
-		*x = y;
+		string userpart(needle, x-needle);
+		i = haystack.find(userpart.c_str());
 		if (i != haystack.end()) return true;	   // found user@ key
 	}
 	return false;
@@ -51,15 +49,13 @@
 const char *CONFIG::find(const char *needle, string_map &haystack) {
 	string_map::iterator i = haystack.find(needle);
 	if (i != haystack.end()) return (*i).second;		// found user@domain.tld key
-	char *x = strchr(needle, '@');
+	const char *x = strchr(needle, '@');
 	if (x) {
 		x++;
 		i = haystack.find(x);
 		if (i != haystack.end()) return (*i).second;	// found domain.tld key
-		char y = *x;
-		*x = '\0';
-		i = haystack.find(needle);
-		*x = y;
+		string userpart(needle, x-needle);
+		i = haystack.find(userpart.c_str());
 		if (i != haystack.end()) return (*i).second;	// found user@ key
 	}
 	return NULL;