summaryrefslogtreecommitdiff
path: root/tm.c
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2007-12-05 22:19:10 +0000
committerDimitri Sokolyuk <demon@dim13.org>2007-12-05 22:19:10 +0000
commita075234d87bb6a80392efd88570673005396a179 (patch)
tree26ec50222cd023d387a033d9a1e6ae67067394a6 /tm.c
parente28182595db472cb20a0017fc3f1b8f7fa77a949 (diff)
getopt()
Diffstat (limited to 'tm.c')
-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);