git: 975ef9b92524 - main - textproc/msort: remove unnecessicary sbrk use

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Fri, 08 Dec 2023 23:31:01 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/ports/commit/?id=975ef9b925241898716a6782a26b4b775bb957f1

commit 975ef9b925241898716a6782a26b4b775bb957f1
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-12-07 00:28:20 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-12-08 23:29:38 +0000

    textproc/msort: remove unnecessicary sbrk use
---
 textproc/msort/Makefile            |  5 +----
 textproc/msort/files/patch-msort.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/textproc/msort/Makefile b/textproc/msort/Makefile
index 575c51b0e61a..9f22d2bf9d18 100644
--- a/textproc/msort/Makefile
+++ b/textproc/msort/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	msort
 PORTVERSION=	8.53
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	textproc
 MASTER_SITES=	http://billposer.org/Software/Downloads/
 
@@ -11,9 +11,6 @@ WWW=		https://billposer.org/Software/msort.html
 LICENSE=	GPLv3
 LICENSE_FILE=	${WRKSRC}/COPYING
 
-BROKEN_aarch64=		fails to link: missing sbrk
-BROKEN_riscv64=		fails to link: missing sbrk
-
 LIB_DEPENDS=	libtre.so:textproc/libtre \
 		libuninum.so:devel/libuninum \
 		libutf8proc.so:textproc/utf8proc
diff --git a/textproc/msort/files/patch-msort.c b/textproc/msort/files/patch-msort.c
new file mode 100644
index 000000000000..16c6763655b0
--- /dev/null
+++ b/textproc/msort/files/patch-msort.c
@@ -0,0 +1,38 @@
+--- msort.c.orig
++++ msort.c
+@@ -639,7 +639,6 @@
+   char *endptr;			/* Used by strtol */
+   char * tmpstr;
+   char *FirstLocale = NULL;
+-  void *InitialBreak;
+   int lgoindex;			/* Unused but needed by getopt_long */
+   char t;
+ #ifndef USEUTF8PROC
+@@ -720,7 +719,6 @@
+   xav = av;
+   xac = ac;
+ 
+-  InitialBreak = sbrk(0);
+ #ifdef HAVE_SETLOCALE
+    (void) setlocale(LC_ALL,"");
+ #endif
+@@ -1946,18 +1944,14 @@
+ 
+   if(LogP) {
+ 
+-    /* Record random number generator seed, dynamic memory usage and number of comparisons */
++    /* Record random number generator seed and number of comparisons */
+ #ifdef HAVE_PRINTF_THSEP
+-    PrintLog(_("Dynamically allocated memory: %'15d bytes\n"),
+-	     ((char *)sbrk(0) - (char *)InitialBreak));
+     PrintLog(_("Random number generator seed: %15u\n"),RandomSeed);
+ #ifndef NOCOMPARISONCNT
+     PrintLog(_("Comparisons:                  %'15llu\n"),ComparisonCnt);
+     if(VerboseP) fprintf(stderr,_("Comparisons:                  %'15llu\n"),ComparisonCnt);
+ #endif
+ #else
+-    PrintLog("Dynamically allocated memory: %d bytes\n",
+-	     ((char *)sbrk(0) - (char *)InitialBreak));
+     PrintLog(_("Random number generator seed: %15u\n"),RandomSeed);
+ #ifndef NOCOMPARISONCNT
+     PrintLog(_("Comparisons:      %'14llu\n"),ComparisonCnt);