summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/init.c33
-rw-r--r--Src/zsh.mdd3
-rw-r--r--configure.ac13
4 files changed, 43 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index d425169db..3c5aa6126 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2014-09-20  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 33212: Src/zsh.mdd: Src/init.c, Src/zsh.mdd, configure.ac: add
+	/usr/local/share/zsh/site-functions to head of fpath if not
+	present in configurable.  Not configurable as serves as fallback
+	only if no handling /etc/zshenv.
+
 	* Tanu Kaskinen: 33209: Doc/Makefile.in: don't fail
 	catastrophically when builing zsh.texi if yodl isn't available.
 
diff --git a/Src/init.c b/Src/init.c
index d536978b9..40f46a804 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -770,7 +770,8 @@ setupvals(void)
     struct timezone dummy_tz;
     char *ptr;
     int i, j;
-#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined (ADDITIONAL_FPATH)
+#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined (ADDITIONAL_FPATH) || defined(FIXED_FPATH_DIR)
+#define FPATH_NEEDS_INIT 1
     char **fpathptr;
 # if defined(FPATH_DIR) && defined(FPATH_SUBDIRS)
     char *fpath_subdirs[] = FPATH_SUBDIRS;
@@ -779,11 +780,17 @@ setupvals(void)
     char *more_fndirs[] = ADDITIONAL_FPATH;
     int more_fndirs_len;
 # endif
+# ifdef FIXED_FPATH_DIR
+#  define FIXED_FPATH_LEN 1
+# else
+#  define FIXED_FPATH_LEN 0
+# endif
 # ifdef SITEFPATH_DIR
-    int fpathlen = 1;
+#  define SITE_FPATH_LEN 1
 # else
-    int fpathlen = 0;
+#  define SITE_FPATH_LEN 0
 # endif
+    int fpathlen = FIXED_FPATH_LEN + SITE_FPATH_LEN;
 #endif
     int close_fds[10], tmppipe[2];
 
@@ -862,23 +869,27 @@ setupvals(void)
     manpath  = mkarray(NULL);
     fignore  = mkarray(NULL);
 
-#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined(ADDITIONAL_FPATH)
+#ifdef FPATH_NEEDS_INIT
 # ifdef FPATH_DIR
 #  ifdef FPATH_SUBDIRS
     fpathlen += sizeof(fpath_subdirs)/sizeof(char *);
-#  else
+#  else /* FPATH_SUBDIRS */
     fpathlen++;
-#  endif
-# endif
+#  endif /* FPATH_SUBDIRS */
+# endif /* FPATH_DIR */
 # if defined(ADDITIONAL_FPATH)
     more_fndirs_len = sizeof(more_fndirs)/sizeof(char *);
     fpathlen += more_fndirs_len;
-# endif
+# endif /* ADDITONAL_FPATH */
     fpath = fpathptr = (char **)zalloc((fpathlen+1)*sizeof(char *));
+# ifdef FIXED_FPATH_DIR
+    *fpathptr++ = ztrdup(FIXED_FPATH_DIR);
+    fpathlen--;
+# endif
 # ifdef SITEFPATH_DIR
     *fpathptr++ = ztrdup(SITEFPATH_DIR);
     fpathlen--;
-# endif
+# endif /* SITEFPATH_DIR */
 # if defined(ADDITIONAL_FPATH)
     for (j = 0; j < more_fndirs_len; j++)
 	*fpathptr++ = ztrdup(more_fndirs[j]);
@@ -897,9 +908,9 @@ setupvals(void)
 #  endif
 # endif
     *fpathptr = NULL;
-#else
+#else /* FPATH_NEEDS_INIT */
     fpath    = mkarray(NULL);
-#endif
+#endif /* FPATH_NEEDS_INIT */
 
     mailpath = mkarray(NULL);
     watch    = mkarray(NULL);
diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index cec3edab7..9a8c923f9 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -73,6 +73,9 @@ zshpaths.h: Makemod $(CONFIG_INCS)
 	@if test x$(sitefndir) != xno; then \
 	  echo '#define SITEFPATH_DIR "'$(sitefndir)'"' >> zshpaths.h.tmp; \
 	fi
+	@if test x$(fixed_sitefndir) != x; then \
+	  echo '#define FIXED_FPATH_DIR "'$(fixed_sitefndir)'"' >> zshpaths.h.tmp; \
+        fi
 	@if test x$(fndir) != xno; then \
 	  echo '#define FPATH_DIR "'$(fndir)'"' >> zshpaths.h.tmp; \
 	  if test x$(FUNCTIONS_SUBDIRS) != x && \
diff --git a/configure.ac b/configure.ac
index 37f35858f..68a2e919f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -315,6 +315,18 @@ else
   sitefndir="$enableval"
 fi], [sitefndir=${datadir}/${tzsh_name}/site-functions])
 
+dnl Add /usr/local/share/zsh/site-functions if not yet present.
+dnl It might be present owing to an explicit sitefndir or the install
+dnl prefix if the shell is installed under the name "zsh".
+if test X$sitefndir = X/usr/local/zsh/site-functions
+then fixed_sitefndir=''
+elif test X$ac_default_prefix != X/usr/local
+then fixed_sitefndir=/usr/local/zsh/site-functions
+elif test X$tzsh_name != Xzsh
+then fixed_sitefndir=/usr/local/zsh/site-functions
+else fixed_sitefndir=''
+fi
+
 ifdef([function_subdirs],[undefine([function_subdirs])])
 AC_ARG_ENABLE(function-subdirs,
 AC_HELP_STRING([--enable-function-subdirs], [install functions in subdirectories]))
@@ -340,6 +352,7 @@ AC_SUBST(runhelp)dnl
 AC_SUBST(additionalfpath)dnl
 AC_SUBST(fndir)dnl
 AC_SUBST(sitefndir)dnl
+AC_SUBST(fixed_sitefndir)dnl
 AC_SUBST(FUNCTIONS_SUBDIRS)dnl
 
 dnl Directories for scripts such as newuser.