about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-05 09:20:02 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-05 09:20:02 +0000
commit5de3404e7c48edae1fa6b2ffc03bc8ed20d32be3 (patch)
tree126164d2794a7aa97ecd7a23c00b3ee9a3b200b6
parentff53f1cfb6a7a513f39603ff14e0656f228927f1 (diff)
downloadzsh-5de3404e7c48edae1fa6b2ffc03bc8ed20d32be3.tar.gz
zsh-5de3404e7c48edae1fa6b2ffc03bc8ed20d32be3.tar.xz
zsh-5de3404e7c48edae1fa6b2ffc03bc8ed20d32be3.zip
make zwc files use the magic number as their verios, report zsh-version in error messages
-rw-r--r--ChangeLog3
-rw-r--r--Src/parse.c21
2 files changed, 18 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index d45bfa695..88c21fe68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
 
 2000-04-05  Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
 
+	* 10502: Src/parse.c: use magic number in zwc files as zwc-version,
+	report zsh-version in error message.
+
 	* 10500: Doc/Zsh/zle.yo, Functions/Zle/incremental-complete-word,
 	Src/utils.c, Src/Zle/zle_params.c: add zle special parameter
 	$PENDING, giving the number of un-read bytes.
diff --git a/Src/parse.c b/Src/parse.c
index 63ea01486..f3908e2e3 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2197,7 +2197,10 @@ init_eprog(void)
  * the version string in a field of 40 characters and the descriptions
  * for the functions in the dump file.
  *
- * NOTE: this layout has to be kept; everything after it may be changed.
+ * NOTES:
+ *  - This layout has to be kept; everything after it may be changed.
+ *  - When incompatible changes are made, the FD_MAGIC and FD_OMAGIC
+ *    numbers have to be changed.
  *
  * Each description consists of a struct fdhead followed by the name,
  * aligned to sizeof(wordcode) (i.e. 4 bytes).
@@ -2358,11 +2361,17 @@ load_dump_header(char *nam, char *name, int err)
     }
     if (read(fd, buf, (FD_PRELEN + 1) * sizeof(wordcode)) !=
 	((FD_PRELEN + 1) * sizeof(wordcode)) ||
-	(fdmagic(buf) != FD_MAGIC && fdmagic(buf) != FD_OMAGIC) ||
-	(v = strcmp(ZSH_VERSION, fdversion(buf)))) {
-	if (err)
-	    zwarnnam(nam, (v ? "invalid zwc file, wrong version: %s" :
-			   "invalid zwc file: %s") , name, 0);
+	(v = (fdmagic(buf) != FD_MAGIC && fdmagic(buf) != FD_OMAGIC))) {
+	if (err) {
+	    if (v) {
+		char msg[80];
+
+		sprintf(msg, "zwc file has wrong version (zsh-%s): %%s",
+			fdversion(buf));
+		zwarnnam(nam, msg , name, 0);
+	    } else
+		zwarnnam(nam, "invalid zwc file: %s" , name, 0);
+	}
 	close(fd);
 	return NULL;
     } else {