-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix rustdoc #43691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix rustdoc #43691
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -531,6 +530,7 @@ extern { | |
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 libc::c_char, len: libc::size_t); | ||
} | ||
|
||
impl hoedown_buffer { | ||
|
@@ -620,8 +620,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() as *const libc::c_char, s.len()); | ||
}) | ||
} | ||
} | ||
|
@@ -681,8 +680,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() as *const libc::c_char, text.len()); } | ||
} | ||
|
||
extern fn codespan( | ||
|
@@ -699,9 +697,10 @@ pub fn render(w: &mut fmt::Formatter, | |
collapse_whitespace(s) | ||
}; | ||
|
||
let content = format!("<code>{}</code>", Escape(&content)); | ||
let element = CString::new(content).unwrap(); | ||
unsafe { hoedown_buffer_puts(ob, element.as_ptr()); } | ||
let content = format!("<code>{}</code>", Escape(&content)).replace("\0", "\\0"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change seems unnecessary. As hoedown just passes null bytes through unmodified everywhere else there is no reason to escape it in this one case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't do it, it doesn't appear in the generated HTML. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will, but browsers may not show anything but that's expected and what already happens if null bytes appear in normal paragraphs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So be it. |
||
unsafe { | ||
hoedown_buffer_put(ob, content.as_ptr() as *const libc::c_char, content.len()); | ||
} | ||
// Return anything except 0, which would mean "also print the code span verbatim". | ||
1 | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' '0' | ||
#[doc = "Attempted to pass a string containing `\0`"] | ||
pub fn foo() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second parameter is
const uint8_t *data
so here it should be*const u8
. That also meansas *const libc::c_char
can be removed from below.