Add limit for looking through STDIN

This commit is contained in:
n3f4s 2021-07-13 14:28:53 +02:00 committed by Harry Jeffery
parent 72bda973f4
commit 8935fafb40

View file

@ -940,6 +940,7 @@ int imv_run(struct imv *imv)
if (imv->starting_path) {
if (imv->paths_from_stdin) {
int max_tries = 1000;
bool is_number = true;
for(int i=0; i<strlen(imv->starting_path); ++i) {
if (!isdigit(imv->starting_path[i])) {
@ -953,6 +954,9 @@ int imv_run(struct imv *imv)
}
bool cont = true;
while (cont) {
if (max_tries <= 0) {
cont = false;
}
imv_window_pump_events(imv->window, event_handler, imv);
if (index == -1) {
ssize_t img_index = imv_navigator_find_path(imv->navigator, imv->starting_path);
@ -966,6 +970,7 @@ int imv_run(struct imv *imv)
cont = false;
}
}
max_tries -= 1;
}
} else {
ssize_t index = imv_navigator_find_path(imv->navigator, imv->starting_path);