You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2014/03/17 21:36:17 UTC
[lucy-commits] [04/11] git commit: .cfp validity checks
.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/eb4d676e
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/eb4d676e
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/eb4d676e
Branch: refs/heads/master
Commit: eb4d676e830bd9bc7947e47a6551f9273c678793
Parents: c596e63
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed Mar 12 13:09:06 2014 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon Mar 17 18:25:29 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/eb4d676e/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;
}