mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +01:00
* miscutil.c (match_multistr): New. Match against each segment in a
string with tokens separated by |. (answer_is_yes_no_default, answer_is_yes_no_quit, answer_is_okay_cancel): Use it here to enable alternate translations.
This commit is contained in:
parent
dcf747d620
commit
baf4e3b6fc
@ -1,3 +1,11 @@
|
|||||||
|
2003-11-20 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* miscutil.c (match_multistr): New. Match against each segment in
|
||||||
|
a string with tokens separated by |.
|
||||||
|
(answer_is_yes_no_default, answer_is_yes_no_quit,
|
||||||
|
answer_is_okay_cancel): Use it here to enable alternate
|
||||||
|
translations.
|
||||||
|
|
||||||
2003-11-01 David Shaw <dshaw@jabberwocky.com>
|
2003-11-01 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* http.c (connect_server): Differentiate between generic "can't
|
* http.c (connect_server): Differentiate between generic "can't
|
||||||
|
@ -293,18 +293,20 @@ make_printable_string( const byte *p, size_t n, int delim )
|
|||||||
int
|
int
|
||||||
answer_is_yes_no_default( const char *s, int def_answer )
|
answer_is_yes_no_default( const char *s, int def_answer )
|
||||||
{
|
{
|
||||||
const char *long_yes = _("yes");
|
/* NOTE TO TRANSLATOR: See doc/TRANSLATE about this string. */
|
||||||
|
const char *long_yes = _("yes|yes");
|
||||||
const char *short_yes = _("yY");
|
const char *short_yes = _("yY");
|
||||||
const char *long_no = _("no");
|
/* NOTE TO TRANSLATOR: See doc/TRANSLATE about this string. */
|
||||||
|
const char *long_no = _("no|no");
|
||||||
const char *short_no = _("nN");
|
const char *short_no = _("nN");
|
||||||
|
|
||||||
/* Note: we have to use the local dependent strcasecmp here */
|
/* Note: we have to use the local dependent strcasecmp here */
|
||||||
if( !strcasecmp(s, long_yes ) )
|
if( match_multistr(long_yes,s) )
|
||||||
return 1;
|
return 1;
|
||||||
if( *s && strchr( short_yes, *s ) && !s[1] )
|
if( *s && strchr( short_yes, *s ) && !s[1] )
|
||||||
return 1;
|
return 1;
|
||||||
/* test for no strings to catch ambiguities for the next test */
|
/* test for no strings to catch ambiguities for the next test */
|
||||||
if( !strcasecmp(s, long_no ) )
|
if( match_multistr(long_no,s) )
|
||||||
return 0;
|
return 0;
|
||||||
if( *s && strchr( short_no, *s ) && !s[1] )
|
if( *s && strchr( short_no, *s ) && !s[1] )
|
||||||
return 0;
|
return 0;
|
||||||
@ -328,19 +330,21 @@ answer_is_yes( const char *s )
|
|||||||
int
|
int
|
||||||
answer_is_yes_no_quit( const char *s )
|
answer_is_yes_no_quit( const char *s )
|
||||||
{
|
{
|
||||||
const char *long_yes = _("yes");
|
/* NOTE TO TRANSLATOR: See doc/TRANSLATE about this string. */
|
||||||
const char *long_no = _("no");
|
const char *long_yes = _("yes|yes");
|
||||||
const char *long_quit = _("quit");
|
/* NOTE TO TRANSLATOR: See doc/TRANSLATE about this string. */
|
||||||
|
const char *long_no = _("no|no");
|
||||||
|
/* NOTE TO TRANSLATOR: See doc/TRANSLATE about this string. */
|
||||||
|
const char *long_quit = _("quit|quit");
|
||||||
const char *short_yes = _("yY");
|
const char *short_yes = _("yY");
|
||||||
const char *short_no = _("nN");
|
const char *short_no = _("nN");
|
||||||
const char *short_quit = _("qQ");
|
const char *short_quit = _("qQ");
|
||||||
|
|
||||||
/* Note: We have to use the locale dependent strcasecmp */
|
if( match_multistr(long_no,s) )
|
||||||
if( !strcasecmp(s, long_no ) )
|
|
||||||
return 0;
|
return 0;
|
||||||
if( !strcasecmp(s, long_yes ) )
|
if( match_multistr(long_yes,s) )
|
||||||
return 1;
|
return 1;
|
||||||
if( !strcasecmp(s, long_quit ) )
|
if( match_multistr(long_quit,s) )
|
||||||
return -1;
|
return -1;
|
||||||
if( *s && strchr( short_no, *s ) && !s[1] )
|
if( *s && strchr( short_no, *s ) && !s[1] )
|
||||||
return 0;
|
return 0;
|
||||||
@ -360,22 +364,23 @@ answer_is_yes_no_quit( const char *s )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return 1 for okay, 0 for for cancel or DEF_ANSWER for default.
|
Return 1 for okay, 0 for for cancel or DEF_ANSWER for default.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
answer_is_okay_cancel (const char *s, int def_answer)
|
answer_is_okay_cancel (const char *s, int def_answer)
|
||||||
{
|
{
|
||||||
const char *long_okay = _("okay");
|
/* NOTE TO TRANSLATOR: See doc/TRANSLATE about this string. */
|
||||||
const char *long_cancel = _("cancel");
|
const char *long_okay = _("okay|okay");
|
||||||
|
/* NOTE TO TRANSLATOR: See doc/TRANSLATE about this string. */
|
||||||
|
const char *long_cancel = _("cancel|cancel");
|
||||||
const char *short_okay = _("oO");
|
const char *short_okay = _("oO");
|
||||||
const char *short_cancel = _("cC");
|
const char *short_cancel = _("cC");
|
||||||
|
|
||||||
/* Note: We have to use the locale dependent strcasecmp */
|
/* Note: We have to use the locale dependent strcasecmp */
|
||||||
if ( !strcasecmp(s, long_okay ) )
|
if ( match_multistr(long_okay,s) )
|
||||||
return 1;
|
return 1;
|
||||||
if ( !strcasecmp(s, long_cancel ) )
|
if ( match_multistr(long_cancel,s) )
|
||||||
return 0;
|
return 0;
|
||||||
if ( *s && strchr( short_okay, *s ) && !s[1] )
|
if ( *s && strchr( short_okay, *s ) && !s[1] )
|
||||||
return 1;
|
return 1;
|
||||||
@ -394,3 +399,24 @@ answer_is_okay_cancel (const char *s, int def_answer)
|
|||||||
return 0;
|
return 0;
|
||||||
return def_answer;
|
return def_answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Try match against each substring of multistr, delimited by | */
|
||||||
|
int
|
||||||
|
match_multistr(const char *multistr,const char *match)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
size_t seglen=strcspn(multistr,"|");
|
||||||
|
if(!seglen)
|
||||||
|
break;
|
||||||
|
/* Using the localized strncasecmp */
|
||||||
|
if(strncasecmp(multistr,match,seglen)==0)
|
||||||
|
return 1;
|
||||||
|
multistr+=seglen;
|
||||||
|
if(*multistr=='|')
|
||||||
|
multistr++;
|
||||||
|
}
|
||||||
|
while(*multistr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user