fish: Move 'is_true' function to library utilities.

The 'is_true' function can be useful elsewhere, not just for parsing
guestfish command parameters.

This is just code motion.
This commit is contained in:
Richard W.M. Jones
2014-12-17 12:34:53 +00:00
parent d375b7818a
commit bdcd2fabe9
4 changed files with 40 additions and 31 deletions

View File

@@ -1302,32 +1302,6 @@ print_table (char *const *argv)
printf ("%s: %s\n", argv[i], argv[i+1]);
}
int
is_true (const char *str)
{
/* Similar to Tcl_GetBoolean. */
if (STREQ (str, "1") ||
STRCASEEQ (str, "true") ||
STRCASEEQ (str, "t") ||
STRCASEEQ (str, "yes") ||
STRCASEEQ (str, "y") ||
STRCASEEQ (str, "on"))
return 1;
if (STREQ (str, "0") ||
STRCASEEQ (str, "false") ||
STRCASEEQ (str, "f") ||
STRCASEEQ (str, "no") ||
STRCASEEQ (str, "n") ||
STRCASEEQ (str, "off"))
return 0;
fprintf (stderr, _("%s: '%s': invalid boolean value, use 'true' or 'false'\n"),
program_name, str);
return -1;
}
/* Free strings from a non-NULL terminated char** */
static void
free_n_strings (char **str, size_t len)