mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-06 18:35:41 +02:00
Handle named files, not just standard input
This commit is contained in:
@@ -64,16 +64,10 @@ void json_print(json_object *j, int depth) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
void process(FILE *f) {
|
||||||
json_object *j = NULL;
|
json_object *j = NULL;
|
||||||
|
|
||||||
while ((j = json_parse(stdin, j)) != NULL) {
|
while ((j = json_parse(f, j)) != NULL) {
|
||||||
json_object *g = json_hash_get(j, "type");
|
|
||||||
if (g != NULL && g->type == JSON_STRING && strcmp(g->string, "Feature") == 0) {
|
|
||||||
json_print(j, 0);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j->parent == NULL) {
|
if (j->parent == NULL) {
|
||||||
json_print(j, 0);
|
json_print(j, 0);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -81,3 +75,20 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if (argc == 1) {
|
||||||
|
process(stdin);
|
||||||
|
} else {
|
||||||
|
int i;
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
FILE *f = fopen(argv[i], "r");
|
||||||
|
if (f == NULL) {
|
||||||
|
perror(argv[i]);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
process(f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user