String split renaming:

* Renamed str::split -> str::split_byte
* Renamed str::splitn -> str::splitn_byte
* Renamed str::split_func -> str::split
* Renamed str::split_char -> str::split_char
* Renamed str::split_chars_iter -> str::split_char_iter
* Added u8::is_ascii
* Fixed the behavior of str::split_str, so that it matches split_chars
  and split (i.e. ["", "XXX", "YYY", ""] == split_str(".XXX.YYY.", "."))
* Fixed str::split_byte and str::splitn_byte so that they handle
  splitting UTF-8 strings on a given UTF-8/ASCII byte and also handle ""
  as the others do
This commit is contained in:
Kevin Cantu
2012-02-01 20:31:01 -08:00
committed by Brian Anderson
parent 159aebc28b
commit a3f5626ad1
10 changed files with 189 additions and 141 deletions

View File

@@ -49,7 +49,8 @@ Failure:
String must be a valid IPv4 address
*/
fn parse_addr(ip: str) -> ip_addr {
let parts = vec::map(str::split(ip, "."[0]), {|s| uint::from_str(s) });
let parts = vec::map(str::split_byte(ip, "."[0]),
{|s| uint::from_str(s) });
if vec::len(parts) != 4u { fail "Too many dots in IP address"; }
for i in parts { if i > 255u { fail "Invalid IP Address part."; } }
ipv4(parts[0] as u8, parts[1] as u8, parts[2] as u8, parts[3] as u8)