chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v234: Apply missing upstream fixes in src/basic (1/6)
[elogind.git]
/
src
/
basic
/
terminal-util.c
diff --git
a/src/basic/terminal-util.c
b/src/basic/terminal-util.c
index efd35cd727cc944c166f428c113669ff97d975c6..6cf623d5196fc16d7ca4b908829a406d1a6704aa 100644
(file)
--- a/
src/basic/terminal-util.c
+++ b/
src/basic/terminal-util.c
@@
-144,12
+144,14
@@
int read_one_char(FILE *f, char *ret, usec_t t, bool *need_nl) {
return 0;
}
return 0;
}
-int ask_char(char *ret, const char *replies, const char *text, ...) {
+#define DEFAULT_ASK_REFRESH_USEC (2*USEC_PER_SEC)
+
+int ask_char(char *ret, const char *replies, const char *fmt, ...) {
int r;
assert(ret);
assert(replies);
int r;
assert(ret);
assert(replies);
- assert(
tex
t);
+ assert(
fm
t);
for (;;) {
va_list ap;
for (;;) {
va_list ap;
@@
-159,8
+161,10
@@
int ask_char(char *ret, const char *replies, const char *text, ...) {
if (colors_enabled())
fputs(ANSI_HIGHLIGHT, stdout);
if (colors_enabled())
fputs(ANSI_HIGHLIGHT, stdout);
- va_start(ap, text);
- vprintf(text, ap);
+ putchar('\r');
+
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
va_end(ap);
if (colors_enabled())
va_end(ap);
if (colors_enabled())
@@
-168,9
+172,12
@@
int ask_char(char *ret, const char *replies, const char *text, ...) {
fflush(stdout);
fflush(stdout);
- r = read_one_char(stdin, &c,
USEC_INFINITY
, &need_nl);
+ r = read_one_char(stdin, &c,
DEFAULT_ASK_REFRESH_USEC
, &need_nl);
if (r < 0) {
if (r < 0) {
+ if (r == -ETIMEDOUT)
+ continue;
+
if (r == -EBADMSG) {
puts("Bad input, please try again.");
continue;
if (r == -EBADMSG) {
puts("Bad input, please try again.");
continue;
@@
-457,7
+464,7
@@
int acquire_terminal(
goto fail;
}
goto fail;
}
- r = fd_wait_for_event(
fd
, POLLIN, ts + timeout - n);
+ r = fd_wait_for_event(
notify
, POLLIN, ts + timeout - n);
if (r < 0)
goto fail;
if (r < 0)
goto fail;
@@
-1219,6
+1226,7
@@
bool colors_enabled(void) {
static int enabled = -1;
if (_unlikely_(enabled < 0)) {
static int enabled = -1;
if (_unlikely_(enabled < 0)) {
+#if 0 /// elogind does not allow such forcing, and we are never init!
int val;
val = getenv_bool("SYSTEMD_COLORS");
int val;
val = getenv_bool("SYSTEMD_COLORS");
@@
-1228,6
+1236,7
@@
bool colors_enabled(void) {
/* PID1 outputs to the console without holding it open all the time */
enabled = !getenv_terminal_is_dumb();
else
/* PID1 outputs to the console without holding it open all the time */
enabled = !getenv_terminal_is_dumb();
else
+#endif // 0
enabled = !terminal_is_dumb();
}
enabled = !terminal_is_dumb();
}