nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH 3/8] drop getdelim/getline fallback functions


From: Mike Frysinger
Subject: [Nano-devel] [PATCH 3/8] drop getdelim/getline fallback functions
Date: Sat, 6 Feb 2016 19:03:56 -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 e3dd617..ec29cf3 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -2,6 +2,8 @@
 # Generate configure & friends for CVS users.
 
 modules="
+       getdelim
+       getline
        strcase
        strcasestr-simple
        strnlen
diff --git a/configure.ac b/configure.ac
index 8d258dd..fa57e35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -434,7 +434,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 4296724..9d68910 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -134,12 +134,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 92f8960..f9148db 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -704,14 +704,6 @@ void align(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 6bd8b57..9cad6b9 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -153,93 +153,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.6.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]