|
diff --git a/main.c b/main.c
|
| ... |
| 110 |
} |
110 |
} |
| 111 |
} |
111 |
} |
| 112 |
|
112 |
|
| 113 |
// Full matching. |
|
|
| 114 |
/* if (strcmp(fn.fname, cfname) == 0) { */ |
|
|
| 115 |
/* printf("%s:%zu\t%s %s %s\n", file_path, fn.lineno, fn.ftype, fn.fname, fn.fparams); */ |
|
|
| 116 |
/* } */ |
|
|
| 117 |
|
|
|
| 118 |
// Substring matching. |
113 |
// Substring matching. |
|
|
114 |
// FIXME: Add Levenshtein distance. |
| 119 |
char *result = strstr(fn.fname, cfname); |
115 |
char *result = strstr(fn.fname, cfname); |
| 120 |
if (result != NULL) { |
116 |
if (result != NULL) { |
| 121 |
char *fparams_formatted = remove_newlines(fn.fparams); |
117 |
char *fparams_formatted = remove_newlines(fn.fparams); |
| 122 |
printf("%s:%zu\t%s %s %s\n", file_path, fn.lineno, fn.ftype, fn.fname, fparams_formatted); |
118 |
printf("%s:%zu:\t%s %s %s\n", file_path, fn.lineno, fn.ftype, fn.fname, fparams_formatted); |
| 123 |
} |
119 |
} |
| 124 |
} |
120 |
} |
| 125 |
} else { |
121 |
} else { |
| ... |
| 145 |
} |
141 |
} |
| 146 |
|
142 |
|
| 147 |
int main(int argc, char *argv[]) { |
143 |
int main(int argc, char *argv[]) { |
| 148 |
if (argc < 2) { |
144 |
if (argc < 3) { |
| 149 |
printf("Usage: %s <argument>\n", argv[0]); |
145 |
printf("Usage: %s <search term> <directory>\n", argv[0]); |
| 150 |
return 1; |
146 |
return 1; |
| 151 |
} |
147 |
} |
| 152 |
|
148 |
|
| 153 |
char *cfname = argv[1]; |
149 |
char *cfname = argv[1]; |
|
|
150 |
char *directory = argv[2]; |
| 154 |
|
151 |
|
| 155 |
TSLanguage *tree_sitter_c(void); |
152 |
TSLanguage *tree_sitter_c(void); |
| 156 |
TSLanguage *tree_sitter_python(void); |
153 |
TSLanguage *tree_sitter_python(void); |
| 157 |
|
154 |
|
| 158 |
Node *head = NULL; |
155 |
Node *head = NULL; |
| 159 |
list_files_recursively("./examples", &head); |
156 |
list_files_recursively(directory, &head); |
| 160 |
int list_size = size_of_file_list(head); |
157 |
int list_size = size_of_file_list(head); |
| 161 |
/* pthread_t threads[list_size]; */ |
158 |
/* pthread_t threads[list_size]; */ |
| 162 |
|
159 |
|
| 163 |
printf("size: %d\n", list_size); |
160 |
if (DEBUG) { |
|
|
161 |
printf("Scanning %d files\n", list_size); |
|
|
162 |
} |
| 164 |
|
163 |
|
| 165 |
Node *current = head; |
164 |
Node *current = head; |
| 166 |
int thread_index = 0; |
165 |
int thread_index = 0; |
| ... |