Changeset 928
- Timestamp:
- 12/14/06 21:38:39 (2 years ago)
- Files:
-
- trunk/pdns/pdns/misc.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pdns/pdns/misc.cc
r924 r928 42 42 #include "ahuexception.hh" 43 43 #include <sys/types.h> 44 45 46 44 #include "utility.hh" 47 45 … … 95 93 96 94 /** Chops off the start of a domain, so goes from 'www.ds9a.nl' to 'ds9a.nl' to 'nl' to ''. Return zero on the empty string */ 97 bool chopOff(string &domain) 95 bool chopOff(string &domain) 98 96 { 99 97 if(domain.empty()) … … 104 102 if(fdot==string::npos) 105 103 domain=""; 106 else 107 domain=domain.substr(fdot+1); 104 else { 105 string::size_type remain = domain.length() - (fdot + 1); 106 char tmp[remain]; 107 memcpy(tmp, domain.c_str()+fdot+1, remain); 108 domain.assign(tmp, remain); // don't dare to do this w/o tmp holder :-) 109 } 108 110 return true; 109 111 } … … 121 123 if(fdot==domain.size()-1) 122 124 domain="."; 123 else 124 domain=domain.substr(fdot+1); 125 else { 126 string::size_type remain = domain.length() - (fdot + 1); 127 char tmp[remain]; 128 memcpy(tmp, domain.c_str()+fdot+1, remain); 129 domain.assign(tmp, remain); 130 } 125 131 return true; 126 132 }