ref: 5c5abaeddf4ec4551e0616e3000f1afaca35bf72
parent: ec7cfc6f9f4927a0dfd85af0145adcf20b66c2b1
author: Ori Bernstein <[email protected]>
date: Thu Dec 18 18:38:38 EST 2014
Remove useless option from muse. Now, merging is the only thing muse does.
--- a/muse/muse.c
+++ b/muse/muse.c
@@ -16,8 +16,7 @@
/* FIXME: move into one place...? */
Node *file;
char *outfile;
-int merge;
-int debug;
+int show;
char debugopt[128];
char **incpaths;
size_t nincpaths;
@@ -26,7 +25,6 @@
{
printf("%s [-hIdos] [-o outfile] [-m] inputs\n", prog);
printf("\t-h\tprint this help\n");
- printf("\t-m\ttreat the inputs as usefiles and merge them into outfile\n");
printf("\t\tThe outfile must be the same name as each package merged.\n");
printf("\t-I path\tAdd 'path' to use search path\n");
printf("\t-d\tPrint debug dumps\n");
@@ -34,43 +32,6 @@
printf("\t-s\tShow the contents of usefiles `inputs`\n");
}
-static void dumpuse(char *path)
-{
- Stab *globls;
- FILE *f;
-
- globls = file->file.globls;
- f = fopen(path, "r");
- loaduse(f, globls, Visexport);
- fclose(f);
- dumpstab(globls, stdout);
-}
-
-static void genuse(char *path)
-{
- Stab *globls;
- char *p;
- FILE *f;
- char buf[1024];
-
- globls = file->file.globls;
- tyinit(globls);
- tokinit(path);
- yyparse();
-
- infer(file);
- tagexports(file->file.globls, 0);
- if (outfile) {
- p = outfile;
- } else {
- swapsuffix(buf, sizeof buf, path, ".myr", ".use");
- p = buf;
- }
- f = fopen(p, "w");
- writeuse(f, file);
- fclose(f);
-}
-
static void mergeuse(char *path)
{
FILE *f;
@@ -97,14 +58,10 @@
usage(argv[0]);
exit(0);
break;
- case 'm':
- merge = 1;
- break;
case 'o':
outfile = ctx.optarg;
break;
case 'd':
- debug = 1;
while (ctx.optarg && *ctx.optarg)
debugopt[*ctx.optarg++ & 0x7f] = 1;
break;
@@ -111,6 +68,9 @@
case 'I':
lappend(&incpaths, &nincpaths, ctx.optarg);
break;
+ case 's':
+ show = 1;
+ break;
default:
usage(argv[0]);
exit(0);
@@ -119,35 +79,24 @@
}
lappend(&incpaths, &nincpaths, Instroot "/lib/myr");
- if (merge) {
- if (!outfile) {
- fprintf(stderr, "Output file needed when merging usefiles.");
- exit(1);
- }
-
- file = mkfile("internal");
- file->file.globls = mkstab();
- updatens(file->file.globls, outfile);
- tyinit(file->file.globls);
- for (i = 0; i < ctx.nargs; i++)
- mergeuse(ctx.args[i]);
- infer(file);
- tagexports(file->file.globls, 1);
- f = fopen(outfile, "w");
- if (debugopt['s'])
- dumpstab(file->file.globls, stdout);
- writeuse(f, file);
- fclose(f);
- } else {
- for (i = 0; i < ctx.nargs; i++) {
- file = mkfile(ctx.args[i]);
- file->file.globls = mkstab();
- if (debugopt['s'])
- dumpuse(ctx.args[i]);
- else
- genuse(ctx.args[i]);
- }
+ if (!outfile) {
+ fprintf(stderr, "Output file needed when merging usefiles.");
+ exit(1);
}
+ file = mkfile("internal");
+ file->file.globls = mkstab();
+ updatens(file->file.globls, outfile);
+ tyinit(file->file.globls);
+ for (i = 0; i < ctx.nargs; i++)
+ mergeuse(ctx.args[i]);
+ infer(file);
+ tagexports(file->file.globls, 1);
+ f = fopen(outfile, "w");
+ if (debugopt['s'] || show)
+ dumpstab(file->file.globls, stdout);
+ else
+ writeuse(f, file);
+ fclose(f);
return 0;
}
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -333,7 +333,7 @@
args = NULL;
nargs = 0;
lappend(&args, &nargs, strdup(muse));
- lappend(&args, &nargs, strdup("-mo"));
+ lappend(&args, &nargs, strdup("-o"));
lappend(&args, &nargs, strdup(libname));
for (i = 0; i < nfiles; i++) {
if (hassuffix(files[i], ".myr")) {