faster_path 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7663e3cebaf52e71d0445b29c541e31ad1b6f87
4
- data.tar.gz: 67071c8d8d399baf4d64705d1e7a5c147f56bc39
3
+ metadata.gz: 8ad592a885912e4267151be6ee15a9accfbd34ef
4
+ data.tar.gz: b2b22d3198284b6dc2bb177c72bd1c99bbcbb3a5
5
5
  SHA512:
6
- metadata.gz: 1607471e1395c8fc7c583fb936e5bfe618dd5066eda0d59613040b3499565ff6d7fe106a55447dcec7a8dc705fb7af96c011e535ec165b2f06b5f7e4fc983ccf
7
- data.tar.gz: 312ba0423e39dce09031e7d2b1f29bfc5562865c89b15854713a771047b89be668e2ca35c254f4471398836999f44037a2539012a0dcdd6935160cdcc6d36105
6
+ metadata.gz: 17eecf18612f14fa87de8fc58f2ae4b08cb4e7f98e4d62283f87457d09e1822a3aba7db72df2e14e4d9cddcab60abf7cc2148742d9ae301541454e7a62080201
7
+ data.tar.gz: 15ad8f6310ce3b5188533f957bbc5e0ba9280686dd148adca124d455249c6426b2ee1f4b9cff43383e6601daf5682fad78a0d376d343537fe1f81118a20fcb21
@@ -1,3 +1,3 @@
1
1
  module FasterPath
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -4,25 +4,26 @@ use std::ffi::{CStr, CString};
4
4
  use std::str;
5
5
 
6
6
  #[no_mangle]
7
- pub extern "C" fn add_trailing_separator(string: *const c_char) -> *const c_char {
8
- let c_str = unsafe {
9
- assert!(!string.is_null());
10
-
11
- CStr::from_ptr(string)
12
- };
13
- let r_str = str::from_utf8(c_str.to_bytes()).unwrap_or("");
14
-
15
- if r_str.is_empty() {
16
- return string;
7
+ pub extern fn add_trailing_separator(string: *const c_char) -> *const c_char {
8
+ let c_str = unsafe {
9
+ if string.is_null() {
10
+ return string;
17
11
  }
12
+ CStr::from_ptr(string)
13
+ };
14
+ let r_str = str::from_utf8(c_str.to_bytes()).unwrap_or("");
15
+
16
+ if r_str.is_empty() {
17
+ return string;
18
+ }
18
19
 
19
- let path = Path::new(r_str);
20
- let out_str = if !(path.to_str().unwrap().chars().last().unwrap() == '/') {
21
- format!("{}{}", path.to_str().unwrap(), MAIN_SEPARATOR)
22
- } else {
23
- path.to_str().unwrap().to_string()
24
- };
20
+ let path = Path::new(r_str);
21
+ let out_str = if !(path.to_str().unwrap().chars().last().unwrap() == '/') {
22
+ format!("{}{}", path.to_str().unwrap(), MAIN_SEPARATOR)
23
+ } else {
24
+ path.to_str().unwrap().to_string()
25
+ };
25
26
 
26
- let output = CString::new(out_str).unwrap();
27
- output.into_raw()
27
+ let output = CString::new(out_str).unwrap();
28
+ output.into_raw()
28
29
  }
data/src/basename.rs CHANGED
@@ -56,11 +56,15 @@ fn it_chomps_strings_correctly(){
56
56
  #[no_mangle]
57
57
  pub extern fn basename(str_pth: *const c_char, comp_ext: *const c_char) -> *const c_char {
58
58
  let c_str1 = unsafe {
59
- assert!(!str_pth.is_null());
59
+ if str_pth.is_null(){
60
+ return str_pth;
61
+ }
60
62
  CStr::from_ptr(str_pth)
61
63
  };
62
64
  let c_str2 = unsafe {
63
- assert!(!comp_ext.is_null());
65
+ if comp_ext.is_null() {
66
+ return str_pth;
67
+ }
64
68
  CStr::from_ptr(comp_ext)
65
69
  };
66
70
  let string = str::from_utf8(c_str1.to_bytes()).unwrap();
@@ -6,8 +6,9 @@ use std::str;
6
6
  #[no_mangle]
7
7
  pub extern fn basename_for_chop(string: *const c_char) -> *const c_char {
8
8
  let c_str = unsafe {
9
- assert!(!string.is_null());
10
-
9
+ if string.is_null() {
10
+ return string;
11
+ }
11
12
  CStr::from_ptr(string)
12
13
  };
13
14
 
@@ -5,11 +5,15 @@ use std::str;
5
5
  #[no_mangle]
6
6
  pub extern fn both_are_blank(s1: *const c_char, s2: *const c_char) -> bool {
7
7
  let c_str1 = unsafe {
8
- assert!(!s1.is_null());
8
+ if s1.is_null() {
9
+ return true;
10
+ }
9
11
  CStr::from_ptr(s1)
10
12
  };
11
13
  let c_str2 = unsafe {
12
- assert!(!s2.is_null());
14
+ if s2.is_null() {
15
+ return true;
16
+ }
13
17
  CStr::from_ptr(s2)
14
18
  };
15
19
 
@@ -6,8 +6,9 @@ use std::str;
6
6
  #[no_mangle]
7
7
  pub extern fn dirname_for_chop(string: *const c_char) -> *const c_char {
8
8
  let c_str = unsafe {
9
- assert!(!string.is_null());
10
-
9
+ if string.is_null() {
10
+ return string
11
+ }
11
12
  CStr::from_ptr(string)
12
13
  };
13
14
 
data/src/is_absolute.rs CHANGED
@@ -7,8 +7,9 @@ use std::path::MAIN_SEPARATOR;
7
7
  #[no_mangle]
8
8
  pub extern fn is_absolute(string: *const c_char) -> bool {
9
9
  let c_str = unsafe {
10
- assert!(!string.is_null());
11
-
10
+ if string.is_null() {
11
+ return false;
12
+ }
12
13
  CStr::from_ptr(string)
13
14
  };
14
15
 
data/src/is_blank.rs CHANGED
@@ -5,8 +5,9 @@ use std::str;
5
5
  #[no_mangle]
6
6
  pub extern fn is_blank(string: *const c_char) -> bool {
7
7
  let c_str = unsafe {
8
- assert!(!string.is_null());
9
-
8
+ if string.is_null() {
9
+ return true;
10
+ }
10
11
  CStr::from_ptr(string)
11
12
  };
12
13
 
data/src/is_directory.rs CHANGED
@@ -6,8 +6,9 @@ use std::path::Path;
6
6
  #[no_mangle]
7
7
  pub extern fn is_directory(string: *const c_char) -> bool {
8
8
  let c_str = unsafe {
9
- assert!(!string.is_null());
10
-
9
+ if string.is_null() {
10
+ return false;
11
+ }
11
12
  CStr::from_ptr(string)
12
13
  };
13
14
 
data/src/is_relative.rs CHANGED
@@ -6,8 +6,9 @@ use std::str;
6
6
  #[no_mangle]
7
7
  pub extern fn is_relative(string: *const c_char) -> bool {
8
8
  let c_str = unsafe {
9
- assert!(!string.is_null());
10
-
9
+ if string.is_null() {
10
+ return false;
11
+ }
11
12
  CStr::from_ptr(string)
12
13
  };
13
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faster_path
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-18 00:00:00.000000000 Z
11
+ date: 2016-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.5.1
168
+ rubygems_version: 2.6.4
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Reimplementation of Pathname for better performance