simplify ngetdelim(), and update the copyright notice on ngetline() and
ngetdelim() to account for modifications git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4144 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
d5a9800fb6
commit
273c1139c0
|
@ -1,3 +1,9 @@
|
||||||
|
2007-08-10 David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
|
|
||||||
|
* utils.c (ngetdelim): Simplify.
|
||||||
|
* utils.c (ngetline, ngetdelim): Update copyright notice to
|
||||||
|
account for modifications.
|
||||||
|
|
||||||
2007-08-07 David Lawrence Ramsey <pooka109@gmail.com>
|
2007-08-07 David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
|
|
||||||
* nano.c (copy_from_file): Fix potential segfault, found by Paul
|
* nano.c (copy_from_file): Fix potential segfault, found by Paul
|
||||||
|
|
|
@ -165,7 +165,8 @@ void sunder(char *str)
|
||||||
* Foundation's address updated:
|
* Foundation's address updated:
|
||||||
*
|
*
|
||||||
* GNU Mailutils -- a suite of utilities for electronic mail
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as
|
* 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. */
|
/* Allocate the line the first time. */
|
||||||
if (*lineptr == NULL) {
|
if (*lineptr == NULL) {
|
||||||
*lineptr = charalloc(MAX_BUF_SIZE);
|
|
||||||
*n = MAX_BUF_SIZE;
|
*n = MAX_BUF_SIZE;
|
||||||
|
*lineptr = charalloc(*n);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((c = getc(stream)) != EOF) {
|
while ((c = getc(stream)) != EOF) {
|
||||||
/* Check if more memory is needed. */
|
/* Check if more memory is needed. */
|
||||||
if (indx >= *n) {
|
if (indx >= *n) {
|
||||||
*lineptr = charealloc(*lineptr, *n + MAX_BUF_SIZE);
|
|
||||||
*n += MAX_BUF_SIZE;
|
*n += MAX_BUF_SIZE;
|
||||||
|
*lineptr = charealloc(*lineptr, *n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put the result in the line. */
|
/* 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. */
|
/* Make room for the null character. */
|
||||||
if (indx >= *n) {
|
if (indx >= *n) {
|
||||||
*lineptr = charealloc(*lineptr, *n + MAX_BUF_SIZE);
|
|
||||||
*n += MAX_BUF_SIZE;
|
*n += MAX_BUF_SIZE;
|
||||||
|
*lineptr = charealloc(*lineptr, *n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Null-terminate the buffer. */
|
/* Null-terminate the buffer. */
|
||||||
|
|
Loading…
Reference in New Issue