progs/key.c: Report full parameter-key name in errors about it.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 22 Apr 2017 19:17:04 +0000 (20:17 +0100)
progs/key.c

index 0549469..597b93a 100644 (file)
@@ -242,6 +242,7 @@ static int copyparam(keyopts *k, const char **pp)
   key_attriter i;
   key_data *kd;
   const char *n, *v;
+  dstr t = DSTR_INIT;
 
   kf.f = KCAT_SHARE;
   kf.m = KF_CATMASK;
@@ -253,12 +254,17 @@ static int copyparam(keyopts *k, const char **pp)
 
   /* --- Run through the checklist --- */
 
+  key_fulltag(k->p, &t);
   while (*pp) {
     key_data *kd = key_structfind(k->p->k, *pp);
-    if (!kd)
-      die(EXIT_FAILURE, "bad parameter key: parameter `%s' not found", *pp);
-    if (!KEY_MATCH(kd, &kf))
-      die(EXIT_FAILURE, "bad parameter key: subkey `%s' is not shared", *pp);
+    if (!kd) {
+      die(EXIT_FAILURE,
+         "bad parameter key `%s': parameter `%s' not found", t.buf, *pp);
+    }
+    if (!KEY_MATCH(kd, &kf)) {
+      die(EXIT_FAILURE,
+         "bad parameter key `%s': subkey `%s' is not shared", t.buf, *pp);
+    }
     pp++;
   }
 
@@ -276,6 +282,7 @@ static int copyparam(keyopts *k, const char **pp)
 
   /* --- Done --- */
 
+  dstr_destroy(&t);
   return (1);
 }