Revision: 149803 https://trac.macports.org/changeset/149803 Author: jmr@macports.org Date: 2016-06-30 02:02:15 -0700 (Thu, 30 Jun 2016) Log Message: ----------- libedit: add a getline implementation for older systems Modified Paths: -------------- trunk/dports/devel/libedit/Portfile Added Paths: ----------- trunk/dports/devel/libedit/files/configure.patch trunk/dports/devel/libedit/files/getline.c trunk/dports/devel/libedit/files/src__Makefile.in.patch Modified: trunk/dports/devel/libedit/Portfile =================================================================== --- trunk/dports/devel/libedit/Portfile 2016-06-30 07:33:46 UTC (rev 149802) +++ trunk/dports/devel/libedit/Portfile 2016-06-30 09:02:15 UTC (rev 149803) @@ -25,8 +25,15 @@ depends_lib port:ncurses -patchfiles doc__Makefile.in.patch src__sys.h.patch +patchfiles doc__Makefile.in.patch \ + src__Makefile.in.patch \ + src__sys.h.patch \ + configure.patch +post-patch { + copy ${filespath}/getline.c ${worksrcpath}/src +} + configure.args --disable-silent-rules --disable-examples livecheck.type regex Added: trunk/dports/devel/libedit/files/configure.patch =================================================================== --- trunk/dports/devel/libedit/files/configure.patch (rev 0) +++ trunk/dports/devel/libedit/files/configure.patch 2016-06-30 09:02:15 UTC (rev 149803) @@ -0,0 +1,26 @@ +--- configure.orig 2016-06-18 22:35:29.000000000 +1000 ++++ configure 2016-06-30 18:41:02.000000000 +1000 +@@ -13623,6 +13623,23 @@ + fi + + ++# getline ++ac_fn_c_check_func "$LINENO" "getline" "ac_cv_func_getline" ++if test "x$ac_cv_func_getline" = xyes; then : ++ found_getline=yes ++else ++ found_getline=no ++fi ++ ++ if test "x$found_getline" = xyes; then ++ HAVE_GETLINE_TRUE= ++ HAVE_GETLINE_FALSE='#' ++else ++ HAVE_GETLINE_TRUE='#' ++ HAVE_GETLINE_FALSE= ++fi ++ ++ + # vis + ac_fn_c_check_func "$LINENO" "vis" "ac_cv_func_vis" + if test "x$ac_cv_func_vis" = xyes; then : Added: trunk/dports/devel/libedit/files/getline.c =================================================================== --- trunk/dports/devel/libedit/files/getline.c (rev 0) +++ trunk/dports/devel/libedit/files/getline.c 2016-06-30 09:02:15 UTC (rev 149803) @@ -0,0 +1,60 @@ +/* CC0, from https://github.com/digilus/getline */ + +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#define GETLINE_MINSIZE 16 +ssize_t getline(char **lineptr, size_t *n, FILE *fp) { + int ch; + int i = 0; + char free_on_err = 0; + char *p; + + errno = 0; + if (lineptr == NULL || n == NULL || fp == NULL) { + errno = EINVAL; + return -1; + } + if (*lineptr == NULL) { + *n = GETLINE_MINSIZE; + *lineptr = (char *)malloc( sizeof(char) * (*n)); + if (*lineptr == NULL) { + errno = ENOMEM; + return -1; + } + free_on_err = 1; + } + + for (i=0; ; i++) { + ch = fgetc(stream); + while (i >= (*n) - 2) { + *n *= 2; + p = realloc(*lineptr, sizeof(char) * (*n)); + if (p == NULL) { + if (free_on_err) + free(*lineptr); + errno = ENOMEM; + return -1; + } + *lineptr = p; + } + if (ch == EOF) { + if (i == 0) { + if (free_on_err) + free(*lineptr); + return -1; + } + (*lineptr)[i] = '\0'; + *n = i; + return i; + } + + if (ch == '\n') { + (*lineptr)[i] = '\n'; + (*lineptr)[i+1] = '\0'; + *n = i+1; + return i+1; + } + (*lineptr)[i] = (char)ch; + } +} Added: trunk/dports/devel/libedit/files/src__Makefile.in.patch =================================================================== --- trunk/dports/devel/libedit/files/src__Makefile.in.patch (rev 0) +++ trunk/dports/devel/libedit/files/src__Makefile.in.patch 2016-06-30 09:02:15 UTC (rev 149803) @@ -0,0 +1,34 @@ +--- src/Makefile.in.orig 2016-06-18 22:35:31.000000000 +1000 ++++ src/Makefile.in 2016-06-30 18:37:25.000000000 +1000 +@@ -93,6 +93,7 @@ + @HAVE_STRLCAT_FALSE@am__append_2 = strlcat.c + @HAVE_VIS_FALSE@am__append_3 = vis.c + @HAVE_UNVIS_FALSE@am__append_4 = unvis.c ++@HAVE_GETLINE_FALSE@am__append_5 = getline.c + subdir = src + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 + am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ +@@ -149,12 +150,13 @@ + @HAVE_STRLCAT_FALSE@am__objects_2 = strlcat.lo + @HAVE_VIS_FALSE@am__objects_3 = vis.lo + @HAVE_UNVIS_FALSE@am__objects_4 = unvis.lo ++@HAVE_GETLINE_FALSE@am__objects_6 = getline.lo + am_libedit_la_OBJECTS = chared.lo common.lo el.lo eln.lo emacs.lo \ + hist.lo keymacro.lo map.lo chartype.lo parse.lo prompt.lo \ + read.lo refresh.lo search.lo sig.lo terminal.lo tty.lo vi.lo \ + wcsdup.lo tokenizer.lo tokenizern.lo history.lo historyn.lo \ + filecomplete.lo readline.lo $(am__objects_1) $(am__objects_2) \ +- $(am__objects_3) $(am__objects_4) ++ $(am__objects_3) $(am__objects_4) $(am__objects_6) + am__objects_5 = + nodist_libedit_la_OBJECTS = $(am__objects_5) + libedit_la_OBJECTS = $(am_libedit_la_OBJECTS) \ +@@ -360,7 +362,7 @@ + parse.h prompt.h read.h refresh.h search.h sig.h sys.h \ + terminal.h tty.h vis.h filecomplete.h editline/readline.h \ + $(am__append_1) $(am__append_2) $(am__append_3) \ +- $(am__append_4) ++ $(am__append_4) $(am__append_5) + EXTRA_DIST = makelist shlib_version + nobase_include_HEADERS = histedit.h editline/readline.h + nodist_libedit_la_SOURCES = $(BUILT_SOURCES)
participants (1)
-
jmr@macports.org