summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tm.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/tm.c b/tm.c
index 25736af..ca89439 100644
--- a/tm.c
+++ b/tm.c
@@ -303,18 +303,30 @@ main(int argc, char **argv)
Tape *tape;
Table *table;
int delay = 250000;
+ int c;
/* TODO: add scroll flag & execution velocity parameter */
- if (argc != 2)
- exit(1);
+ while ((c = getopt(argc, argv, "d:")) != -1)
+ switch (c) {
+ case 'd':
+ delay = atoi(optarg);
+ if (delay < 0)
+ exit(1);
+ break;
+ default:
+ exit(1);
+ }
+
+ argc -= optind;
+ argv += optind;
- if (**argv == 'f')
- delay /= 100; /* fast */
+ if (argc != 1)
+ exit(1);
signal(SIGHUP, halt);
signal(SIGINT, halt);
- table = alloctable(argv[1]);
+ table = alloctable(*argv);
tape = alloctape(initstring);
execute(tape, table, delay);