summaryrefslogtreecommitdiff
path: root/match_pool.c
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-01-05 22:42:37 +1300
committerDavid Phillips <david@sighup.nz>2017-01-05 22:42:37 +1300
commite452f3d9975208a9e746a4993d17ef4bd3879c14 (patch)
tree3edec6a3265088ba7ce0dd799f34a073f30be7d1 /match_pool.c
parentfe85861f176998d694566b6718125848bd8f52be (diff)
downloadodds-and-ends-e452f3d9975208a9e746a4993d17ef4bd3879c14.tar.xz
Move words-misc into subdirectory
Diffstat (limited to 'match_pool.c')
-rw-r--r--match_pool.c50
1 files changed, 0 insertions, 50 deletions
diff --git a/match_pool.c b/match_pool.c
deleted file mode 100644
index eda8f61..0000000
--- a/match_pool.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int main(int argc, char **argv)
-{
- int i = 0;
- char buffer[1024];
- char *res = NULL;
- char *pool = NULL;
- char *local_pool = NULL;
- size_t pool_size = 0;
-
-
- if (argc != 2)
- {
- fprintf(stderr, "Usage: %s <character pool>\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- pool = argv[1];
- pool_size = strlen(pool);
-
- local_pool = malloc(pool_size);
- if (local_pool == NULL)
- {
- fprintf(stderr, "%s: malloc for local pool failed\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- while (fgets(buffer, sizeof(buffer), stdin))
- {
- buffer[strcspn(buffer, "\r\n")] = '\0'; /* chomp */
-
- if (strlen(buffer) == 0)
- continue;
-
- strcpy(local_pool, pool);
- for (i = strlen(buffer)-1; i >= 0; i--)
- {
- if ((res = memchr(local_pool, buffer[i], pool_size)) != NULL)
- *res = '\0';
- else
- break;
- }
- printf("%s %s\n", buffer, i < 0? "matches" : "doesn't match" );
- }
- free(local_pool);
- return 0;
-}