Permalink
Browse files

Add -q command-line flag to suppress non-explicit output.

  • Loading branch information...
1 parent ff245fa commit 6b2b41fddb345f53978b90cbea0a20e21e43af55 @cpressey cpressey committed Dec 26, 2011
Showing with 37 additions and 10 deletions.
  1. +1 −1 Makefile
  2. +3 −1 README
  3. +33 −8 miniscm.c
View
@@ -11,7 +11,7 @@
# CFLAGS = -O -DSYSV
CC ?= gcc
-CFLAGS ?= -O -ansi -pedantic -DBSD
+CFLAGS ?= -O -ansi -pedantic -DBSD -DCMDLINE
all : miniscm
View
4 README
@@ -14,11 +14,13 @@ Some improvements that have been made:
- modernized Makefile (defaults to 4.3 BSD, which works for Linux)
- removed compiler warnings (under 4.3 BSD)
- made compilable under AmigaOS 1.3 with DICE C
+- added -q command line option to suppress all non-explicit output
+ (this includes the prompt; if you want output, use (display))
Some further improvements I might consider:
-- add -q command line option to suppress extraneous output
- add -i command line option to specify the location of init.scm
+- add -l command line option to disable abbreviated quote output
- allow source file(s) to be specified on command line
If you are interested in a more developed and actively maintained
View
@@ -339,6 +339,7 @@ jmp_buf error_jmp;
#endif
char gc_verbose; /* if gc_verbose is not zero, print gc status */
+int quiet = 0; /* if not zero, print banner, prompt, results */
/* allocate new cell segment */
alloc_cellseg(n)
@@ -690,12 +691,14 @@ int inchar()
if (feof(infp)) {
fclose(infp);
infp = stdin;
- printf(prompt);
+ if (!quiet)
+ printf(prompt);
}
strcpy(linebuff, "\n");
if (fgets(currentline = linebuff, LINESIZE, infp) == NULL)
if (infp == stdin) {
- fprintf(stderr, "Good-bye\n");
+ if (!quiet)
+ fprintf(stderr, "Good-bye\n");
exit(0);
}
endline = linebuff + strlen(linebuff);
@@ -1148,16 +1151,18 @@ register short op;
infp = stdin;
Error_1("Unable to open", car(args));
}
- fprintf(outfp, "loading %s", strvalue(car(args)));
+ if (!quiet)
+ fprintf(outfp, "loading %s", strvalue(car(args)));
s_goto(OP_T0LVL);
case OP_T0LVL: /* top level */
- fprintf(outfp, "\n");
+ if (!quiet)
+ fprintf(outfp, "\n");
dump = NIL;
envir = global_env;
s_save(OP_VALUEPRINT, NIL, NIL);
s_save(OP_T1LVL, NIL, NIL);
- if (infp == stdin)
+ if (infp == stdin && !quiet)
printf(prompt);
s_goto(OP_READ);
@@ -1172,8 +1177,12 @@ register short op;
case OP_VALUEPRINT: /* print evalution result */
print_flag = 1;
args = value;
- s_save(OP_T0LVL, NIL, NIL);
- s_goto(OP_P0LIST);
+ if (quiet) {
+ s_goto(OP_T0LVL);
+ } else {
+ s_save(OP_T0LVL, NIL, NIL);
+ s_goto(OP_P0LIST);
+ }
case OP_EVAL: /* main part of evalution */
if (issymbol(code)) { /* symbol */
@@ -2439,11 +2448,27 @@ char *fmt, *a, *b, *c;
/* ========== Main ========== */
+#ifdef CMDLINE
+main(argc, argv)
+int argc;
+char **argv;
+#else
main()
+#endif
{
+ short i;
short op = (short) OP_LOAD;
- printf(banner);
+#ifdef CMDLINE
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-q") == 0) {
+ quiet = 1;
+ }
+ }
+#endif
+
+ if (!quiet)
+ printf(banner);
init_scheme();
args = cons(mk_string(InitFile), NIL);
#ifdef USE_SETJMP

0 comments on commit 6b2b41f

Please sign in to comment.