summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.c4
-rw-r--r--util.c10
2 files changed, 14 insertions, 0 deletions
diff --git a/main.c b/main.c
index f925915..ef87898 100644
--- a/main.c
+++ b/main.c
@@ -13,6 +13,7 @@
#include "util.h"
#include <errno.h>
#include <fcntl.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -46,6 +47,9 @@ int main(int argc, char *argv[]) {
goto done;
}
+ // Use the system locale instead of "C"
+ setlocale(LC_ALL, "");
+
struct cmdline *cmdline = parse_cmdline(argc, argv);
if (cmdline) {
ret = eval_cmdline(cmdline);
diff --git a/util.c b/util.c
index 81eeda0..0d7e17d 100644
--- a/util.c
+++ b/util.c
@@ -373,6 +373,16 @@ static int xrpmatch(const char *response) {
ret = xrpregex(YESEXPR, response);
if (ret == 0) {
return 1;
+ } else if (ret != REG_NOMATCH) {
+ return -1;
+ }
+
+ // Failsafe: always handle y/n
+ char c = response[0];
+ if (c == 'n' || c == 'N') {
+ return 0;
+ } else if (c == 'y' || c == 'Y') {
+ return 1;
} else {
return -1;
}