diff --git a/racket/src/native-libs/README.txt b/racket/src/native-libs/README.txt index 2891ce9771..f70ee8857b 100644 --- a/racket/src/native-libs/README.txt +++ b/racket/src/native-libs/README.txt @@ -18,6 +18,7 @@ Currently, we use the following external packages and versions: pkg-config-0.28 sed-4.2 (Windows only, to avoid non-GNU `sed`) sqlite[-autoconf]-3220000 (Windows, Linux, and PPC Mac OS only) + libedit-20191231-3.1 (Mac OS only) openssl-1.1.1g libiconv-1.15 (Windows only) zlib-1.2.11 (Windows and Linux only) diff --git a/racket/src/native-libs/build.rkt b/racket/src/native-libs/build.rkt index 09cc5c32b9..b63f45ab1f 100644 --- a/racket/src/native-libs/build.rkt +++ b/racket/src/native-libs/build.rkt @@ -154,6 +154,9 @@ ;; Needed when building with old GCC, such as 4.0: (define-runtime-path gmp-weak-patch "patches/gmp-weak.patch") +;; For `getline` on 32-bit Mac OS 10.6: +(define-runtime-path libedit-getline-patch "patches/libedit-getline.patch") + ;; Upstream patch to fix Win32 build: (define-runtime-path glib-win32-weekday-patch "patches/glib-win32-weekday.patch") @@ -359,6 +362,10 @@ [("pkg-config") (config #:configure (list "--with-internal-glib"))] [("sed") (config)] [("longdouble") (config)] + [("libedit") (config + #:patches (if (and mac? m32?) + (list libedit-getline-patch) + null))] [("libiconv") (nonmac-only) (config)] diff --git a/racket/src/native-libs/install.rkt b/racket/src/native-libs/install.rkt index 9a11827401..873ce71872 100644 --- a/racket/src/native-libs/install.rkt +++ b/racket/src/native-libs/install.rkt @@ -42,7 +42,8 @@ "libpangowin32-1.0.0")) (define mac-libs - '("PSMTabBarControl.framework")) + '("libedit.0" + "PSMTabBarControl.framework")) (define mac64-libs '("MMTabBarView.framework")) @@ -129,7 +130,10 @@ ["libiconv-2" "libiconv is released under the GNU Lesser General Public License (GNU LGPL)."] ["longdouble" ,(~a "The source to longdouble is included with the Racket source code,\n" "which is available from\n" - " http://www.racket-lang.org/")])] + " http://www.racket-lang.org/")] + ["libedit" ,(~a "This package includes libedit software developed for NetBSD under the\n" + "NetBSD license.")])] + ["math" "" "math" diff --git a/racket/src/native-libs/patches/libedit-getline.patch b/racket/src/native-libs/patches/libedit-getline.patch new file mode 100644 index 0000000000..9fd3e46391 --- /dev/null +++ b/racket/src/native-libs/patches/libedit-getline.patch @@ -0,0 +1,62 @@ +diff -u -r old/libedit-20191231-3.1/src/sys.h new/libedit-20191231-3.1/src/sys.h +--- old/libedit-20191231-3.1/src/sys.h 2020-08-27 10:57:43.000000000 -0600 ++++ new/libedit-20191231-3.1/src/sys.h 2020-08-27 10:57:56.000000000 -0600 +@@ -43,6 +43,7 @@ + #ifdef HAVE_SYS_CDEFS_H + #include + #endif ++#include + + #if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) + # define __attribute__(A) +diff -u -r old/libedit-20191231-3.1/src/wcsdup.c new/libedit-20191231-3.1/src/wcsdup.c +--- old/libedit-20191231-3.1/src/wcsdup.c 2020-08-27 10:57:43.000000000 -0600 ++++ new/libedit-20191231-3.1/src/wcsdup.c 2020-08-27 12:03:37.000000000 -0600 +@@ -41,3 +41,46 @@ + } + + #endif ++ ++ ++#ifndef HAVE_GETLINE ++#include ++#include ++#include ++#include ++ ++ssize_t getline(char **line, size_t *len, FILE *fp) { ++ char *buffer, *r; ++ int buflen, delta = 0, slen; ++ ++ if (*line == NULL) { ++ buflen = 256; ++ buffer = malloc(buflen); ++ } else { ++ buffer = *line; ++ buflen = *len; ++ if (buflen == 0) { ++ buflen = 128; ++ buffer = realloc(buffer, buflen); ++ } ++ } ++ ++ while (1) { ++ r = fgets(buffer + delta, buflen - delta, fp); ++ if (!r) { ++ if (delta == 0) ++ return -1; ++ } ++ delta += strlen(buffer + delta); ++ if ((delta > 0) && (buffer[delta-1] == '\n')) { ++ *line = buffer; ++ *len = buflen; ++ return delta; ++ } ++ if (delta + 1 == buflen) { ++ buflen *= 2; ++ buffer = realloc(buffer, buflen); ++ } ++ } ++} ++#endif +Only in new/libedit-20191231-3.1/src: wcsdup.c~