File: 0002-Use-c_char-instead-of-i8-for-ffi.patch

package info (click to toggle)
rust-yaml 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 292 kB
  • sloc: ansic: 73; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 1,128 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From e5261398fcb4cd3406d727973486d0178130825a Mon Sep 17 00:00:00 2001
From: Wolfgang Silbermayr <wolfgang@silbermayr.at>
Date: Sat, 8 Dec 2018 09:39:56 +0100
Subject: [PATCH 2/2] Use c_char instead of i8 for ffi

This allows the project to build on architectures which define c_char as u8.
Fixes build problems in architectures provided by debian.
---
 src/codecs.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/codecs.rs b/src/codecs.rs
index b28f835..749e7a2 100644
--- a/src/codecs.rs
+++ b/src/codecs.rs
@@ -6,14 +6,15 @@ use std::slice;
 use std::str;
 use std::ptr;
 use std::ffi::CStr;
+use std::os::raw::c_char;
 
 pub fn decode_c_str(c_str: *const ffi::yaml_char_t) -> Option<String> {
     if c_str == ptr::null() {
         None
     } else {
         unsafe {
-            let i8_str = c_str as *const i8;
-            str::from_utf8(CStr::from_ptr(i8_str).to_bytes()).map(|s| s.to_string()).ok()
+            let c_char_str = c_str as *const c_char;
+            str::from_utf8(CStr::from_ptr(c_char_str).to_bytes()).map(|s| s.to_string()).ok()
         }
     }
 }
-- 
2.20.0.rc2