libopkg: do not rely on getline()
[oweals/opkg-lede.git] / libopkg / pkg_hash.c
index 2a76be886bff273a12eafdce8cca2bb246174daa..7f76da130d0c5f20be22e4fe203c1a2574ad99bc 100644 (file)
@@ -23,6 +23,7 @@
 #include "opkg_message.h"
 #include "pkg_vec.h"
 #include "pkg_hash.h"
+#include "parse_util.h"
 #include "pkg_parse.h"
 #include "opkg_utils.h"
 #include "sprintf_alloc.h"
@@ -119,8 +120,14 @@ pkg_hash_add_from_file(const char *file_name,
                pkg->src = src;
                pkg->dest = dest;
 
-               ret = pkg_parse_from_stream_nomalloc(pkg, fp, 0,
+               ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, 0,
                                &buf, len);
+
+               if (pkg->name == NULL) {
+                       /* probably just a blank line */
+                       ret = 1;
+               }
+
                if (ret) {
                        pkg_deinit (pkg);
                        free(pkg);