OSDN Git Service

Fix nasty behavior difference from glibc -- also fixes getline()
authorEric Andersen <andersen@codepoet.org>
Sun, 30 Sep 2001 04:55:22 +0000 (04:55 -0000)
committerEric Andersen <andersen@codepoet.org>
Sun, 30 Sep 2001 04:55:22 +0000 (04:55 -0000)
 -Erik

libc/stdio/getdelim.c

index 65d5738..7cc1f8e 100644 (file)
@@ -41,13 +41,12 @@ ssize_t getdelim(char **linebuf, size_t *linebufsz, int delimiter, FILE *file)
        int ch;
        int idx = 0;
 
-       if ((file == NULL || linebuf==NULL || *linebuf == NULL || *linebufsz == 0)
-                       && !(*linebuf == NULL && *linebufsz ==0 )) {
+       if (file == NULL || linebuf==NULL || linebufsz == NULL) {
            __set_errno(EINVAL);
            return -1;
        }
 
-       if (*linebuf == NULL && *linebufsz == 0){
+       if (*linebuf == NULL || *linebufsz < 2) {
                *linebuf = malloc(GROWBY);
                if (!*linebuf) {
                        __set_errno(ENOMEM);