Skip to content

Commit 7e43f8f

Browse files
Daniel Pattersonbrson
authored andcommitted
std::net::url - change alt to match, ret to return, as per recent syntax changes
1 parent 64eb497 commit 7e43f8f

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/libstd/net_url.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn encode_inner(s: ~str, full_url: bool) -> ~str {
4747

4848
while !rdr.eof() {
4949
let ch = rdr.read_byte() as char;
50-
alt ch {
50+
match ch {
5151
// unreserved:
5252
'A' to 'Z' |
5353
'a' to 'z' |
@@ -57,7 +57,7 @@ fn encode_inner(s: ~str, full_url: bool) -> ~str {
5757
}
5858
_ {
5959
if full_url {
60-
alt ch {
60+
match ch {
6161
// gen-delims:
6262
':' | '/' | '?' | '#' | '[' | ']' | '@' |
6363

@@ -105,14 +105,14 @@ fn decode_inner(s: ~str, full_url: bool) -> ~str {
105105
let mut out = ~"";
106106

107107
while !rdr.eof() {
108-
alt rdr.read_char() {
108+
match rdr.read_char() {
109109
'%' {
110110
let bytes = rdr.read_bytes(2u);
111111
let ch = uint::parse_buf(bytes, 16u).get() as char;
112112

113113
if full_url {
114114
// Only decode some characters:
115-
alt ch {
115+
match ch {
116116
// gen-delims:
117117
':' | '/' | '?' | '#' | '[' | ']' | '@' |
118118

@@ -160,7 +160,7 @@ fn encode_plus(s: ~str) -> ~str {
160160

161161
while !rdr.eof() {
162162
let ch = rdr.read_byte() as char;
163-
alt ch {
163+
match ch {
164164
'A' to 'Z' | 'a' to 'z' | '0' to '9' | '_' | '.' | '-' {
165165
str::push_char(out, ch);
166166
}
@@ -211,10 +211,10 @@ fn decode_form_urlencoded(s: ~[u8]) ->
211211
let mut parsing_key = true;
212212

213213
while !rdr.eof() {
214-
alt rdr.read_char() {
214+
match rdr.read_char() {
215215
'&' | ';' {
216216
if key != ~"" && value != ~"" {
217-
let values = alt m.find(key) {
217+
let values = match m.find(key) {
218218
some(values) { values }
219219
none {
220220
let values = @dvec();
@@ -231,7 +231,7 @@ fn decode_form_urlencoded(s: ~[u8]) ->
231231
}
232232
'=' { parsing_key = false; }
233233
ch {
234-
let ch = alt ch {
234+
let ch = match ch {
235235
'%' {
236236
uint::parse_buf(rdr.read_bytes(2u), 16u).get() as char
237237
}
@@ -249,7 +249,7 @@ fn decode_form_urlencoded(s: ~[u8]) ->
249249
}
250250

251251
if key != ~"" && value != ~"" {
252-
let values = alt m.find(key) {
252+
let values = match m.find(key) {
253253
some(values) { values }
254254
none {
255255
let values = @dvec();
@@ -268,24 +268,24 @@ fn decode_form_urlencoded(s: ~[u8]) ->
268268
fn split_char_first(s: ~str, c: char) -> (~str, ~str) {
269269
let len = str::len(s);
270270
let mut index = len;
271-
let mut match_ = 0;
271+
let mut mat = 0;
272272
do io::with_str_reader(s) |rdr| {
273273
let mut ch : char;
274274
while !rdr.eof() {
275275
ch = rdr.read_byte() as char;
276276
if ch == c {
277277
// found a match, adjust markers
278278
index = rdr.tell()-1;
279-
match_ = 1;
279+
mat = 1;
280280
break;
281281
}
282282
}
283283
}
284-
if index+match_ == len {
284+
if index+mat == len {
285285
return (str::slice(s, 0, index), ~"");
286286
} else {
287287
return (str::slice(s, 0, index),
288-
str::slice(s, index + match_, str::len(s)));
288+
str::slice(s, index + mat, str::len(s)));
289289
}
290290
}
291291

@@ -332,7 +332,7 @@ fn query_to_str(query: query) -> ~str {
332332
// returns the scheme and the rest of the url, or a parsing error
333333
fn get_scheme(rawurl: ~str) -> result::result<(~str, ~str), @~str> {
334334
for str::each_chari(rawurl) |i,c| {
335-
alt c {
335+
match c {
336336
'A' to 'Z' | 'a' to 'z' { again; }
337337
'0' to '9' | '+' | '-' | '.' {
338338
if i == 0 {
@@ -392,7 +392,7 @@ fn get_authority(rawurl: ~str) ->
392392
if i < 2 { again; } // ignore the leading //
393393

394394
// deal with input class first
395-
alt c {
395+
match c {
396396
'0' to '9' { }
397397
'A' to 'F' | 'a' to 'f' {
398398
if in == digit {
@@ -412,10 +412,10 @@ fn get_authority(rawurl: ~str) ->
412412
}
413413
414414
// now process states
415-
alt c {
415+
match c {
416416
':' {
417417
colon_count += 1;
418-
alt st {
418+
match st {
419419
start {
420420
pos = i;
421421
st = pass_host_port;
@@ -458,7 +458,7 @@ fn get_authority(rawurl: ~str) ->
458458
'@' {
459459
in = digit; // reset input class
460460
colon_count = 0; // reset count
461-
alt st {
461+
match st {
462462
start {
463463
let user = str::slice(rawurl, begin, i);
464464
userinfo = option::some({user : user,
@@ -489,7 +489,7 @@ fn get_authority(rawurl: ~str) ->
489489
}
490490
491491
// finish up
492-
alt st {
492+
match st {
493493
start {
494494
if end+1 == len {
495495
host = str::slice(rawurl, begin, end+1);
@@ -527,7 +527,7 @@ fn get_path(rawurl: ~str, authority : bool) ->
527527
let len = str::len(rawurl);
528528
let mut end = len;
529529
for str::each_chari(rawurl) |i,c| {
530-
alt c {
530+
match c {
531531
'A' to 'Z' | 'a' to 'z' | '0' to '9' | '&' |'\'' | '(' | ')' | '.'
532532
| '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '=' {
533533
again;
@@ -657,11 +657,11 @@ fn to_str(url: url) -> ~str {
657657
};
658658
659659
return str::concat(~[copy url.scheme,
660-
~":",
661-
authority,
662-
copy url.path,
663-
query,
664-
fragment]);
660+
~":",
661+
authority,
662+
copy url.path,
663+
query,
664+
fragment]);
665665
}
666666
667667
impl of to_str::to_str for url {

0 commit comments

Comments
 (0)