From 5761ea2c14a144f7584f02583b57a64449393a88 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Fri, 10 Aug 2007 17:03:29 +0000 Subject: [PATCH] simplify ngetdelim(), and update the copyright notice on ngetline() and ngetdelim() to account for modifications git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_0_branch/nano@4144 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/utils.c | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3bcacf5e..5f273d3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,6 +44,11 @@ CVS code - - Fix problem where replacing e.g. single-byte characters with multibyte ones could result in openfile->totsize's being miscalculated. (DLR) +- utils.c: + ngetline(), ngetdelim() + - Update copyright notice to account for modifications. (DLR) + ngetdelim() + - Simplify. (DLR) - winio.c: get_key_buffer() - Fix inaccurate comments. (DLR) diff --git a/src/utils.c b/src/utils.c index 38c31348..7785c7cf 100644 --- a/src/utils.c +++ b/src/utils.c @@ -165,7 +165,8 @@ void sunder(char *str) * Foundation's address updated: * * GNU Mailutils -- a suite of utilities for electronic mail - * Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + * 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 @@ -207,15 +208,15 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream) /* Allocate the line the first time. */ if (*lineptr == NULL) { - *lineptr = charalloc(MAX_BUF_SIZE); *n = MAX_BUF_SIZE; + *lineptr = charalloc(*n); } while ((c = getc(stream)) != EOF) { /* Check if more memory is needed. */ if (indx >= *n) { - *lineptr = charealloc(*lineptr, *n + MAX_BUF_SIZE); *n += MAX_BUF_SIZE; + *lineptr = charealloc(*lineptr, *n); } /* Put the result in the line. */ @@ -228,8 +229,8 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream) /* Make room for the null character. */ if (indx >= *n) { - *lineptr = charealloc(*lineptr, *n + MAX_BUF_SIZE); *n += MAX_BUF_SIZE; + *lineptr = charealloc(*lineptr, *n); } /* Null-terminate the buffer. */ -- 2.39.5