0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-09-19 01:19:52 +00:00
Files
termux-packages/packages/fish/revert-6644cc9.patch
Robert Kirkman 036d4ea4d3 bump(main/fish): 4.0.6
- Fixes https://github.com/termux/termux-packages/issues/26325

- Upstream fish, it appears through the heavy patching we increasingly need to do, does not officially support Android. This means that it is completely understandable that they continue to make changes that break the Android build, and these are not necessarily bugs on their end because they don't build or test for Android, and already work a lot to support all non-Android platforms. Therefore, sometimes the only viable option we might have is to revert or partially revert some commits which are problematic for Android support, in the downstream.

Commits being reverted in this PR:
  - d68f8bdd3b - partially reverted to avoid error `error: call to undeclared function 'UNUSED'`
  - 6644cc9b0e - reverted to avoid error `expected fn pointer`...`*const i8`...`found fn item`...`*const u8`

Commits that I am aware are in the development branch of fish that are not yet present in this fish stable release, but which I believe are highly likely to cause errors in a future release and will most likely also need to be reverted in order to build that future release for Android:
  - 70bd49f612
2025-09-16 12:50:25 -05:00

85 lines
3.3 KiB
Diff

Reverts https://github.com/fish-shell/fish-shell/commit/6644cc9b0e29841e3d0a85fbc672a95c4a2fd000,
a NetBSD-related commit,
because it causes this compilation failure on Android:
error[E0308]: mismatched types
--> src/path.rs:749:13
|
748 | let remoteness = remoteness_via_statfs(
| --------------------- arguments to this function are incorrect
749 | libc::statfs,
| ^^^^^^^^^^^^ expected fn pointer, found fn item
|
= note: expected fn pointer `unsafe extern "C" fn(*const i8, _) -> _`
found fn item `unsafe extern "C" fn(*const u8, _) -> _ {libc::statfs}`
--- a/src/path.rs
+++ b/src/path.rs
@@ -6,6 +6,8 @@ use crate::common::{wcs2osstring, wcs2zstring};
use crate::env::{EnvMode, EnvStack, Environment};
use crate::expand::{expand_tilde, HOME_DIRECTORY};
use crate::flog::{FLOG, FLOGF};
+#[cfg(not(target_os = "linux"))]
+use crate::libc::{MNT_LOCAL, ST_LOCAL};
use crate::wchar::prelude::*;
use crate::wutil::{normalize_path, path_normalize_for_cd, waccess, wdirname, wstat};
use errno::{errno, set_errno, Errno};
@@ -709,49 +711,25 @@ fn path_remoteness(path: &wstr) -> DirRemoteness {
}
#[cfg(not(target_os = "linux"))]
{
- fn remoteness_via_statfs<StatFS, Flags>(
- statfn: unsafe extern "C" fn(*const i8, *mut StatFS) -> libc::c_int,
- flagsfn: fn(&StatFS) -> Flags,
- is_local_flag: u64,
- path: &std::ffi::CStr,
- ) -> DirRemoteness
- where
- u64: From<Flags>,
- {
- if is_local_flag == 0 {
- return DirRemoteness::unknown;
- }
+ // ST_LOCAL is a flag to statvfs, which is itself standardized.
+ // In practice the only system to define it is NetBSD.
+ let local_flag = ST_LOCAL() | MNT_LOCAL();
+ if local_flag != 0 {
let mut buf = MaybeUninit::uninit();
- if unsafe { (statfn)(path.as_ptr(), buf.as_mut_ptr()) } < 0 {
+ if unsafe { libc::statfs(narrow.as_ptr(), buf.as_mut_ptr()) } < 0 {
return DirRemoteness::unknown;
}
let buf = unsafe { buf.assume_init() };
// statfs::f_flag is hard-coded as 64-bits on 32/64-bit FreeBSD but it's a (4-byte)
// long on 32-bit NetBSD.. and always 4-bytes on macOS (even on 64-bit builds).
#[allow(clippy::useless_conversion)]
- if u64::from((flagsfn)(&buf)) & is_local_flag != 0 {
+ return if u64::from(buf.f_flags) & local_flag != 0 {
DirRemoteness::local
} else {
DirRemoteness::remote
- }
+ };
}
- // ST_LOCAL is a flag to statvfs, which is itself standardized.
- // In practice the only system to define it is NetBSD.
- #[cfg(target_os = "netbsd")]
- let remoteness = remoteness_via_statfs(
- libc::statvfs,
- |stat: &libc::statvfs| stat.f_flag,
- crate::libc::ST_LOCAL(),
- &narrow,
- );
- #[cfg(not(target_os = "netbsd"))]
- let remoteness = remoteness_via_statfs(
- libc::statfs,
- |stat: &libc::statfs| stat.f_flags,
- crate::libc::MNT_LOCAL(),
- &narrow,
- );
- remoteness
+ DirRemoteness::unknown
}
}