From 9fcc047d921bde95b6807325b7fd2b697e89907f Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 3 Dec 2015 10:39:29 +0100 Subject: [PATCH] gpg: Change some error messages. * g10/getkey.c (parse_def_secret_key): Change error message. Replace log_debug by log_info. * g10/gpg.c (check_user_ids): Make function static. Change error messages. (main): Change error messages. * g10/revoke.c (gen_revoke): Ditto. -- There are other smaller changes not described above. This change tries to avoid new error messages so not to increase the the number of translated strings or break too many existing translations. It also tries to use existing strings and changes the quoting to the most common style used in gpg. Key specifications should in general use double quotes. Other values should use single quotes. However. sometimes it is not easy to distinguish between values given on the command line and key specifications. According to old GNU coding standards diagnostics should not start capitalized - whether this is a good idea is a different thing but we used this rules for most strings. However, strings which are used interactively should be properly capitalized and end with a dot. Signed-off-by: Werner Koch --- g10/getkey.c | 11 +++++---- g10/gpg.c | 66 ++++++++++++++++++++++++++++----------------------- g10/keyedit.c | 4 ++-- g10/keygen.c | 3 ++- g10/misc.c | 2 +- g10/revoke.c | 10 ++++---- 6 files changed, 53 insertions(+), 43 deletions(-) diff --git a/g10/getkey.c b/g10/getkey.c index 88d8c65a6..7d69912c4 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -1148,8 +1148,10 @@ parse_def_secret_key (ctrl_t ctrl) err = classify_user_id (t->d, &desc, 1); if (err) { - log_error (_("Invalid value ('%s') for --default-key.\n"), - t->d); + log_error (_("secret key \"%s\" not found: %s\n"), + t->d, gpg_strerror (err)); + if (!opt.quiet) + log_info (_("(check argument of option '%s')\n"), "--default-key"); continue; } @@ -1164,8 +1166,7 @@ parse_def_secret_key (ctrl_t ctrl) if (err) { - log_error (_("Error reading from keyring: %s.\n"), - gpg_strerror (err)); + log_error (_("key \"%s\" not found: %s\n"), t->d, gpg_strerror (err)); t = NULL; break; } @@ -1183,7 +1184,7 @@ parse_def_secret_key (ctrl_t ctrl) if (! err) { if (! warned) - log_debug (_("Using %s as default secret key.\n"), t->d); + log_info (_("using \"%s\" as default secret key\n"), t->d); break; } } diff --git a/g10/gpg.c b/g10/gpg.c index 774125117..225ca9af0 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -2083,7 +2083,8 @@ get_default_configname (void) return configname; } -gpg_error_t + +static gpg_error_t check_user_ids (strlist_t *sp, int warn_possibly_ambiguous, int error_if_not_found) @@ -2137,7 +2138,8 @@ check_user_ids (strlist_t *sp, if (! rc) rc = err; - log_error (_("Invalid value ('%s')."), t->d); + log_error (_("key \"%s\" not found: %s\n"), + t->d, gpg_strerror (err)); if (!opt.quiet) log_info (_("(check argument of option '%s')\n"), option); continue; @@ -2148,8 +2150,8 @@ check_user_ids (strlist_t *sp, || desc.mode == KEYDB_SEARCH_MODE_FPR16 || desc.mode == KEYDB_SEARCH_MODE_FPR20 || desc.mode == KEYDB_SEARCH_MODE_FPR)) - log_info (_("Warning: value '%s' for %s" - " should be a long keyid or a fingerprint.\n"), + log_info (_("Warning: value '%s' for option '%s'" + " should be a long key ID or a fingerprint\n"), t->d, option); if (! hd) @@ -2168,7 +2170,8 @@ check_user_ids (strlist_t *sp, if (! rc) rc = err; - log_error (_("no such key corresponding to '%s'\n"), t->d); + log_error (_("key \"%s\" not found: %s\n"), + t->d, gpg_strerror (err)); if (!opt.quiet) log_info (_("(check argument of option '%s')\n"), option); } @@ -2179,8 +2182,7 @@ check_user_ids (strlist_t *sp, if (! rc) rc = err; - log_error (_("error looking up '%s' in keyring: %s.\n"), - t->d, gpg_strerror (err)); + log_error (_("key \"%s\" not found: %s\n"), t->d, gpg_strerror (err)); break; } @@ -2190,8 +2192,7 @@ check_user_ids (strlist_t *sp, if (! rc) rc = err; - log_error (_("error reading key block for '%s': %s\n"), - t->d, gpg_strerror (err)); + log_error (_("error reading keyblock: %s\n"), gpg_strerror (err)); continue; } @@ -2254,8 +2255,7 @@ check_user_ids (strlist_t *sp, size_t fingerprint_bin2_len = sizeof (fingerprint_bin2); char fingerprint2[2 * MAX_FINGERPRINT_LEN + 1]; - log_error (_("Error: the key specification '%s' is ambiguous.\n"), - t->d); + log_error (_("key specification '%s' is ambiguous\n"), t->d); if (!opt.quiet) log_info (_("(check argument of option '%s')\n"), option); @@ -2264,8 +2264,7 @@ check_user_ids (strlist_t *sp, err = keydb_get_keyblock (hd, &kb); if (err) - log_error (_("error reading key block for '%s': %s.\n"), - t->d, gpg_strerror (err)); + log_error (_("error reading keyblock: %s\n"), gpg_strerror (err)); else { pk = kb->pkt->pkt.public_key; @@ -2273,8 +2272,12 @@ check_user_ids (strlist_t *sp, assert (fingerprint_bin2_len == sizeof (fingerprint_bin2)); bin2hex (fingerprint_bin2, MAX_FINGERPRINT_LEN, fingerprint2); - log_error ("'%s' matches at least: %s and %s.\n", - t->d, fingerprint, fingerprint2); + /* TRANSLATORS: The %s prints a key specification which + for example has been given at the command line. Two + lines with fingerprints are printed after this message. */ + log_info (_("'%s' matches at least:\n"), t->d); + log_info (" %s\n", fingerprint); + log_info (" %s\n", fingerprint2); release_kbnode (kb); } @@ -2283,7 +2286,7 @@ check_user_ids (strlist_t *sp, || gpg_err_code (err) == GPG_ERR_EOF)) /* An error (other than "not found"). */ { - log_error (_("Error reading from keyring: %s\n"), + log_error (_("error searching the keyring: %s\n"), gpg_strerror (err)); if (! rc) rc = err; @@ -2300,6 +2303,7 @@ check_user_ids (strlist_t *sp, return rc; } + int main (int argc, char **argv) { @@ -3986,9 +3990,11 @@ main (int argc, char **argv) sl->flags = (oEncryptToDefaultKey << 2) | 1; } else if (have_def_secret_key) - log_info (_("--encrypt-to-default-key specified, but no valid default keys specified.\n")); + log_info (_("option '%s' given, but no valid default keys given\n"), + "--encrypt-to-default-key"); else - log_info (_("--encrypt-to-default-key specified, but --default-key not specified.\n")); + log_info (_("option '%s' given, but option '%s' not given\n"), + "--encrypt-to-default-key", "--default-key"); } } @@ -4735,7 +4741,8 @@ main (int argc, char **argv) rc = classify_user_id (argv[i], &desc, 0); if (rc) { - log_error (_("Failed to parse '%s'.\n"), argv[i]); + log_error (_("error parsing key specification '%s': %s\n"), + argv[i], gpg_strerror (rc)); g10_exit (1); } @@ -4747,7 +4754,7 @@ main (int argc, char **argv) || desc.mode == KEYDB_SEARCH_MODE_KEYGRIP)) { log_error (_("'%s' does not appear to be a valid" - " key id, fingerprint or key grip.\n"), + " key ID, fingerprint or keygrip\n"), argv[i]); g10_exit (1); } @@ -4755,27 +4762,26 @@ main (int argc, char **argv) rc = keydb_search_reset (hd); if (rc) { - log_error (_("Failed to reset keyring handle.\n")); + /* This should not happen, thus no need to tranalate + the string. */ + log_error ("keydb_search_reset failed: %s\n", + gpg_strerror (rc)); g10_exit (1); } rc = keydb_search (hd, &desc, 1, NULL); - if (gpg_err_code (rc) == GPG_ERR_NO_PUBKEY) + if (rc) { - log_error (_("Key '%s' is not available\n"), argv[i]); - g10_exit (1); - } - else if (rc) - { - log_error (_("Failed to find key '%s'\n"), argv[i]); + log_error (_("key \"%s\" not found: %s\n"), argv[i], + gpg_strerror (rc)); g10_exit (1); } rc = keydb_get_keyblock (hd, &kb); if (rc) { - log_error (_("Failed to read key '%s' from the keyring\n"), - argv[i]); + log_error (_("error reading keyblock: %s\n"), + gpg_strerror (rc)); g10_exit (1); } diff --git a/g10/keyedit.c b/g10/keyedit.c index d7c70e626..a3feb796d 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -618,7 +618,7 @@ sign_uids (ctrl_t ctrl, estream_t fp, if (opt.only_sign_text_ids && uidnode->pkt->pkt.user_id->attribs) { - tty_fprintf (fp, _("Skipping User ID \"%s\"," + tty_fprintf (fp, _("Skipping user ID \"%s\"," " which is not a text ID.\n"), user); uidnode->flag &= ~NODFLG_MARK_A; @@ -4983,7 +4983,7 @@ menu_select_key (KBNODE keyblock, int idx, char *p) if (found_one) return 1; - tty_printf (_("No subkey with keyid %s\n"), p); + tty_printf (_("No subkey with key ID '%s'.\n"), p); return 0; } diff --git a/g10/keygen.c b/g10/keygen.c index 4296fe7fd..b3367a4ac 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -2538,7 +2538,8 @@ ask_user_id (int mode, int full, KBNODE keyblock) if( strpbrk( aname, "<>" ) ) { tty_printf(_("Invalid character in name\n")); - tty_printf(_("The characters < and > may not appear in name\n")); + tty_printf(_("The characters '%s' and '%s' may not " + "appear in name\n"), "<", ">"); } else if( digitp(aname) ) tty_printf(_("Name may not start with a digit\n")); diff --git a/g10/misc.c b/g10/misc.c index 861ba8752..547944d34 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -1705,7 +1705,7 @@ additional_weak_digest (const char* digestname) if (algo == GCRY_MD_NONE) { - log_error(_("Unknown weak digest '%s'\n"), digestname); + log_error (_("unknown weak digest '%s'\n"), digestname); return; } diff --git a/g10/revoke.c b/g10/revoke.c index 8599d17af..99242d115 100644 --- a/g10/revoke.c +++ b/g10/revoke.c @@ -615,10 +615,9 @@ gen_revoke (const char *uname) if (rc) { if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND) - log_error (_("no secret key matches the search term \"%s\"\n"), - uname); + log_error (_("secret key \"%s\" not found\n"), uname); else - log_error (_("error looking up secret key \"%s\": %s\n"), + log_error (_("secret key \"%s\" not found: %s\n"), uname, gpg_strerror (rc)); goto leave; } @@ -640,6 +639,9 @@ gen_revoke (const char *uname) { char *info; + /* TRANSLATORS: The %s prints a key specification which + for example has been given at the command line. Several lines + lines with secret key infos are printed after this message. */ log_error (_("'%s' matches multiple secret keys:\n"), uname); info = format_seckey_info (keyblock->pkt->pkt.public_key); @@ -651,7 +653,7 @@ gen_revoke (const char *uname) while (! rc) { info = format_seckey_info (keyblock->pkt->pkt.public_key); - log_error (" %s\n", info); + log_info (" %s\n", info); xfree (info); release_kbnode (keyblock); keyblock = NULL;