yanglint REFACTOR setting of --disable-searchdir
diff --git a/tools/lint/cmd_add.c b/tools/lint/cmd_add.c
index 744ea80..97ef94c 100644
--- a/tools/lint/cmd_add.c
+++ b/tools/lint/cmd_add.c
@@ -75,12 +75,7 @@
             if (yo->ctx_options & LY_CTX_DISABLE_SEARCHDIRS) {
                 YLMSG_W("The -D option specified too many times.\n");
             }
-            if (yo->ctx_options & LY_CTX_DISABLE_SEARCHDIR_CWD) {
-                yo->ctx_options &= ~LY_CTX_DISABLE_SEARCHDIR_CWD;
-                yo->ctx_options |= LY_CTX_DISABLE_SEARCHDIRS;
-            } else {
-                yo->ctx_options |= LY_CTX_DISABLE_SEARCHDIR_CWD;
-            }
+            yo_opt_update_disable_searchdir(yo);
             break;
 
         case 'F': /* --features */
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 40e4df8..637c7f4 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -549,16 +549,11 @@
             break;
         /* case 'p' */
 
-        case 'D': /* --disable-search */
+        case 'D': /* --disable-searchdir */
             if (yo->ctx_options & LY_CTX_DISABLE_SEARCHDIRS) {
                 YLMSG_W("The -D option specified too many times.\n");
             }
-            if (yo->ctx_options & LY_CTX_DISABLE_SEARCHDIR_CWD) {
-                yo->ctx_options &= ~LY_CTX_DISABLE_SEARCHDIR_CWD;
-                yo->ctx_options |= LY_CTX_DISABLE_SEARCHDIRS;
-            } else {
-                yo->ctx_options |= LY_CTX_DISABLE_SEARCHDIR_CWD;
-            }
+            yo_opt_update_disable_searchdir(yo);
             break;
 
         case 'F': /* --features */
diff --git a/tools/lint/yl_opt.c b/tools/lint/yl_opt.c
index 1d21eb8..20fbf1f 100644
--- a/tools/lint/yl_opt.c
+++ b/tools/lint/yl_opt.c
@@ -246,6 +246,17 @@
 }
 
 void
+yo_opt_update_disable_searchdir(struct yl_opt *yo)
+{
+    if (yo->ctx_options & LY_CTX_DISABLE_SEARCHDIR_CWD) {
+        yo->ctx_options &= ~LY_CTX_DISABLE_SEARCHDIR_CWD;
+        yo->ctx_options |= LY_CTX_DISABLE_SEARCHDIRS;
+    } else {
+        yo->ctx_options |= LY_CTX_DISABLE_SEARCHDIR_CWD;
+    }
+}
+
+void
 free_cmdline(char *argv[])
 {
     if (argv) {
diff --git a/tools/lint/yl_opt.h b/tools/lint/yl_opt.h
index e0ff7bd..9dffd7d 100644
--- a/tools/lint/yl_opt.h
+++ b/tools/lint/yl_opt.h
@@ -213,6 +213,13 @@
 void yo_opt_update_make_implemented(struct yl_opt *yo);
 
 /**
+ * @brief Update @p yo according to the --disable-searchdir parameter.
+ *
+ * @param[in,out] yo yanglint options used to update.
+ */
+void yo_opt_update_disable_searchdir(struct yl_opt *yo);
+
+/**
  * @brief Helper function to prepare argc, argv pair from a command line string.
  *
  * @param[in] cmdline Complete command line string.