Ejemplo n.º 1
0
int
answer_is_yes_no_default( const char *s, int def_answer )
{
    /* TRANSLATORS: See doc/TRANSLATE about this string. */
    const char *long_yes = _("yes");
    const char *short_yes = _("yY");
    /* TRANSLATORS: See doc/TRANSLATE about this string. */
    const char *long_no = _("no");
    const char *short_no = _("nN");

    /* Note: we have to use the local dependent strcasecmp here */
    if( match_multistr(long_yes,s) )
	return 1;
    if( *s && strchr( short_yes, *s ) && !s[1] )
	return 1;
    /* test for no strings to catch ambiguities for the next test */
    if( match_multistr(long_no,s) )
	return 0;
    if( *s && strchr( short_no, *s ) && !s[1] )
	return 0;
    /* test for the english version (for those who are used to type yes) */
    if( !ascii_strcasecmp(s, "yes" ) )
	return 1;
    if( *s && strchr( "yY", *s ) && !s[1] )
	return 1;
    return def_answer;
}
Ejemplo n.º 2
0
/*
   Return 1 for okay, 0 for for cancel or DEF_ANSWER for default. 
 */
int
answer_is_okay_cancel (const char *s, int def_answer)
{
  /* TRANSLATORS: See doc/TRANSLATE about this string. */
  const char *long_okay = _("okay|okay");
  /* TRANSLATORS: See doc/TRANSLATE about this string. */
  const char *long_cancel = _("cancel|cancel");
  const char *short_okay = _("oO");
  const char *short_cancel = _("cC");
  
  /* Note: We have to use the locale dependent strcasecmp */
  if ( match_multistr(long_okay,s) )
    return 1;
  if ( match_multistr(long_cancel,s) )
    return 0;
  if ( *s && strchr( short_okay, *s ) && !s[1] )
    return 1;
  if ( *s && strchr( short_cancel, *s ) && !s[1] )
    return 0;
  /* Always test for the English values (not locale here) */
  if ( !ascii_strcasecmp(s, "okay" ) )
    return 1;
  if ( !ascii_strcasecmp(s, "ok" ) )
    return 1;
  if ( !ascii_strcasecmp(s, "cancel" ) )
    return 0;
  if ( *s && strchr( "oO", *s ) && !s[1] )
    return 1;
  if ( *s && strchr( "cC", *s ) && !s[1] )
    return 0;
  return def_answer;
}
Ejemplo n.º 3
0
/****************
 * Return 1 for yes, -1 for quit, or 0 for no
 */
int
answer_is_yes_no_quit ( const char *s )
{
  /* TRANSLATORS: See doc/TRANSLATE about this string. */
  const char *long_yes = _("yes");
  /* TRANSLATORS: See doc/TRANSLATE about this string. */
  const char *long_no = _("no");
  /* TRANSLATORS: See doc/TRANSLATE about this string. */
  const char *long_quit = _("quit");
  const char *short_yes = _("yY");
  const char *short_no = _("nN");
  const char *short_quit = _("qQ");

  /* Note: we have to use a local dependent compare here. */
  if ( match_multistr(long_no,s) )
    return 0;
  if ( match_multistr(long_yes,s) )
    return 1;
  if ( match_multistr(long_quit,s) )
    return -1;
  if ( *s && strchr( short_no, *s ) && !s[1] )
    return 0;
  if ( *s && strchr( short_yes, *s ) && !s[1] )
      return 1;
  if ( *s && strchr( short_quit, *s ) && !s[1] )
    return -1;
  /* but not here. */
  if ( !ascii_strcasecmp(s, "yes" ) )
    return 1;
  if ( !ascii_strcasecmp(s, "quit" ) )
      return -1;
  if ( *s && strchr( "yY", *s ) && !s[1] )
    return 1;
  if ( *s && strchr( "qQ", *s ) && !s[1] )
    return -1;
  return 0;
}