Auto merge of #43691 - GuillaumeGomez:fix-rustdoc, r=QuietMisdreavus
Fix rustdoc Fixes #43625. r? @rust-lang/dev-tools cc @rust-lang/docs
This commit is contained in:
commit
78efb23586
@ -32,7 +32,6 @@ use std::ascii::AsciiExt;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::default::Default;
|
||||
use std::ffi::CString;
|
||||
use std::fmt::{self, Write};
|
||||
use std::str;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
@ -529,8 +528,8 @@ extern {
|
||||
fn hoedown_document_free(md: *mut hoedown_document);
|
||||
|
||||
fn hoedown_buffer_new(unit: libc::size_t) -> *mut hoedown_buffer;
|
||||
fn hoedown_buffer_puts(b: *mut hoedown_buffer, c: *const libc::c_char);
|
||||
fn hoedown_buffer_free(b: *mut hoedown_buffer);
|
||||
fn hoedown_buffer_put(b: *mut hoedown_buffer, c: *const u8, len: libc::size_t);
|
||||
}
|
||||
|
||||
impl hoedown_buffer {
|
||||
@ -620,8 +619,7 @@ pub fn render(w: &mut fmt::Formatter,
|
||||
Some("rust-example-rendered"),
|
||||
None,
|
||||
playground_button.as_ref().map(String::as_str)));
|
||||
let output = CString::new(s).unwrap();
|
||||
hoedown_buffer_puts(ob, output.as_ptr());
|
||||
hoedown_buffer_put(ob, s.as_ptr(), s.len());
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -630,7 +628,7 @@ pub fn render(w: &mut fmt::Formatter,
|
||||
level: libc::c_int, data: *const hoedown_renderer_data,
|
||||
_: libc::size_t) {
|
||||
// hoedown does this, we may as well too
|
||||
unsafe { hoedown_buffer_puts(ob, "\n\0".as_ptr() as *const _); }
|
||||
unsafe { hoedown_buffer_put(ob, "\n".as_ptr(), 1); }
|
||||
|
||||
// Extract the text provided
|
||||
let s = if text.is_null() {
|
||||
@ -681,8 +679,7 @@ pub fn render(w: &mut fmt::Formatter,
|
||||
<a href='#{id}'>{sec}{}</a></h{lvl}>",
|
||||
s, lvl = level, id = id, sec = sec);
|
||||
|
||||
let text = CString::new(text).unwrap();
|
||||
unsafe { hoedown_buffer_puts(ob, text.as_ptr()) }
|
||||
unsafe { hoedown_buffer_put(ob, text.as_ptr(), text.len()); }
|
||||
}
|
||||
|
||||
extern fn codespan(
|
||||
@ -700,8 +697,9 @@ pub fn render(w: &mut fmt::Formatter,
|
||||
};
|
||||
|
||||
let content = format!("<code>{}</code>", Escape(&content));
|
||||
let element = CString::new(content).unwrap();
|
||||
unsafe { hoedown_buffer_puts(ob, element.as_ptr()); }
|
||||
unsafe {
|
||||
hoedown_buffer_put(ob, content.as_ptr(), content.len());
|
||||
}
|
||||
// Return anything except 0, which would mean "also print the code span verbatim".
|
||||
1
|
||||
}
|
||||
|
18
src/test/rustdoc/nul-error.rs
Normal file
18
src/test/rustdoc/nul-error.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// build-aux-docs
|
||||
// ignore-cross-compile
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
// @has foo/fn.foo.html '//code' ''
|
||||
#[doc = "Attempted to pass a string containing `\0`"]
|
||||
pub fn foo() {}
|
Loading…
x
Reference in New Issue
Block a user