Created
May 29, 2013 03:59
Revisions
-
o11c created this gist
May 29, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ int main(int argc, char **argv) { int fd = open("/dev/urandom", 0); int ai = 0; int idx; for (;;) { char c; read(fd, &c, 1); if (ai && argv[ai][idx + 1] == c) { printf("++ %d %d\n", ai, idx); idx++; if (idx == strlen(argv[ai])) break; } for (int i = 1; i < argc; ++i) if (argv[i][0] == c) { printf("-> %d %d\n", ai, idx); ai = i; idx = 0; } } puts(argv[ai]); return ai; }