lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [1/4] git commit: .cfp validity checks
Date Wed, 12 Mar 2014 12:36:36 GMT
Repository: lucy-clownfish
Updated Branches:
  refs/heads/explicit-dependencies [created] 3e08f203a


.cfp validity checks

- Check that .cfp contains a hash.
- Simplify check for invalid keys.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/0d8143ab
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/0d8143ab
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/0d8143ab

Branch: refs/heads/explicit-dependencies
Commit: 0d8143ab83e88f069a9fffb6935b19962f3d41ed
Parents: 6393be8
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Wed Mar 12 13:09:06 2014 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Wed Mar 12 13:09:06 2014 +0100

----------------------------------------------------------------------
 compiler/src/CFCParcel.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0d8143ab/compiler/src/CFCParcel.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.c b/compiler/src/CFCParcel.c
index bb6eb56..7674d05 100644
--- a/compiler/src/CFCParcel.c
+++ b/compiler/src/CFCParcel.c
@@ -256,6 +256,9 @@ S_new_from_json(const char *json, const char *path, int is_included) {
     if (!parsed) {
         CFCUtil_die("Invalid JSON parcel definition in '%s'", path);
     }
+    if (parsed->type != JSON_HASH) {
+        CFCUtil_die("Parcel definition must be a hash in '%s'", path);
+    }
     const char *name     = NULL;
     const char *nickname = NULL;
     CFCVersion *version  = NULL;
@@ -285,6 +288,10 @@ S_new_from_json(const char *json, const char *path, int is_included)
{
             }
             version = CFCVersion_new(value->string);
         }
+        else {
+            CFCUtil_die("Unrecognized key: '%s' (filepath '%s')",
+                        key->string, path);
+        }
     }
     if (!name) {
         CFCUtil_die("Missing required key 'name' (filepath '%s')", path);
@@ -295,20 +302,6 @@ S_new_from_json(const char *json, const char *path, int is_included)
{
     CFCParcel *self = CFCParcel_new(name, nickname, version, is_included);
     CFCBase_decref((CFCBase*)version);
 
-    for (size_t i = 0, max = parsed->num_kids; i < max; i += 2) {
-        JSONNode *key   = parsed->kids[i];
-        if (strcmp(key->string, "name") == 0
-            || strcmp(key->string, "nickname") == 0
-            || strcmp(key->string, "version") == 0
-           ) {
-            ;
-        }
-        else {
-            CFCUtil_die("Unrecognized key: '%s' (filepath '%s')",
-                        key->string, path);
-        }
-    }
-
     S_destroy_json(parsed);
     return self;
 }


Mime
View raw message