Open the source before creating the destination.
[oweals/busybox.git] / libbb / get_line_from_file.c
index 759481731f49a1f4f6479c6fe5cfb6fd629ad30c..5e7062127d4c26cb9568019828f7fe64c2ea7e9c 100644 (file)
@@ -2,9 +2,8 @@
 /*
  * Utility routines.
  *
- * Copyright (C) tons of folks.  Tracking down who wrote what
- * isn't something I'm going to worry about...  If you wrote something
- * here, please feel free to acknowledge your work.
+ * Copyright (C) many different people.  If you wrote this, please
+ * acknowledge your work.
  *
  * 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
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Based in part on code from sash, Copyright (c) 1999 by David I. Bell 
- * Permission has been granted to redistribute this code under the GPL.
- *
  */
 
 #include <stdio.h>
@@ -50,7 +45,7 @@ extern char *get_line_from_file(FILE *file)
                while (idx > linebufsz-2)
                        linebuf = xrealloc(linebuf, linebufsz += GROWBY);
                linebuf[idx++] = (char)ch;
-               if ((char)ch == '\n')
+               if (ch == '\n' || ch == '\0')
                        break;
        }