termux-packages/packages/newsboat/rust-libnewsboat-src-utils.rs.patch
vhqtvn 124efc9dd9
package updates & build issue fixes ()
aptly: fix build failure

dpkg: fix $TERMUX_ARCH in configure script

gotty: switch to up-to-date upstream

minicom: update source url

ncurses: force build with -fPIC

newsboat: update to 2.23

ovmf: update to 20210421.18.g15ee7b7689

pforth: update to 20210315

pup: build with GO111MODULE=off

rcshell: update source url

remind: update to 03.03.07

tweego: update to 2.1.1

virustotal-cli: update to 0.9.6

docker image: install some missing build tools
2021-05-29 14:41:04 +03:00

91 lines
3.2 KiB
Diff

--- ./rust/libnewsboat/src/utils.rs.orig 2021-05-17 17:24:43.019948076 +0000
+++ ./rust/libnewsboat/src/utils.rs 2021-05-17 17:45:43.814961688 +0000
@@ -891,6 +891,7 @@
// On FreeBSD, link with GNU libiconv; the iconv implementation in libc doesn't support //TRANSLIT
// and WCHAR_T. This is also why we change the symbol names from "iconv" to "libiconv" below.
+/*
#[cfg_attr(target_os = "freebsd", link(name = "iconv"))]
extern "C" {
#[cfg_attr(target_os = "freebsd", link_name = "libiconv_open")]
@@ -906,7 +907,7 @@
#[cfg_attr(target_os = "freebsd", link_name = "libiconv_close")]
pub fn iconv_close(cd: iconv_t) -> c_int;
}
-
+*/
/// Annotates the target encoding (`tocode`) with `//TRANSLIT` if conversion between `fromcode` and
/// `tocode` might require transliterating some characters.
pub fn translit(tocode: &str, fromcode: &str) -> String {
@@ -920,7 +921,7 @@
// However, in our case it's okay: even if multiple threads run this function, they will all
// arrive at the same result, so we don't care if those threads race to write that result into
// the variable.
- static mut STATE: TranslitState = TranslitState::Unknown;
+ static mut STATE: TranslitState = TranslitState::Unsupported;
// TRANSLIT is not needed when converting to unicode encodings
if tocode == "utf-8" || tocode == "WCHAR_T" {
@@ -931,6 +932,7 @@
unsafe {
if STATE == TranslitState::Unknown {
+ /*
// The three calls to expect() can't panic because the input strings come from either:
//
// - our code, and we won't deliberately put a NUL byte inside an encoding name; or
@@ -968,6 +970,7 @@
STATE = TranslitState::Supported;
iconv_close(cd);
}
+ */
}
}
@@ -987,7 +990,9 @@
let mut result = vec![];
let tocode_translit = translit(tocode, fromcode);
-
+
+ result = tocode_translit.as_bytes().to_vec();
+ /*
// Illegal and incomplete multi-byte sequences will be replaced by this
// placeholder. By default, we use an ASCII value for "question mark".
let question_mark = {
@@ -1078,21 +1083,25 @@
iconv_close(cd);
}
-
+ */
result
}
fn get_locale_encoding() -> String {
unsafe {
- use libc::{nl_langinfo, CODESET};
+ use libc::{setlocale, LC_CTYPE};
use std::ffi::CStr;
-
- let codeset = CStr::from_ptr(nl_langinfo(CODESET));
- // Codeset names are ASCII, so the below expect() should never panic.
- codeset
- .to_str()
- .expect("Locale codeset name is not a valid UTF-8 string")
- .to_owned()
+ // reimplement from C version https://github.com/crystax/android-vendor-gnu-grep/blob/master/lib/nl_langinfo.c
+ let mut locale = CStr::from_ptr(setlocale(LC_CTYPE, std::ptr::null())).to_str().expect("Null locale found").to_owned();
+ locale = match locale.find(".") {
+ Some(pos) => locale[(pos+1)..].to_string(),
+ None => locale
+ };
+ locale = match locale.find("@") {
+ Some(pos) => locale[..pos].to_string(),
+ None => locale
+ };
+ locale
}
}