Randy Eckenrode 2024-09-22 17:00:25 -04:00
parent 72f19adb18
commit 63bfe3cc6d
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9
4 changed files with 128 additions and 35 deletions

View File

@ -6,6 +6,9 @@ project('text_cmds', 'c', version : '@version@')
add_global_arguments(
# Many programs use old prototypes
'-Wno-deprecated-non-prototype',
# Needed to build errx functions from Libc
'-include', 'crt_externs.h',
'-D_getprogname()=(*_NSGetProgname())',
language : 'c',
)
@ -16,6 +19,7 @@ cc = meson.get_compiler('c')
bzip2 = dependency('bzip2')
libbsd = dependency('libbsd-overlay', required : false)
libmd = dependency('libmd')
libresolv = cc.find_library('resolv')
libutil = cc.find_library('util')
libxo = dependency('libxo')
@ -42,6 +46,7 @@ executable(
'bintrans/qp.c',
'bintrans/uudecode.c',
'bintrans/uuencode.c',
fs.exists('err-libc.c') ? 'err-libc.c' : [ ],
],
)
install_man(
@ -78,14 +83,20 @@ executable(
'col',
dependencies : [ libbsd ],
install : true,
sources : [ 'col/col.c' ],
sources : [
'col/col.c',
fs.exists('err-libc.c') ? 'err-libc.c' : [ ],
],
)
install_man('col/col.1')
executable(
'colrm',
install : true,
sources : [ 'colrm/colrm.c' ],
sources : [
'colrm/colrm.c',
fs.exists('err-libc.c') ? 'err-libc.c' : [ ],
],
)
install_man('colrm/colrm.1')
@ -99,14 +110,20 @@ install_man('column/column.1')
executable(
'comm',
install : true,
sources : [ 'comm/comm.c' ],
sources : [
'comm/comm.c',
fs.exists('err-libc.c') ? 'err-libc.c' : [ ],
],
)
install_man('comm/comm.1')
executable(
'csplit',
install : true,
sources : [ 'csplit/csplit.c' ],
sources : [
'csplit/csplit.c',
fs.exists('err-libc.c') ? 'err-libc.c' : [ ],
],
)
install_man('csplit/csplit.1')
@ -135,26 +152,6 @@ install_man(
'ed/red.1',
)
executable(
'ee',
c_args : [ '-Wno-format-security' ],
dependencies : [ ncurses ],
c_args : [
'-DHAS_NCURSES',
'-DHAS_STDARG',
'-DHAS_STDLIB',
'-DHAS_SYS_WAIT',
'-DHAS_UNISTD',
'-DNO_CATGETS',
],
install : true,
sources : [
'ee/ee.c',
'ee/new_curse.c',
],
)
install_man('ee/ee.1')
executable(
'expand',
install : true,
@ -227,13 +224,28 @@ install_man('look/look.1')
executable(
'md5',
dependencies : [ libmd ],
install : true,
sources : [
'md5/commoncrypto.c',
'md5/md5.c',
],
sources : [ 'md5/md5.c' ],
)
install_man('md5/md5.1')
foreach cmd : [ 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512' ]
foreach suffix : [ '', 'sum' ]
cmd += suffix
if cmd != 'md5'
install_symlink(
cmd,
install_dir : get_option('bindir'),
pointing_to : 'md5',
)
install_symlink(
f'@cmd@.1',
install_dir : get_option('mandir') + '/man1',
pointing_to : 'md5.1',
)
endif
endforeach
endforeach
executable(
'nl',
@ -304,7 +316,7 @@ executable(
executable(
'split',
dependencies : [ libutil ],
dependencies : [ libbsd, libutil ],
install : true,
sources : [ 'split/split.c' ],
)
@ -354,6 +366,7 @@ executable(
executable(
'uniq',
dependencies : [ libbsd ],
install : true,
sources : [ 'uniq/uniq.c' ],
)

View File

@ -5,13 +5,14 @@
apple-sdk_13,
bzip2,
libbsd,
libmd,
libresolv,
libutil,
libxo,
mkAppleDerivation,
shell_cmds,
ncurses,
pkg-config,
shell_cmds,
stdenvNoCC,
xz,
zlib,
@ -56,12 +57,36 @@ mkAppleDerivation {
"man"
];
xcodeHash = "sha256-DzLrQ8CbInXj7PrV9jp3nHfE84A09ZwS729c9WXFV4Y=";
xcodeHash = "sha256-dZ+yJyfflhmUyx3gitRXC115QxS87SGC4/HjMa199Ts=";
patches = lib.optionals (lib.versionOlder (lib.getVersion apple-sdk) "11.0") [
./patches/0001-Use-availability-check-for-__collate_lookup_l.patch
];
postPatch =
''
# Fix format security errors
sed -e 's/wprintw(\([^,]*\), \([^)]*\))/wprintw(\1, "%s", \2)/g' -i ee/ee.c
# Improve compatiblity with libmd in nixpkgs.
substituteInPlace md5/md5.c \
--replace-fail '<sha224.h>' '<sha2.h>' \
--replace-fail SHA224_Init SHA224Init \
--replace-fail SHA224_Update SHA224Update \
--replace-fail SHA224_End SHA224End \
--replace-fail SHA224_Data SHA224Data \
--replace-fail SHA224_CTX SHA2_CTX \
--replace-fail '<sha384.h>' '<sha512.h>' \
--replace-fail 'const void *, unsigned int, char *' 'const uint8_t *, size_t, char *'
''
+ lib.optionalString (lib.versionOlder (lib.getVersion apple-sdk) "13.0") ''
# Backport vis APIs from the 13.3 SDK (needed by vis).
cp '${Libc_13}/gen/FreeBSD/vis.c' vis/vis-libc.c
# Backport errx APIs from the 13.3 SDK (needed by lots of things).
mkdir sys
cp '${Libc_13}/gen/FreeBSD/err.c' err-libc.c
cp '${Libc_13}/include/err.h' err.h
cp '${Libc_13}/fbsdcompat/sys/cdefs.h' sys/cdefs.h
substituteInPlace err.h \
--replace-fail '__cold' ""
touch namespace.h un-namespace.h libc_private.h
'';
env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include";
@ -70,6 +95,7 @@ mkAppleDerivation {
buildInputs = [
bzip2
libmd
libresolv
libutil
libxo

View File

@ -0,0 +1,54 @@
From 11ad41c2d3af88b5cf85d4bc2f5388b65e5ff347 Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Mon, 16 Sep 2024 12:42:59 -0400
Subject: [PATCH] Use availability check for __collate_lookup_l
---
tr/str.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tr/str.c b/tr/str.c
index 6a79df2..8226abe 100644
--- a/tr/str.c
+++ b/tr/str.c
@@ -69,6 +69,7 @@ static void genseq(STR *);
* Using libc internal function __collate_lookup_l for character
* equivalence
*/
+void __collate_lookup(const __darwin_wchar_t *, int *, int *, int *);
void __collate_lookup_l(const __darwin_wchar_t *, int *, int *, int *,
locale_t);
/*
@@ -255,7 +256,13 @@ genequiv(STR *s)
*/
int tprim, tsec;
int len;
- __collate_lookup_l(s->equiv, &len, &tprim, &tsec, LC_GLOBAL_LOCALE);
+ if (__builtin_available(macOS 11.0, *)) {
+ __collate_lookup_l(s->equiv, &len, &tprim, &tsec, LC_GLOBAL_LOCALE);
+ } else {
+ locale_t old = uselocale(LC_GLOBAL_LOCALE);
+ __collate_lookup(s->equiv, &len, &tprim, &tsec);
+ uselocale(old);
+ }
if (tprim != -1) {
for (p = 1, i = 1; i < NCHARS_SB; i++) {
@@ -270,7 +277,13 @@ genequiv(STR *s)
* perform lookup of primary weight and fill cache
*/
int csec;
- __collate_lookup_l((__darwin_wchar_t *)&i, &len, &cprim, &csec, LC_GLOBAL_LOCALE);
+ if (__builtin_available(macOS 11.0, *)) {
+ __collate_lookup_l((__darwin_wchar_t *)&i, &len, &cprim, &csec, LC_GLOBAL_LOCALE);
+ } else {
+ locale_t old = uselocale(LC_GLOBAL_LOCALE);
+ __collate_lookup((__darwin_wchar_t *)&i, &len, &cprim, &csec);
+ uselocale(old);
+ }
collation_weight_cache[i] = cprim;
}
--
2.46.0

View File

@ -100,8 +100,8 @@
"version": "1012"
},
"text_cmds": {
"hash": "sha256-KSebU7ZyUsPeqn51nzuGNaNxs9pvmlIQQdkWXIVzDxw=",
"version": "99"
"hash": "sha256-76dagwRcAf5fpoyH5FDR5kdCldv6Mgre6aFBzxaCRkg=",
"version": "190.0.1"
},
"top": {
"hash": "sha256-jbz64ODogtpNyLpXGSZj1jCBdFPVXcVcBkL1vc7g5qQ=",