summaryrefslogtreecommitdiffstats
path: root/g10/passphrase.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2014-08-26 10:16:04 +0200
committerWerner Koch <wk@gnupg.org>2014-08-26 10:16:04 +0200
commita731c22952278c12c601b73d7581fda3a15a4b5b (patch)
tree1487c8fac152845476d75b855c186a86d2183399 /g10/passphrase.c
parentgpg: Fix "can't handle public key algorithm" warning. (diff)
downloadgnupg2-a731c22952278c12c601b73d7581fda3a15a4b5b.tar.xz
gnupg2-a731c22952278c12c601b73d7581fda3a15a4b5b.zip
gpg: Allow for positional parameters in the passphrase prompt.
* g10/passphrase.c (passphrase_get): Replace sprintf by xasprintf. -- Without that at least the French translation does not always work because it requires positional parameters. Windows for example does not support them as they are not defined by C99 but by POSIX.
Diffstat (limited to 'g10/passphrase.c')
-rw-r--r--g10/passphrase.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/g10/passphrase.c b/g10/passphrase.c
index 9d3f497ba..4d0fda634 100644
--- a/g10/passphrase.c
+++ b/g10/passphrase.c
@@ -265,38 +265,27 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid, int repeat,
if ( !algo_name )
algo_name = "?";
-#define KEYIDSTRING _(" (main key ID %s)")
-
- maink = xmalloc ( strlen (KEYIDSTRING) + keystrlen() + 20 );
- if( keyid[2] && keyid[3] && keyid[0] != keyid[2]
+ if (keyid[2] && keyid[3]
+ && keyid[0] != keyid[2]
&& keyid[1] != keyid[3] )
- sprintf( maink, KEYIDSTRING, keystr(&keyid[2]) );
+ maink = xasprintf (_(" (main key ID %s)"), keystr (&keyid[2]));
else
- *maink = 0;
+ maink = xstrdup ("");
uid = get_user_id ( keyid, &uidlen );
timestr = strtimestamp (pk->timestamp);
-#undef KEYIDSTRING
-
-#define PROMPTSTRING _("Please enter the passphrase to unlock the" \
- " secret key for the OpenPGP certificate:\n" \
- "\"%.*s\"\n" \
- "%u-bit %s key, ID %s,\n" \
- "created %s%s.\n" )
-
- atext = xmalloc ( 100 + strlen (PROMPTSTRING)
- + uidlen + 15 + strlen(algo_name) + keystrlen()
- + strlen (timestr) + strlen (maink) );
- sprintf (atext, PROMPTSTRING,
- (int)uidlen, uid,
- nbits_from_pk (pk), algo_name, keystr(&keyid[0]), timestr,
- maink );
+ atext = xasprintf (_("Please enter the passphrase to unlock the"
+ " secret key for the OpenPGP certificate:\n"
+ "\"%.*s\"\n"
+ "%u-bit %s key, ID %s,\n"
+ "created %s%s.\n"),
+ (int)uidlen, uid,
+ nbits_from_pk (pk), algo_name, keystr(&keyid[0]),
+ timestr, maink);
xfree (uid);
xfree (maink);
-#undef PROMPTSTRING
-
{
size_t dummy;
fingerprint_from_pk( pk, fpr, &dummy );