Skip to content

Commit ea41c02

Browse files
drbawblifthrasiir
authored andcommitted
Ranges must use ... instead of ..
1 parent 1d26487 commit ea41c02

5 files changed

Lines changed: 52 additions & 52 deletions

File tree

src/encoding/codec/japanese.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ impl Encoder for EUCJPEncoder {
5050

5151
for ((i,j), ch) in input.index_iter() {
5252
match ch {
53-
'\u0000'..'\u007f' => { output.write_byte(ch as u8); }
53+
'\u0000'...'\u007f' => { output.write_byte(ch as u8); }
5454
'\u00a5' => { output.write_byte(0x5c); }
5555
'\u203e' => { output.write_byte(0x7e); }
56-
'\uff61'..'\uff9f' => {
56+
'\uff61'...'\uff9f' => {
5757
output.write_byte(0x8e);
5858
output.write_byte((ch as uint - 0xff61 + 0xa1) as u8);
5959
}
@@ -93,7 +93,7 @@ ascii_compatible_stateful_decoder! {
9393
let lead = lead as uint;
9494
let trail = trail as uint;
9595
let index = match (lead, trail) {
96-
(0xa1..0xfe, 0xa1..0xfe) => (lead - 0xa1) * 94 + trail - 0xa1,
96+
(0xa1...0xfe, 0xa1...0xfe) => (lead - 0xa1) * 94 + trail - 0xa1,
9797
_ => 0xffff,
9898
};
9999
index::jis0208::forward(index as u16)
@@ -105,39 +105,39 @@ ascii_compatible_stateful_decoder! {
105105
let lead = lead as uint;
106106
let trail = trail as uint;
107107
let index = match (lead, trail) {
108-
(0xa1..0xfe, 0xa1..0xfe) => (lead - 0xa1) * 94 + trail - 0xa1,
108+
(0xa1...0xfe, 0xa1...0xfe) => (lead - 0xa1) * 94 + trail - 0xa1,
109109
_ => 0xffff,
110110
};
111111
index::jis0212::forward(index as u16)
112112
}
113113

114114
// euc-jp lead = 0x00
115115
initial state S0(ctx) {
116-
case b @ 0x00..0x7f => ctx.emit(b as u32);
116+
case b @ 0x00...0x7f => ctx.emit(b as u32);
117117
case 0x8e => S1(ctx);
118118
case 0x8f => S2(ctx);
119-
case b @ 0xa1..0xfe => S3(ctx, b);
119+
case b @ 0xa1...0xfe => S3(ctx, b);
120120
case _ => ctx.err("invalid sequence");
121121
}
122122

123123
// euc-jp lead = 0x8e
124124
state S1(ctx) {
125-
case b @ 0xa1..0xdf => ctx.emit(0xff61 + b as u32 - 0xa1);
126-
case 0xa1..0xfe => ctx.err("invalid sequence");
125+
case b @ 0xa1...0xdf => ctx.emit(0xff61 + b as u32 - 0xa1);
126+
case 0xa1...0xfe => ctx.err("invalid sequence");
127127
case _ => ctx.backup_and_err(1, "invalid sequence");
128128
}
129129

130130
// euc-jp lead = 0x8f
131131
// JIS X 0201 half-width katakana
132132
state S2(ctx) {
133-
case b @ 0xa1..0xfe => S4(ctx, b);
133+
case b @ 0xa1...0xfe => S4(ctx, b);
134134
case _ => ctx.backup_and_err(1, "invalid sequence");
135135
}
136136

137137
// euc-jp lead != 0x00, euc-jp jis0212 flag = unset
138138
// JIS X 0208 two-byte sequence
139139
state S3(ctx, lead: u8) {
140-
case b @ 0xa1..0xfe => match map_two_0208_bytes(lead, b) {
140+
case b @ 0xa1...0xfe => match map_two_0208_bytes(lead, b) {
141141
// do NOT backup, we only backup for out-of-range trails.
142142
0xffff => ctx.err("invalid sequence"),
143143
ch => ctx.emit(ch as u32)
@@ -148,7 +148,7 @@ ascii_compatible_stateful_decoder! {
148148
// euc-jp lead != 0x00, euc-jp jis0212 flag = set
149149
// JIS X 0212 three-byte sequence
150150
state S4(ctx, lead: u8) {
151-
case b @ 0xa1..0xfe => match map_two_0212_bytes(lead, b) {
151+
case b @ 0xa1...0xfe => match map_two_0212_bytes(lead, b) {
152152
// do NOT backup, we only backup for out-of-range trails.
153153
0xffff => ctx.err("invalid sequence"),
154154
ch => ctx.emit(ch as u32)
@@ -443,10 +443,10 @@ impl Encoder for Windows31JEncoder {
443443

444444
for ((i,j), ch) in input.index_iter() {
445445
match ch {
446-
'\u0000'..'\u0080' => { output.write_byte(ch as u8); }
446+
'\u0000'...'\u0080' => { output.write_byte(ch as u8); }
447447
'\u00a5' => { output.write_byte(0x5c); }
448448
'\u203e' => { output.write_byte(0x7e); }
449-
'\uff61'..'\uff9f' => { output.write_byte((ch as uint - 0xff61 + 0xa1) as u8); }
449+
'\uff61'...'\uff9f' => { output.write_byte((ch as uint - 0xff61 + 0xa1) as u8); }
450450
_ => {
451451
// corresponds to the "index shift_jis pointer" in the WHATWG spec
452452
let ptr = index::jis0208::backward_remapped(ch as u32);
@@ -488,10 +488,10 @@ ascii_compatible_stateful_decoder! {
488488
let leadoffset = if lead < 0xa0 {0x81} else {0xc1};
489489
let trailoffset = if trail < 0x7f {0x40} else {0x41};
490490
let index = match (lead, trail) {
491-
(0xf0..0xf9, 0x40..0x7e) | (0xf0..0xf9, 0x80..0xfc) =>
491+
(0xf0...0xf9, 0x40...0x7e) | (0xf0...0xf9, 0x80...0xfc) =>
492492
return (0xe000 + (lead - 0xf0) * 188 + trail - trailoffset) as u32,
493-
(0x81..0x9f, 0x40..0x7e) | (0x81..0x9f, 0x80..0xfc) |
494-
(0xe0..0xfc, 0x40..0x7e) | (0xe0..0xfc, 0x80..0xfc) =>
493+
(0x81...0x9f, 0x40...0x7e) | (0x81...0x9f, 0x80...0xfc) |
494+
(0xe0...0xfc, 0x40...0x7e) | (0xe0...0xfc, 0x80...0xfc) =>
495495
(lead - leadoffset) * 188 + trail - trailoffset,
496496
_ => 0xffff,
497497
};
@@ -500,9 +500,9 @@ ascii_compatible_stateful_decoder! {
500500

501501
// shift_jis lead = 0x00
502502
initial state S0(ctx) {
503-
case b @ 0x00..0x80 => ctx.emit(b as u32);
504-
case b @ 0xa1..0xdf => ctx.emit(0xff61 + b as u32 - 0xa1);
505-
case b @ 0x81..0x9f | b @ 0xe0..0xfc => S1(ctx, b);
503+
case b @ 0x00...0x80 => ctx.emit(b as u32);
504+
case b @ 0xa1...0xdf => ctx.emit(0xff61 + b as u32 - 0xa1);
505+
case b @ 0x81...0x9f | b @ 0xe0...0xfc => S1(ctx, b);
506506
case _ => ctx.err("invalid sequence");
507507
}
508508

@@ -758,10 +758,10 @@ impl Encoder for ISO2022JPEncoder {
758758

759759
for ((i,j), ch) in input.index_iter() {
760760
match ch {
761-
'\u0000'..'\u007f' => { ensure_ASCII!(); output.write_byte(ch as u8); }
761+
'\u0000'...'\u007f' => { ensure_ASCII!(); output.write_byte(ch as u8); }
762762
'\u00a5' => { ensure_ASCII!(); output.write_byte(0x5c); }
763763
'\u203e' => { ensure_ASCII!(); output.write_byte(0x7e); }
764-
'\uff61'..'\uff9f' => {
764+
'\uff61'...'\uff9f' => {
765765
ensure_Katakana!();
766766
output.write_byte((ch as uint - 0xff61 + 0x21) as u8);
767767
}
@@ -807,7 +807,7 @@ stateful_decoder! {
807807
let lead = lead as uint;
808808
let trail = trail as uint;
809809
let index = match (lead, trail) {
810-
(0x21..0x7e, 0x21..0x7e) => (lead - 0x21) * 94 + trail - 0x21,
810+
(0x21...0x7e, 0x21...0x7e) => (lead - 0x21) * 94 + trail - 0x21,
811811
_ => 0xffff,
812812
};
813813
index::jis0208::forward(index as u16)
@@ -819,7 +819,7 @@ stateful_decoder! {
819819
let lead = lead as uint;
820820
let trail = trail as uint;
821821
let index = match (lead, trail) {
822-
(0x21..0x7e, 0x21..0x7e) => (lead - 0x21) * 94 + trail - 0x21,
822+
(0x21...0x7e, 0x21...0x7e) => (lead - 0x21) * 94 + trail - 0x21,
823823
_ => 0xffff,
824824
};
825825
index::jis0212::forward(index as u16)
@@ -828,7 +828,7 @@ stateful_decoder! {
828828
// iso-2022-jp state = ASCII, iso-2022-jp jis0212 flag = unset, iso-2022-jp lead = 0x00
829829
initial state ASCII(ctx) {
830830
case 0x1b => EscapeStart(ctx);
831-
case b @ 0x00..0x7f => ctx.emit(b as u32), ASCII(ctx);
831+
case b @ 0x00...0x7f => ctx.emit(b as u32), ASCII(ctx);
832832
case _ => ctx.err("invalid sequence"), ASCII(ctx);
833833
final => ctx.reset();
834834
}
@@ -852,7 +852,7 @@ stateful_decoder! {
852852
// iso-2022-jp state = Katakana
853853
checkpoint state Katakana(ctx) {
854854
case 0x1b => EscapeStart(ctx);
855-
case b @ 0x21..0x5f => ctx.emit(0xff61 + b as u32 - 0x21), Katakana(ctx);
855+
case b @ 0x21...0x5f => ctx.emit(0xff61 + b as u32 - 0x21), Katakana(ctx);
856856
case _ => ctx.err("invalid sequence"), Katakana(ctx);
857857
final => ctx.reset();
858858
}

src/encoding/codec/korean.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ ascii_compatible_stateful_decoder! {
8989
let lead = lead as uint;
9090
let trail = trail as uint;
9191
let index = match (lead, trail) {
92-
(0x81..0xc6, 0x41..0x5a) =>
92+
(0x81...0xc6, 0x41...0x5a) =>
9393
(26 + 26 + 126) * (lead - 0x81) + trail - 0x41,
94-
(0x81..0xc6, 0x61..0x7a) =>
94+
(0x81...0xc6, 0x61...0x7a) =>
9595
(26 + 26 + 126) * (lead - 0x81) + 26 + trail - 0x61,
96-
(0x81..0xc6, 0x81..0xfe) =>
96+
(0x81...0xc6, 0x81...0xfe) =>
9797
(26 + 26 + 126) * (lead - 0x81) + 26 + 26 + trail - 0x81,
98-
(0xc7..0xfe, 0xa1..0xfe) =>
98+
(0xc7...0xfe, 0xa1...0xfe) =>
9999
(26 + 26 + 126) * (0xc7 - 0x81) + (lead - 0xc7) * 94 + trail - 0xa1,
100100
(_, _) => 0xffff,
101101
};
@@ -104,8 +104,8 @@ ascii_compatible_stateful_decoder! {
104104

105105
// euc-kr lead = 0x00
106106
initial state S0(ctx) {
107-
case b @ 0x00..0x7f => ctx.emit(b as u32);
108-
case b @ 0x81..0xfe => S1(ctx, b);
107+
case b @ 0x00...0x7f => ctx.emit(b as u32);
108+
case b @ 0x81...0xfe => S1(ctx, b);
109109
case _ => ctx.err("invalid sequence");
110110
}
111111

src/encoding/codec/simpchinese.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ ascii_compatible_stateful_decoder! {
101101
let lead = lead as uint;
102102
let trail = trail as uint;
103103
let index = match (lead, trail) {
104-
(0x81..0xfe, 0x40..0x7e) | (0x81..0xfe, 0x80..0xfe) => {
104+
(0x81...0xfe, 0x40...0x7e) | (0x81...0xfe, 0x80...0xfe) => {
105105
let trailoffset = if trail < 0x7f {0x40} else {0x41};
106106
(lead - 0x81) * 190 + trail - trailoffset
107107
}
@@ -121,15 +121,15 @@ ascii_compatible_stateful_decoder! {
121121

122122
// gb18030 first = 0x00, gb18030 second = 0x00, gb18030 third = 0x00
123123
initial state S0(ctx) {
124-
case b @ 0x00..0x7f => ctx.emit(b as u32);
124+
case b @ 0x00...0x7f => ctx.emit(b as u32);
125125
case 0x80 => ctx.emit(0x20ac);
126-
case b @ 0x81..0xfe => S1(ctx, b);
126+
case b @ 0x81...0xfe => S1(ctx, b);
127127
case _ => ctx.err("invalid sequence");
128128
}
129129

130130
// gb18030 first != 0x00, gb18030 second = 0x00, gb18030 third = 0x00
131131
state S1(ctx, first: u8) {
132-
case b @ 0x30..0x39 => S2(ctx, first, b);
132+
case b @ 0x30...0x39 => S2(ctx, first, b);
133133
case b => match map_two_bytes(first, b) {
134134
0xffff => ctx.backup_and_err(1, "invalid sequence"), // unconditional
135135
ch => ctx.emit(ch)
@@ -138,13 +138,13 @@ ascii_compatible_stateful_decoder! {
138138

139139
// gb18030 first != 0x00, gb18030 second != 0x00, gb18030 third = 0x00
140140
state S2(ctx, first: u8, second: u8) {
141-
case b @ 0x81..0xfe => S3(ctx, first, second, b);
141+
case b @ 0x81...0xfe => S3(ctx, first, second, b);
142142
case _ => ctx.backup_and_err(2, "invalid sequence");
143143
}
144144

145145
// gb18030 first != 0x00, gb18030 second != 0x00, gb18030 third != 0x00
146146
state S3(ctx, first: u8, second: u8, third: u8) {
147-
case b @ 0x30..0x39 => match map_four_bytes(first, second, third, b) {
147+
case b @ 0x30...0x39 => match map_four_bytes(first, second, third, b) {
148148
0xffffffff => ctx.backup_and_err(3, "invalid sequence"), // unconditional
149149
ch => ctx.emit(ch)
150150
};
@@ -418,7 +418,7 @@ stateful_decoder! {
418418
let lead = lead as uint;
419419
let trail = trail as uint;
420420
let index = match (lead, trail) {
421-
(0x20..0x7f, 0x21..0x7e) => (lead - 1) * 190 + (trail + 0x3f),
421+
(0x20...0x7f, 0x21...0x7e) => (lead - 1) * 190 + (trail + 0x3f),
422422
_ => 0xffff,
423423
};
424424
index::gb18030::forward(index as u16)
@@ -427,15 +427,15 @@ stateful_decoder! {
427427
// hz-gb-2312 flag = unset, hz-gb-2312 lead = 0x00
428428
initial state A0(ctx) {
429429
case 0x7e => A1(ctx);
430-
case b @ 0x00..0x7f => ctx.emit(b as u32);
430+
case b @ 0x00...0x7f => ctx.emit(b as u32);
431431
case _ => ctx.err("invalid sequence");
432432
final => ctx.reset();
433433
}
434434

435435
// hz-gb-2312 flag = set, hz-gb-2312 lead = 0x00
436436
checkpoint state B0(ctx) {
437437
case 0x7e => B1(ctx);
438-
case b @ 0x20..0x7f => B2(ctx, b);
438+
case b @ 0x20...0x7f => B2(ctx, b);
439439
case 0x0a => ctx.err("invalid sequence"); // error *and* reset
440440
case _ => ctx.err("invalid sequence"), B0(ctx);
441441
final => ctx.reset();

src/encoding/codec/tradchinese.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ ascii_compatible_stateful_decoder! {
8686
let lead = lead as uint;
8787
let trail = trail as uint;
8888
let index = match (lead, trail) {
89-
(0x81..0xfe, 0x40..0x7e) | (0x81..0xfe, 0xa1..0xfe) => {
89+
(0x81...0xfe, 0x40...0x7e) | (0x81...0xfe, 0xa1...0xfe) => {
9090
let trailoffset = if trail < 0x7f {0x40} else {0x62};
9191
(lead - 0x81) * 157 + trail - trailoffset
9292
}
@@ -97,8 +97,8 @@ ascii_compatible_stateful_decoder! {
9797

9898
// big5 lead = 0x00
9999
initial state S0(ctx) {
100-
case b @ 0x00..0x7f => ctx.emit(b as u32);
101-
case b @ 0x81..0xfe => S1(ctx, b);
100+
case b @ 0x00...0x7f => ctx.emit(b as u32);
101+
case b @ 0x81...0xfe => S1(ctx, b);
102102
case _ => ctx.err("invalid sequence");
103103
}
104104

src/encoding/codec/utf_16.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ impl<E:Endian+Clone+'static> Encoder for UTF16Encoder<E> {
110110
for ((i,j), ch) in input.index_iter() {
111111
let ch = ch as uint;
112112
match ch {
113-
0x0000..0xd7ff | 0xe000..0xffff => {
113+
0x0000...0xd7ff | 0xe000...0xffff => {
114114
write_two_bytes(output, (ch >> 8) as u8, (ch & 0xff) as u8);
115115
}
116-
0x10000..0x10ffff => {
116+
0x10000...0x10ffff => {
117117
let ch = ch - 0x10000;
118118
write_two_bytes(output, (0xd8 | (ch >> 18)) as u8,
119119
((ch >> 10) & 0xff) as u8);
@@ -177,7 +177,7 @@ impl<E:Endian+Clone+'static> Decoder for UTF16Decoder<E> {
177177
let upper = self.leadsurrogate;
178178
self.leadsurrogate = 0xffff;
179179
match ch {
180-
0xdc00..0xdfff => {
180+
0xdc00...0xdfff => {
181181
let ch = ((upper as uint - 0xd800) << 10) + (ch as uint - 0xdc00);
182182
output.write_char(as_char(ch + 0x10000));
183183
processed = i;
@@ -190,11 +190,11 @@ impl<E:Endian+Clone+'static> Decoder for UTF16Decoder<E> {
190190
}
191191
} else {
192192
match ch {
193-
0xd800..0xdbff => {
193+
0xd800...0xdbff => {
194194
self.leadsurrogate = ch;
195195
// pass through
196196
}
197-
0xdc00..0xdfff => {
197+
0xdc00...0xdfff => {
198198
return (processed, Some(CodecError {
199199
upto: i as int, cause: "invalid sequence".into_maybe_owned()
200200
}));
@@ -218,7 +218,7 @@ impl<E:Endian+Clone+'static> Decoder for UTF16Decoder<E> {
218218
let ch = concat_two_bytes(input[i-1] as u16, input[i]);
219219
i += 1;
220220
match ch {
221-
0xdc00..0xdfff => {
221+
0xdc00...0xdfff => {
222222
let ch = ((upper as uint - 0xd800) << 10) + (ch as uint - 0xdc00);
223223
output.write_char(as_char(ch + 0x10000));
224224
}
@@ -243,7 +243,7 @@ impl<E:Endian+Clone+'static> Decoder for UTF16Decoder<E> {
243243
}
244244
let ch = concat_two_bytes(input[i-1] as u16, input[i]);
245245
match ch {
246-
0xd800..0xdbff => {
246+
0xd800...0xdbff => {
247247
i += 2;
248248
if i >= len {
249249
self.leadsurrogate = ch;
@@ -252,7 +252,7 @@ impl<E:Endian+Clone+'static> Decoder for UTF16Decoder<E> {
252252
}
253253
let ch2 = concat_two_bytes(input[i-1] as u16, input[i]);
254254
match ch2 {
255-
0xdc00..0xdfff => {
255+
0xdc00...0xdfff => {
256256
let ch = ((ch as uint - 0xd800) << 10) + (ch2 as uint - 0xdc00);
257257
output.write_char(as_char(ch + 0x10000));
258258
}
@@ -263,7 +263,7 @@ impl<E:Endian+Clone+'static> Decoder for UTF16Decoder<E> {
263263
}
264264
}
265265
}
266-
0xdc00..0xdfff => {
266+
0xdc00...0xdfff => {
267267
return (processed, Some(CodecError {
268268
upto: i as int + 1, cause: "invalid sequence".into_maybe_owned()
269269
}));

0 commit comments

Comments
 (0)