diff options
author | Ori Bernstein <ori@eigenstate.org> | 2017-07-19 22:20:53 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2017-07-19 22:22:26 -0700 |
commit | ec311388a2880c4f836bd1108245cd4c2ab5630e (patch) | |
tree | 1b34660d9b7c26eec6c2510bf189c79c9ebedcf5 /parse | |
parent | 80e1f20064f435fba7b4c7be70fd6b19c5218cc3 (diff) | |
download | mc-ec311388a2880c4f836bd1108245cd4c2ab5630e.tar.gz |
Only use the filename itself for __init__
This sucks, but it's *extremely* unlikely that a file
will share a namespace, filename, and __init__.
This makes builds directory-independent, so that linking
the same file compiled with a different compiler cwd will
work.
Diffstat (limited to 'parse')
-rw-r--r-- | parse/gram.y | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/parse/gram.y b/parse/gram.y index 02b3399..dc91cb8 100644 --- a/parse/gram.y +++ b/parse/gram.y @@ -1053,10 +1053,15 @@ label : Tcolon Tident { static void setupinit(Node *n) { char name[1024]; - char *p; + char *p, *s; bprintf(name, sizeof name, "%s$__init__", file->file.files[0]); - p = name; + s = strrchr(name, '/'); + if (s) + s++; + else + s = name; + p = s; while (*p) { if (!isalnum(*p) && *p != '_') *p = '$'; @@ -1064,7 +1069,7 @@ static void setupinit(Node *n) } n->decl.isinit = 1; n->decl.vis = Vishidden; - n->decl.name->name.name = strdup(name); + n->decl.name->name.name = strdup(s); } static void addtrait(Type *t, char *str) |