context: Maintain list of failed include paths
authorDaniel Stone <daniel@fooishbar.org>
Fri, 3 Aug 2012 01:11:19 +0000 (03:11 +0200)
committerDaniel Stone <daniel@fooishbar.org>
Wed, 8 Aug 2012 14:23:30 +0000 (16:23 +0200)
Keep around a list of paths we tried to add but couldn't.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
src/context.c

index 81c008b..c9d90bd 100644 (file)
@@ -45,6 +45,7 @@ struct xkb_context {
     void *user_data;
 
     darray(char *) includes;
+    darray(char *) failed_includes;
 
     /* xkbcomp needs to assign sequential IDs to XkbFile's it creates. */
     unsigned file_id;
@@ -62,26 +63,30 @@ xkb_context_include_path_append(struct xkb_context *ctx, const char *path)
     int err;
     char *tmp;
 
+    tmp = strdup(path);
+    if (!tmp)
+        goto err;
+
     err = stat(path, &stat_buf);
     if (err != 0)
-        return 0;
+        goto err;
     if (!S_ISDIR(stat_buf.st_mode))
-        return 0;
+        goto err;
 
 #if defined(HAVE_EACCESS)
     if (eaccess(path, R_OK | X_OK) != 0)
-        return 0;
+        goto err;
 #elif defined(HAVE_EUIDACCESS)
     if (euidaccess(path, R_OK | X_OK) != 0)
-        return 0;
+        goto err;
 #endif
 
-    tmp = strdup(path);
-    if (!tmp)
-        return 0;
-
     darray_append(ctx->includes, tmp);
     return 1;
+
+err:
+    darray_append(ctx->failed_includes, tmp);
+    return 0;
 }
 
 /**
@@ -118,9 +123,12 @@ xkb_context_include_path_clear(struct xkb_context *ctx)
     char **path;
 
     darray_foreach(path, ctx->includes)
-    free(*path);
-
+        free(*path);
     darray_free(ctx->includes);
+
+    darray_foreach(path, ctx->failed_includes)
+        free(*path);
+    darray_free(ctx->failed_includes);
 }
 
 /**