summaryrefslogtreecommitdiff
path: root/src/pacman
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman')
-rw-r--r--src/pacman/callback.c1
-rw-r--r--src/pacman/util.c31
2 files changed, 16 insertions, 16 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 43c56d00..53a56817 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -311,7 +311,6 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
depstring);
free(depstring);
select_display(providers);
- printf("\n");
*response = select_question(count);
}
break;
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 51abbf4d..37f28528 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -815,27 +815,28 @@ int select_question(int count)
stream = stderr;
}
- fprintf(stream, _("Enter a number (default=%d)"), preset);
- fprintf(stream, ": ");
-
- if(config->noconfirm) {
+ while(1) {
fprintf(stream, "\n");
- return(preset-1);
- }
+ fprintf(stream, _("Enter a number (default=%d)"), preset);
+ fprintf(stream, ": ");
- if(fgets(response, sizeof(response), stdin)) {
- strtrim(response);
- if(strlen(response) > 0) {
- char *endptr = NULL;
- int n = strtol(response, &endptr, 10);
- if(*endptr == '\0' && n >= 1 && n <= count) {
+ if(config->noconfirm) {
+ fprintf(stream, "\n");
+ break;
+ }
+
+ if(fgets(response, sizeof(response), stdin)) {
+ strtrim(response);
+ if(strlen(response) > 0) {
+ int n;
+ if(parseindex(response, &n, 1, count) != 0)
+ continue;
return(n-1);
- } else {
- fprintf(stream, _("Invalid number: %s\n"), response);
- return(-1);
}
}
+ break;
}
+
return(preset-1);
}