summaryrefslogtreecommitdiff
path: root/parse
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-04-23 20:57:05 -0700
committerOri Bernstein <ori@eigenstate.org>2015-04-23 20:58:46 -0700
commitf8b5e94caa6de168b47e47900176ff3b56c5e2c4 (patch)
treee8ec5e0811d9ba08e347530e31f651a03f249a8d /parse
parent64067fba02be50c0ccc8629b068f5e4bbeb64d13 (diff)
downloadmc-f8b5e94caa6de168b47e47900176ff3b56c5e2c4.tar.gz
Give more useful error on failing to find matching pkg.
It used to be that to find the matching use package, you had to poke around in a debugger with trial and error.
Diffstat (limited to 'parse')
-rw-r--r--parse/parse.h2
-rw-r--r--parse/use.c23
2 files changed, 13 insertions, 12 deletions
diff --git a/parse/parse.h b/parse/parse.h
index 420237b..1cc9323 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -571,7 +571,7 @@ Type *tyspecialize(Type *t, Htab *tymap, Htab *delayed);
Node *genericname(Node *n, Type *t);
/* usefiles */
-int loaduse(FILE *f, Stab *into, Vis vis);
+int loaduse(char *path, FILE *f, Stab *into, Vis vis);
void readuse(Node *use, Stab *into, Vis vis);
void writeuse(FILE *fd, Node *file);
void tagexports(Stab *st, int hidelocal);
diff --git a/parse/use.c b/parse/use.c
index 23e5a56..4050d29 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -803,7 +803,7 @@ int tdeq(void *pa, void *pb)
* D<picled-decl>
* G<pickled-decl><pickled-initializer>
*/
-int loaduse(FILE *f, Stab *st, Vis vis)
+int loaduse(char *path, FILE *f, Stab *st, Vis vis)
{
intptr_t tid;
size_t i;
@@ -842,7 +842,7 @@ int loaduse(FILE *f, Stab *st, Vis vis)
}
}
if (!s) {
- printf("could not find matching package for merge: %s\n", st->name);
+ printf("could not find matching package for merge: %s in %s\n", st->name, path);
exit(1);
}
tidmap = mkht(ptrhash, ptreq);
@@ -919,21 +919,21 @@ void readuse(Node *use, Stab *st, Vis vis)
{
size_t i;
FILE *fd;
- char *p, *q;
+ char *t, *p;
/* local (quoted) uses are always relative to the cwd */
fd = NULL;
if (use->use.islocal) {
- fd = fopen(use->use.name, "r");
+ p = strdup(use->use.name);
+ fd = fopen(p, "r");
/* nonlocal (barename) uses are always searched on the include path */
} else {
for (i = 0; i < nincpaths; i++) {
- p = strjoin(incpaths[i], "/");
- q = strjoin(p, use->use.name);
- fd = fopen(q, "r");
+ t = strjoin(incpaths[i], "/");
+ p = strjoin(t, use->use.name);
+ fd = fopen(p, "r");
if (fd) {
- free(p);
- free(q);
+ free(t);
break;
}
}
@@ -941,8 +941,9 @@ void readuse(Node *use, Stab *st, Vis vis)
if (!fd)
fatal(use, "Could not open %s", use->use.name);
- if (!loaduse(fd, st, vis))
- die("Could not load usefile %s", use->use.name);
+ if (!loaduse(p, fd, st, vis))
+ die("Could not load usefile %s from %s", use->use.name);
+ free(p);
}
/* Usefile format: