Skip to content

Commit 540d8bc

Browse files
liigoalexcrichton
authored andcommitted
---
yaml --- r: 106927 b: refs/heads/try c: 20e178c h: refs/heads/master i: 106925: e1364ac 106923: 0a41cb5 106919: 8262dc0 106911: 939afe5 v: v3
1 parent 6913f2f commit 540d8bc

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b8601a3d8b91ad3b653d143307611f2f5c75617e
5-
refs/heads/try: 8f7a7970f3f01aa2266c6ce3ee031234b86b1b9b
5+
refs/heads/try: 20e178c5821b32d7a7deab70af90bf50f9d39df3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustdoc/html/render.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,13 @@ impl<'a> SourceCollector<'a> {
463463
};
464464
let contents = str::from_utf8_owned(contents).unwrap();
465465

466+
// Remove the utf-8 BOM if any
467+
let contents = if contents.starts_with("\ufeff") {
468+
contents.as_slice().slice_from(3)
469+
} else {
470+
contents.as_slice()
471+
};
472+
466473
// Create the intermediate directories
467474
let mut cur = self.dst.clone();
468475
let mut root_path = ~"../../";
@@ -482,7 +489,7 @@ impl<'a> SourceCollector<'a> {
482489
root_path: root_path,
483490
};
484491
try!(layout::render(&mut w as &mut Writer, &self.cx.layout,
485-
&page, &(""), &Source(contents.as_slice())));
492+
&page, &(""), &Source(contents)));
486493
try!(w.flush());
487494
return Ok(());
488495
}

branches/try/src/libsyntax/codemap.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,22 @@ impl CodeMap {
271271
}
272272
}
273273

274-
pub fn new_filemap(&self, filename: FileName, mut src: ~str) -> Rc<FileMap> {
274+
pub fn new_filemap(&self, filename: FileName, src: ~str) -> Rc<FileMap> {
275275
let mut files = self.files.borrow_mut();
276276
let start_pos = match files.get().last() {
277277
None => 0,
278278
Some(last) => last.deref().start_pos.to_uint() + last.deref().src.len(),
279279
};
280280

281+
// Remove utf-8 BOM if any.
282+
// FIXME #12884: no efficient/safe way to remove from the start of a string
283+
// and reuse the allocation.
284+
let mut src = if src.starts_with("\ufeff") {
285+
src.as_slice().slice_from(3).into_owned()
286+
} else {
287+
src
288+
};
289+
281290
// Append '\n' in case it's not already there.
282291
// This is a workaround to prevent CodeMap.lookup_filemap_idx from accidentally
283292
// overflowing into the next filemap in case the last byte of span is also the last
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This file has utf-8 BOM, it should be compiled normally without error.
12+
13+
pub fn main() {}

0 commit comments

Comments
 (0)