summaryrefslogtreecommitdiff
path: root/parse
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-03-09 01:12:37 -0700
committerOri Bernstein <ori@eigenstate.org>2015-03-09 01:12:37 -0700
commit4de5734e774e40c75b4018e5ce62809532ea3030 (patch)
treeb0b99a85314aa569996615dffb546f73b3970504 /parse
parent625ed632135e5fa0d12167b68f59f046179c8ae2 (diff)
downloadmc-4de5734e774e40c75b4018e5ce62809532ea3030.tar.gz
Put a version in the usefile.
Give an error instead of a crash on version changes.
Diffstat (limited to 'parse')
-rw-r--r--parse/parse.h2
-rw-r--r--parse/use.c5
2 files changed, 7 insertions, 0 deletions
diff --git a/parse/parse.h b/parse/parse.h
index 09b1a2e..664aab6 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -4,6 +4,8 @@
# define FATAL
#endif
+#define Useversion 0
+
typedef uint8_t byte;
typedef unsigned int uint;
typedef unsigned long ulong;
diff --git a/parse/use.c b/parse/use.c
index 3ea739e..06d702c 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -819,6 +819,10 @@ int loaduse(FILE *f, Stab *st, Vis vis)
tydedup = mkht(tdhash, tdeq);
if (fgetc(f) != 'U')
return 0;
+ if (rdint(f) != Useversion) {
+ fprintf(stderr, "usefile version mismatch. try rebuilding your deps.\n");
+ return 0;
+ }
pkg = rdstr(f);
/* if the package names match up, or the usefile has no declared
* package, then we simply add to the current stab. Otherwise,
@@ -959,6 +963,7 @@ void writeuse(FILE *f, Node *file)
/* usefile name */
wrbyte(f, 'U');
+ wrint(f, Useversion); /* use version */
if (st->_name)
wrstr(f, st->_name);
else