From 80844b89da2b8dea682790e3f5f6cb3cad154c82 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 13 Dec 2014 12:11:20 +0100 Subject: [PATCH 1/2] Update translation URL "rosetta" now lives at translations.launchpad.net --- README-NLS | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README-NLS b/README-NLS index 422156d..ee02dc9 100644 --- a/README-NLS +++ b/README-NLS @@ -60,11 +60,12 @@ to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' Translating =========== -EncFS is registered with Rosetta - an online interface for supplying -translations. See https://launchpad.ubuntu.com/rosetta/products/encfs +EncFS is registered with Launchpad Translations - an online interface +for supplying translations. +See https://translations.launchpad.net/encfs/main/+pots/encfs If your language is not included in this distribution, you may want -to check if translated text is already available online in Rosetta. +to check if translated text is already available online in Launchpad. If not, consider translating some of the strings, which will then be included in the next EncFS release. From 0a920fa7332d8bc4b80ce6cf8ab107ac3a8990c3 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 13 Dec 2014 13:01:03 +0100 Subject: [PATCH 2/2] Use standard "[y]/n" / "y/[n]" prompt This removes the need for a translated prompt. Fixes issue #20. Also, * merge boolDefaultNo() and boolDefaultYes() into boolDefault() * do not accept arbitrary answers, but prompt again --- encfs/FileUtils.cpp | 65 ++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/encfs/FileUtils.cpp b/encfs/FileUtils.cpp index ccfaf0b..f658bf8 100644 --- a/encfs/FileUtils.cpp +++ b/encfs/FileUtils.cpp @@ -805,19 +805,51 @@ static int selectBlockSize(const Cipher::CipherAlgorithm &alg) { return blockSize; } -static bool boolDefaultNo(const char *prompt) { - cout << prompt << "\n"; - cout << _("The default here is No.\n" - "Any response that does not begin with 'y' will mean No: "); +/** + * Prompt the user for a "y" or "n" answer. + * An empty answer returns defaultValue. + */ +static bool boolDefault(const char *prompt, bool defaultValue) { - char answer[10]; - char *res = fgets(answer, sizeof(answer), stdin); + cout << prompt; cout << "\n"; - if (res != 0 && tolower(answer[0]) == 'y') - return true; + string yesno; + + if (defaultValue == true) + yesno = "[y]/n: "; else - return false; + yesno = "y/[n]: "; + + string response; + bool value; + + while(true) { + cout << yesno; + getline(cin, response); + + if (cin.fail() || response == "") { + value = defaultValue; + break; + } else if (response == "y") { + value = true; + break; + } else if (response == "n") { + value = false; + break; + } + } + + cout << "\n"; + return value; +} + +static bool boolDefaultNo(const char *prompt) { + return boolDefault(prompt, false); +} + +static bool boolDefaultYes(const char *prompt) { + return boolDefault(prompt, true); } /** @@ -858,21 +890,6 @@ static void selectBlockMAC(int *macBytes, int *macRandBytes) { *macRandBytes = randSize; } -static bool boolDefaultYes(const char *prompt) { - cout << prompt << "\n"; - cout << _("The default here is Yes.\n" - "Any response that does not begin with 'n' will mean Yes: "); - - char answer[10]; - char *res = fgets(answer, sizeof(answer), stdin); - cout << "\n"; - - if (res != 0 && tolower(answer[0]) == 'n') - return false; - else - return true; -} - /** * Ask the user if per-file unique IVs should be used */