use helper in cmd node
[protos/libecoli.git] / lib / ecoli_node_file.c
index ab772dc..001dcb6 100644 (file)
@@ -17,7 +17,7 @@
 #include <ecoli_strvec.h>
 #include <ecoli_string.h>
 #include <ecoli_node.h>
-#include <ecoli_parsed.h>
+#include <ecoli_parse.h>
 #include <ecoli_complete.h>
 #include <ecoli_node_file.h>
 
@@ -38,14 +38,14 @@ struct ec_node_file {
 
 static int
 ec_node_file_parse(const struct ec_node *gen_node,
-               struct ec_parsed *state,
+               struct ec_parse *state,
                const struct ec_strvec *strvec)
 {
        (void)gen_node;
        (void)state;
 
        if (ec_strvec_len(strvec) == 0)
-               return EC_PARSED_NOMATCH;
+               return EC_PARSE_NOMATCH;
 
        return 1;
 }
@@ -161,13 +161,17 @@ ec_node_file_complete(const struct ec_node *gen_node,
 
        bname_len = strlen(bname);
        while (1) {
+               int save_errno = errno;
+
                errno = 0;
                de = node->readdir(dir);
                if (de == NULL) {
-                       if (errno == 0)
+                       if (errno == 0) {
+                               errno = save_errno;
                                goto out;
-                       else
+                       } else {
                                goto fail;
+                       }
                }
 
                if (!ec_str_startswith(de->d_name, bname))