Can now handle the first 8 commits then segfaults.
[svn-fe.git] / sanitise.c
blobc941c94cdde67bbe547c8de893c321c73e564b43
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdbool.h>
4 #include <stdint.h>
5 #include <string.h>
7 #include "string_pool.h"
9 int main(int argc, char **argv)
11 char *cmd;
12 char *a1, *a2, *a3;
13 char buffer[4096];
14 pool_init(300000, 30000);
15 for (fgets(buffer, 4096, stdin);
16 !feof(stdin); fgets(buffer, 4096, stdin)) {
18 cmd = strtok(buffer, " ");
19 if (!strcmp(cmd, "copy")) {
20 a1 = strtok(NULL, ":");
21 a2 = strtok(NULL, "\"");
22 strtok(NULL, "\"");
23 a3 = strtok(NULL, "\"");
24 printf("%s %s:\"", cmd, a1);
25 for (a2 = strtok(a2, "/"); a2;
26 (a2 = strtok(NULL, a2)) && putchar('/')) {
27 printf("%d", pool_intern(a2));
29 printf("\" \"");
30 for (a3 = strtok(a3, "/"); a3;
31 (a3 = strtok(NULL, a3)) && putchar('/')) {
32 printf("%d", pool_intern(a3));
34 printf("\"\n");
35 } else if (!strcmp(cmd, "add") || !strcmp(cmd, "modify") || !strcmp(cmd, "delete")) {
36 a1 = strtok(NULL, "\"");
37 strtok(NULL, "\"");
38 printf("%s \"", cmd);
39 for (a1 = strtok(a1, "/"); a1;
40 (a1 = strtok(NULL, a1)) && putchar('/')) {
41 printf("%d", pool_intern(a1));
43 printf("\"\n");
44 } else if (!strcmp(cmd, "commit")) {
45 a1 = strtok(NULL, "\n");
46 printf("%s %s\n", cmd, a1);
49 return 0;