libyang CHANGE path generation optimization refactored

Fixes #242
diff --git a/src/parser_yin.c b/src/parser_yin.c
index f3baba7..658d435 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -3442,7 +3442,7 @@
     /* check - default is prohibited in combination with mandatory */
     if (dflt && (choice->flags & LYS_MAND_TRUE)) {
         LOGVAL(LYE_INCHILDSTMT, LY_VLOG_LYS, retval, "default", "choice");
-        LOGVAL(LYE_SPEC, LY_VLOG_LYS, retval, "The \"default\" statement is forbidden on choices with \"mandatory\".");
+        LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "The \"default\" statement is forbidden on choices with \"mandatory\".");
         goto error;
     }
 
@@ -3720,7 +3720,7 @@
     }
     if (leaf->dflt && (leaf->flags & LYS_MAND_TRUE)) {
         LOGVAL(LYE_INCHILDSTMT, LY_VLOG_LYS, retval, "mandatory", "leaf");
-        LOGVAL(LYE_SPEC, LY_VLOG_LYS, retval,
+        LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL,
                "The \"mandatory\" statement is forbidden on leaf with the \"default\" statement.");
         goto error;
     }
@@ -3904,7 +3904,7 @@
             llist->min = (uint32_t) val;
             if (llist->max && (llist->min > llist->max)) {
                 LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_LYS, retval, "\"min-elements\" is bigger than \"max-elements\".");
+                LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "\"min-elements\" is bigger than \"max-elements\".");
                 goto error;
             }
         } else if (!strcmp(sub->name, "max-elements")) {
@@ -3933,7 +3933,7 @@
                 llist->max = (uint32_t) val;
                 if (llist->min > llist->max) {
                     LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_LYS, retval, "\"max-elements\" is smaller than \"min-elements\".");
+                    LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "\"max-elements\" is smaller than \"min-elements\".");
                     goto error;
                 }
             }
@@ -4006,7 +4006,7 @@
                 for (r = 0; r < llist->dflt_size; r++) {
                     if (ly_strequal(llist->dflt[r], value, 1)) {
                         LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, "default");
-                        LOGVAL(LYE_SPEC, LY_VLOG_LYS, retval, "Duplicated default value \"%s\".", value);
+                        LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "Duplicated default value \"%s\".", value);
                         goto error;
                     }
                 }
@@ -4023,7 +4023,7 @@
 
     if (llist->dflt_size && llist->min) {
         LOGVAL(LYE_INCHILDSTMT, LY_VLOG_LYS, retval, "min-elements", "leaf-list");
-        LOGVAL(LYE_SPEC, LY_VLOG_LYS, retval,
+        LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL,
                "The \"min-elements\" statement with non-zero value is forbidden on leaf-lists with the \"default\" statement.");
         goto error;
     }
@@ -4199,7 +4199,7 @@
             list->min = (uint32_t) val;
             if (list->max && (list->min > list->max)) {
                 LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_LYS, retval, "\"min-elements\" is bigger than \"max-elements\".");
+                LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "\"min-elements\" is bigger than \"max-elements\".");
                 lyxml_free(module->ctx, sub);
                 goto error;
             }
@@ -4230,7 +4230,7 @@
                 list->max = (uint32_t) val;
                 if (list->min > list->max) {
                     LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_LYS, retval, "\"max-elements\" is smaller than \"min-elements\".");
+                    LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "\"max-elements\" is smaller than \"min-elements\".");
                     goto error;
                 }
             }