about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2001-06-08 18:34:53 +0000
committerClint Adams <clint@users.sourceforge.net>2001-06-08 18:34:53 +0000
commit975c0b44c56c7bf12f93a54f20bbfeff06fac7da (patch)
treee62ebdcb89cc1082ed22a2c53d40831fe0a496dd
parent9675a70946e07dee97a61ef0408595a6a52b7b21 (diff)
downloadzsh-975c0b44c56c7bf12f93a54f20bbfeff06fac7da.tar.gz
zsh-975c0b44c56c7bf12f93a54f20bbfeff06fac7da.tar.xz
zsh-975c0b44c56c7bf12f93a54f20bbfeff06fac7da.zip
14813: autoload functions from deleted .zwc files
-rw-r--r--ChangeLog6
-rw-r--r--Src/parse.c6
-rw-r--r--Src/utils.c17
-rw-r--r--Src/zsh.h1
-rw-r--r--zshconfig.ac3
5 files changed, 30 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 35cd6d9e9..0ead55a9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-06-08  Clint Adams  <clint@zsh.org>
+
+	* 14813: zshconfig.ac, Src/parse.c, Src/utils.c, Src/zsh.h:
+	try to autoload functions from digest files that are deleted
+	but still open.
+
 2001-06-08  Bart Schaefer  <schaefer@zsh.org>
 
 	* 14796: zshconfig.ac: More reliable BROKEN_KILL_ESRCH test.
diff --git a/Src/parse.c b/Src/parse.c
index 78b14fb41..ea0dffdef 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2827,6 +2827,7 @@ load_dump_file(char *dump, struct stat *sbuf, int other, int len)
     d->addr = addr;
     d->len = len;
     d->count = 0;
+    d->filename = ztrdup(dump);
 }
 
 #endif
@@ -2854,7 +2855,7 @@ try_dump_file(char *path, char *name, char *file, int *ksh)
     dig = dyncat(path, FD_EXT);
     wc = dyncat(file, FD_EXT);
 
-    rd = stat(dig, &std);
+    rd = zwcstat(dig, &std, dumps);
     rc = stat(wc, &stc);
     rn = stat(file, &stn);
 
@@ -2934,7 +2935,7 @@ check_dump_file(char *file, struct stat *sbuf, char *name, int *ksh)
     struct stat lsbuf;
 
     if (!sbuf) {
-	if (stat(file, &lsbuf))
+	if (zwcstat(file, &lsbuf, dumps))
 	    return NULL;
 	sbuf = &lsbuf;
     }
@@ -3077,6 +3078,7 @@ decrdumpcount(FuncDump f)
 		dumps = p->next;
 	    munmap((void *) f->addr, f->len);
 	    zclose(f->fd);
+	    zsfree(f->filename);
 	    zfree(f, sizeof(*f));
 	}
     }
diff --git a/Src/utils.c b/Src/utils.c
index 6bede2e43..cd7685e6e 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3829,3 +3829,20 @@ mailstat(char *path, struct stat *st)
        return 0;
 }
 #endif
+
+/**/
+mod_export int
+zwcstat(char *filename, struct stat *buf, FuncDump dumps)
+{
+    FuncDump f;
+    
+    if (stat(filename, buf)) {
+#ifdef HAVE_FSTAT
+	for (f = dumps; f; f = f->next) {
+	    if (!fstat(f->fd, buf)) return 0;
+	}
+#endif
+	return 1;
+    } else return 0;
+    
+}
diff --git a/Src/zsh.h b/Src/zsh.h
index 1d8d8888b..c510b9759 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -493,6 +493,7 @@ struct funcdump {
     Wordcode addr;		/* mapped region */
     int len;			/* length */
     int count;			/* reference count */
+    char *filename;
 };
 
 struct eprog {
diff --git a/zshconfig.ac b/zshconfig.ac
index 0f4fe14e6..37f9ca2d5 100644
--- a/zshconfig.ac
+++ b/zshconfig.ac
@@ -912,7 +912,8 @@ dnl AC_FUNC_STRFTIME
 
 AC_CHECK_FUNCS(strftime difftime gettimeofday \
 	       select poll \
-	       readlink lstat lchown faccessx fchdir ftruncate \
+	       readlink faccessx fchdir ftruncate \
+	       fstat lstat lchown \
 	       fseeko ftello \
 	       mkfifo _mktemp \
 	       waitpid wait3 \