in ngetdelim(), do sanity checks manually again instead of in an assert,

and set errno to EINVAL as well as return -1 if they fail; this matches
the manual page


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3262 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey 2006-01-09 03:23:29 +00:00
parent db2dc81cee
commit 76f9485b02
2 changed files with 10 additions and 2 deletions

View File

@ -17,6 +17,11 @@ CVS code -
- chars.c: - chars.c:
mbstrchr() mbstrchr()
- Make parameter c const. (DLR) - Make parameter c const. (DLR)
- utils.c:
ngetdelim()
- Do sanity checks manually again instead of in an assert, and
set errno to EINVAL as well as return -1 if they fail. This
matches the manual page. (DLR)
- winio.c: - winio.c:
edit_scroll() edit_scroll()
- Redraw the lines before and after the scrolled region even if - Redraw the lines before and after the scrolled region even if

View File

@ -3,7 +3,7 @@
* utils.c * * utils.c *
* * * *
* Copyright (C) 1999-2004 Chris Allegretta * * Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey * * Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) * * the Free Software Foundation; either version 2, or (at your option) *
@ -197,7 +197,10 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream)
int c; int c;
/* Sanity checks. */ /* Sanity checks. */
assert(lineptr != NULL && n != NULL && stream != NULL); if (lineptr == NULL || n == NULL || stream == NULL) {
errno = EINVAL;
return -1;
}
/* Allocate the line the first time. */ /* Allocate the line the first time. */
if (*lineptr == NULL) { if (*lineptr == NULL) {