mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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:
26
fish/fish.c
26
fish/fish.c
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user