about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorFrank Terbeck <bewater@users.sourceforge.net>2011-04-18 20:36:31 +0000
committerFrank Terbeck <bewater@users.sourceforge.net>2011-04-18 20:36:31 +0000
commit32974286d41f0041aa6c26157e1a69e193d3b1fa (patch)
tree9c551b43c30b125b2dad0c5ed72dc654f679bd6f /Src
parent95b83f217d7ec89be0a05437b8dccf96f7d15dd8 (diff)
downloadzsh-32974286d41f0041aa6c26157e1a69e193d3b1fa.tar.gz
zsh-32974286d41f0041aa6c26157e1a69e193d3b1fa.tar.xz
zsh-32974286d41f0041aa6c26157e1a69e193d3b1fa.zip
29008, 29012: Add `--enable-additional-fpath' option to add arbitrary directories to the default `$fpath'.
Diffstat (limited to 'Src')
-rw-r--r--Src/init.c21
-rw-r--r--Src/zsh.mdd4
2 files changed, 23 insertions, 2 deletions
diff --git a/Src/init.c b/Src/init.c
index aa052d834..0fcecef1a 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -676,11 +676,15 @@ setupvals(void)
     struct timezone dummy_tz;
     char *ptr;
     int i, j;
-#if defined(SITEFPATH_DIR) || defined(FPATH_DIR)
+#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined (ADDITIONAL_FPATH)
     char **fpathptr;
 # if defined(FPATH_DIR) && defined(FPATH_SUBDIRS)
     char *fpath_subdirs[] = FPATH_SUBDIRS;
 # endif
+# if defined(ADDITIONAL_FPATH)
+    char *more_fndirs[] = ADDITIONAL_FPATH;
+    int more_fndirs_len;
+# endif
 # ifdef SITEFPATH_DIR
     int fpathlen = 1;
 # else
@@ -764,7 +768,7 @@ setupvals(void)
     manpath  = mkarray(NULL);
     fignore  = mkarray(NULL);
 
-#if defined(SITEFPATH_DIR) || defined(FPATH_DIR)
+#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined(ADDITIONAL_FPATH)
 # ifdef FPATH_DIR
 #  ifdef FPATH_SUBDIRS
     fpathlen += sizeof(fpath_subdirs)/sizeof(char *);
@@ -772,15 +776,28 @@ setupvals(void)
     fpathlen++;
 #  endif
 # endif
+# if defined(ADDITIONAL_FPATH)
+    more_fndirs_len = sizeof(more_fndirs)/sizeof(char *);
+    fpathlen += more_fndirs_len;
+# endif
     fpath = fpathptr = (char **)zalloc((fpathlen+1)*sizeof(char *));
 # ifdef SITEFPATH_DIR
     *fpathptr++ = ztrdup(SITEFPATH_DIR);
     fpathlen--;
 # endif
+# if defined(ADDITIONAL_FPATH)
+    for (j = 0; j < more_fndirs_len; j++)
+	*fpathptr++ = ztrdup(more_fndirs[j]);
+# endif
 # ifdef FPATH_DIR
 #  ifdef FPATH_SUBDIRS
+#   ifdef ADDITIONAL_FPATH
+    for (j = more_fndirs_len; j < fpathlen; j++)
+	*fpathptr++ = tricat(FPATH_DIR, "/", fpath_subdirs[j - more_fndirs_len]);
+#   else
     for (j = 0; j < fpathlen; j++)
 	*fpathptr++ = tricat(FPATH_DIR, "/", fpath_subdirs[j]);
+#endif
 #  else
     *fpathptr++ = ztrdup(FPATH_DIR);
 #  endif
diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index 537aa4d8e..9f19b45da 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -86,6 +86,10 @@ zshpaths.h: Makemod $(CONFIG_INCS)
 	    >>zshpaths.h.tmp; \
 	  fi; \
 	fi
+	@if test x$(additionalfpath) != x; then \
+	  fpath_tmp="`echo $(additionalfpath) | sed -e 's:,:\", \":g'`"; \
+	  echo "#define ADDITIONAL_FPATH { \"$$fpath_tmp\" }" >> zshpaths.h.tmp; \
+	fi
 	@if cmp -s zshpaths.h zshpaths.h.tmp; then \
 	    rm -f zshpaths.h.tmp; \
 	    echo "\`zshpaths.h' is up to date." ; \