From 5de3404e7c48edae1fa6b2ffc03bc8ed20d32be3 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Wed, 5 Apr 2000 09:20:02 +0000 Subject: make zwc files use the magic number as their verios, report zsh-version in error messages --- Src/parse.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Src') 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 { -- cgit 1.4.1