about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2013-11-13 22:14:27 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2013-11-13 22:14:27 +0000
commit7a94960957e37c198e93dfbd7af864799b01650d (patch)
treebd38804dad3cfec7f90b92bc5e7830f84728f7a6
parent128034e2118036e3012b9a41520467e257ed263a (diff)
downloadzsh-7a94960957e37c198e93dfbd7af864799b01650d.tar.gz
zsh-7a94960957e37c198e93dfbd7af864799b01650d.tar.xz
zsh-7a94960957e37c198e93dfbd7af864799b01650d.zip
31977: It's OK to autoload a feature that's loaded.
Simply check that the feature is from the same module that's requested.
-rw-r--r--ChangeLog3
-rw-r--r--Src/module.c15
2 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 18538a5a1..63eca13a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2013-11-13  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 31977: Src/module.c: no error if autoloading a feature that
+	is already loaded in a consistent fashion.
+
 	* Jun T.: 31971: locale fix for helpfiles.
 
 	* Martin Vaeth: 31959: .gitignore, Doc/help/.cvsignore,
diff --git a/Src/module.c b/Src/module.c
index 5cc595c47..f5479c1a6 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -3419,12 +3419,15 @@ autofeatures(const char *cmdnam, const char *module, char **features,
     int ret = 0, subret;
     Module defm, m;
     char **modfeatures = NULL;
+    int *modenables = NULL;
     if (module) {
 	defm = (Module)find_module(module,
 				   FINDMOD_ALIASP|FINDMOD_CREATE, NULL);
 	if ((defm->node.flags & MOD_LINKED) ? defm->u.linked :
-	    defm->u.handle)
+	    defm->u.handle) {
 	    (void)features_module(defm, &modfeatures);
+	    (void)enables_module(defm, &modenables);
+	}
     } else
 	defm = NULL;
 
@@ -3544,6 +3547,16 @@ autofeatures(const char *cmdnam, const char *module, char **features,
 		    ret = 1;
 		    continue;
 		}
+		/*
+		 * If the feature is already provided by the module, there's
+		 * nothing more to do.
+		 */
+		if (modenables[ptr-modfeatures])
+		    continue;
+		/*
+		 * Otherwise, marking it for autoload will do the
+		 * right thing when the feature is eventually used.
+		 */
 	    }
 	    if (!m->autoloads) {
 		m->autoloads = znewlinklist();