[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH 05/17] drop getdelim/getline fallback functions
From: |
Mike Frysinger |
Subject: |
[Nano-devel] [PATCH 05/17] drop getdelim/getline fallback functions |
Date: |
Tue, 21 Feb 2017 17:04:37 -0500 |
Switch over to gnulib for these.
---
autogen.sh | 2 ++
configure.ac | 2 +-
src/nano.h | 6 -----
src/proto.h | 8 ------
src/utils.c | 87 ------------------------------------------------------------
5 files changed, 3 insertions(+), 102 deletions(-)
diff --git a/autogen.sh b/autogen.sh
index 4e7ff142b2eb..35c4f88a0584 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -5,6 +5,8 @@ gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="4084b3a1094372b960ce4a97634e08f4538c8bdd"
modules="
+ getdelim
+ getline
strcase
strcasestr-simple
strnlen
diff --git a/configure.ac b/configure.ac
index 622ac40bd97c..9247ec62121a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -473,7 +473,7 @@ int main(void)
dnl Checks for functions.
-AC_CHECK_FUNCS(getdelim getline isblank snprintf vsnprintf)
+AC_CHECK_FUNCS(isblank snprintf vsnprintf)
if test "x$enable_utf8" != xno; then
AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace nl_langinfo mblen
mbstowcs mbtowc wctomb wcwidth)
diff --git a/src/nano.h b/src/nano.h
index 2a3152965fec..82bb264cd7e8 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -137,12 +137,6 @@
#ifndef HAVE_ISWBLANK
#define iswblank niswblank
#endif
-#ifndef HAVE_GETDELIM
-#define getdelim ngetdelim
-#endif
-#ifndef HAVE_GETLINE
-#define getline ngetline
-#endif
/* If we aren't using ncurses with mouse support, turn the mouse support
* off, as it's useless then. */
diff --git a/src/proto.h b/src/proto.h
index 6e3346654664..e5dd78db55fc 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -652,14 +652,6 @@ void snuggly_fit(char **str);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void sunder(char *str);
-#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
-#ifndef HAVE_GETLINE
-ssize_t ngetline(char **lineptr, size_t *n, FILE *stream);
-#endif
-#ifndef HAVE_GETDELIM
-ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream);
-#endif
-#endif
#ifdef HAVE_REGEX_H
const char *fixbounds(const char *r);
#endif
diff --git a/src/utils.c b/src/utils.c
index 07dad2d7bc88..d5982eeead65 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -170,93 +170,6 @@ void sunder(char *str)
}
}
-/* These functions, ngetline() (originally getline()) and ngetdelim()
- * (originally getdelim()), were adapted from GNU mailutils 0.5
- * (mailbox/getline.c). Here is the notice from that file, after
- * converting to the GPL via LGPL clause 3, and with the Free Software
- * Foundation's address and the copyright years updated:
- *
- * GNU Mailutils -- a suite of utilities for electronic mail
- * Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007
- * Free Software Foundation, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301, USA. */
-
-#ifndef DISABLE_NANORC
-
-#ifndef HAVE_GETDELIM
-/* This function is equivalent to getdelim(). */
-ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream)
-{
- size_t indx = 0;
- int c;
-
- /* Sanity checks. */
- if (lineptr == NULL || n == NULL || stream == NULL ||
- fileno(stream) == -1) {
- errno = EINVAL;
- return -1;
- }
-
- /* Allocate the line the first time. */
- if (*lineptr == NULL) {
- *n = MAX_BUF_SIZE;
- *lineptr = charalloc(*n);
- }
-
- while ((c = getc(stream)) != EOF) {
- /* Check if more memory is needed. */
- if (indx >= *n) {
- *n += MAX_BUF_SIZE;
- *lineptr = charealloc(*lineptr, *n);
- }
-
- /* Put the result in the line. */
- (*lineptr)[indx++] = (char)c;
-
- /* Bail out. */
- if (c == delim)
- break;
- }
-
- /* Make room for the null character. */
- if (indx >= *n) {
- *n += MAX_BUF_SIZE;
- *lineptr = charealloc(*lineptr, *n);
- }
-
- /* Null-terminate the buffer. */
- null_at(lineptr, indx++);
- *n = indx;
-
- /* The last line may not have the delimiter. We have to return what
- * we got, and the error will be seen on the next iteration. */
- return (c == EOF && (indx - 1) == 0) ? -1 : indx - 1;
-}
-#endif
-
-#ifndef HAVE_GETLINE
-/* This function is equivalent to getline(). */
-ssize_t ngetline(char **lineptr, size_t *n, FILE *stream)
-{
- return getdelim(lineptr, n, '\n', stream);
-}
-#endif
-#endif /* !DISABLE_NANORC */
-
#ifdef HAVE_REGEX_H
/* Fix the regex if we're on platforms which require an adjustment
* from GNU-style to BSD-style word boundaries. */
--
2.11.1
- [Nano-devel] [PATCH 00/17 v3] update autotools & add gnulib support, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 06/17] drop isblank/iswblank fallback functions, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 05/17] drop getdelim/getline fallback functions,
Mike Frysinger <=
- [Nano-devel] [PATCH 04/17] drop various str fallback functions, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 01/17] configure: require autoconf-2.69/automake-1.14, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 03/17] add support for gnulib, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 08/17] assume getopt_long support is always available, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 07/17] assume regex.h support is always available, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 12/17] fix build on systems w/out pwd.h, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 09/17] drop glib fallback for snprintf/vsnprintf, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 17/17] pull in sys_wait module from gnulib, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 14/17] pull in lstat module from gnulib, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 13/17] add an explicit test for set_escdelay, Mike Frysinger, 2017/02/21