summaryrefslogtreecommitdiff
path: root/parse/use.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-23 02:34:17 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-23 02:34:17 -0800
commit6d5d0ec7ee3480347255a9f469c26c8c34b2819a (patch)
tree7f316bbf7bbee620b7bdfde3808369d52a452e83 /parse/use.c
parentd29f8b95128b46048e5dbac897dc27fe70efe3c0 (diff)
downloadmc-6d5d0ec7ee3480347255a9f469c26c8c34b2819a.tar.gz
Make '.use' suffix on usefiles optional.
Diffstat (limited to 'parse/use.c')
-rw-r--r--parse/use.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/parse/use.c b/parse/use.c
index 23cd96e..acdefab 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -994,17 +994,34 @@ foundextlib:
return 1;
}
+int hassuffix(char *str, char *suff)
+{
+ size_t nstr, nsuff;
+
+ nstr = strlen(str);
+ nsuff = strlen(suff);
+ if (nstr < nsuff)
+ return 0;
+ return !strcmp(str + nstr - nsuff, suff);
+}
+
void readuse(Node *use, Stab *st, Vis vis)
{
size_t i;
FILE *fd;
char *t, *p;
+ char buf[512];
/* local (quoted) uses are always relative to the cwd */
fd = NULL;
p = NULL;
if (use->use.islocal) {
- p = strdup(use->use.name);
+ if (hassuffix(use->use.name, ".use"))
+ snprintf(buf, sizeof buf, "%s", use->use.name);
+ else
+ snprintf(buf,sizeof buf, "%s.use", use->use.name);
+
+ p = strdup(buf);
fd = fopen(p, "r");
/* nonlocal (barename) uses are always searched on the include path */
} else {