From d35a27ccc1012ef41157b07a54b6759bacefb32d Mon Sep 17 00:00:00 2001 From: Lars Bergstrom Date: Tue, 4 Mar 2014 16:11:44 -0800 Subject: [PATCH 1/3] Rust upgrade --- lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib.rs b/lib.rs index c99cd46..44f3d39 100644 --- a/lib.rs +++ b/lib.rs @@ -10,9 +10,9 @@ #[crate_id = "github.com/mozilla-servo/rust-png#png:0.1"]; #[cfg(test)] -extern mod extra; +extern crate extra; -extern mod std; +extern crate std; use std::cast; use std::io; use std::io::File; @@ -58,7 +58,7 @@ pub extern fn read_data(png_ptr: *ffi::png_struct, data: *mut u8, length: size_t let image_data: &mut ImageData = cast::transmute(io_ptr); let len = length as uint; vec::raw::mut_buf_as_slice(data, len, |buf| { - let end_pos = std::num::min(image_data.data.len()-image_data.offset, len); + let end_pos = std::cmp::min(image_data.data.len()-image_data.offset, len); buf.copy_memory(image_data.data.slice(image_data.offset, image_data.offset+end_pos)); image_data.offset += end_pos; }); @@ -144,7 +144,7 @@ pub fn load_png_from_memory(image: &[u8]) -> Result { let mut image_data = vec::from_elem((width * height * pixel_width) as uint, 0u8); let image_buf = image_data.as_mut_ptr(); let row_pointers: ~[*mut u8] = vec::from_fn(height as uint, |idx| { - ptr::mut_offset(image_buf, (((width * pixel_width) as uint) * idx) as int) + image_buf.offset((((width * pixel_width) as uint) * idx) as int) }); ffi::png_read_image(png_ptr, row_pointers.as_ptr()); @@ -188,8 +188,8 @@ pub extern fn flush_data(png_ptr: *ffi::png_struct) { pub fn store_png(img: &Image, path: &Path) -> Result<(),~str> { let mut file = match File::create(path) { - Ok(file) => file, - Err(_) => return Err(~"could not open file") + Ok(f) => f, + Err(e) => return Err(format!("{}", e)) }; let mut writer = &mut file as &mut io::Writer; @@ -234,7 +234,7 @@ pub fn store_png(img: &Image, path: &Path) -> Result<(),~str> { let image_buf = img.pixels.as_ptr(); let row_pointers: ~[*u8] = vec::from_fn(img.height as uint, |idx| { - ptr::offset(image_buf, (((img.width * pixel_width) as uint) * idx) as int) + image_buf.offset((((img.width * pixel_width) as uint) * idx) as int) }); ffi::png_set_rows(&*png_ptr, info_ptr, row_pointers.as_ptr()); From 4c27ef2961bb6df512df093dbf800a6bb26fdccb Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 14 Mar 2014 15:12:29 -0400 Subject: [PATCH 2/3] Warning police. --- ffi.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ffi.rs b/ffi.rs index 7e4344e..f3d6e1e 100644 --- a/ffi.rs +++ b/ffi.rs @@ -7,6 +7,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[allow(non_camel_case_types)]; + use std::libc::{c_int, size_t, c_void, c_char}; pub static TRANSFORM_IDENTITY: c_int = 0; From 3c4f326b0ddd7bf47966facb56c40d76bfb6cec3 Mon Sep 17 00:00:00 2001 From: Lars Bergstrom Date: Mon, 17 Mar 2014 12:33:29 -0500 Subject: [PATCH 3/3] Rust upgrade --- lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib.rs b/lib.rs index 44f3d39..21876d7 100644 --- a/lib.rs +++ b/lib.rs @@ -249,7 +249,9 @@ pub fn store_png(img: &Image, path: &Path) -> Result<(),~str> { #[cfg(test)] mod test { - use extra::test::{bench, fmt_bench_samples}; + extern crate test; + use self::test::bench; + use self::test::fmt_bench_samples; use std::io; use std::io::File; use std::vec;