Re: [PATCH] virsh: Clarify escape sequence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/03/2012 07:10 AM, Michal Privoznik wrote:
> Currently, we put no strains on escape sequence possibly leaving users
> with console that cannot be terminated. However, not all ASCII
> characters can be used as escape sequence. Only those falling in
> @ - _ can be; implement and document this constraint.

>  vshGetEscapeChar(const char *s)
>  {
>      if (*s == '^')
> -        return CONTROL(s[1]);
> +        return CONTROL(c_islower(s[1]) ? c_toupper(s[1]) : s[1]);

Unlike toupper(), c_toupper() is safe even on non-alphabetic characters
(that's part of why gnulib wrote "c-ctype.h"); you can shorten this to:

return CONTROL(c_toupper(s[1]));

>  
>      return *s;
>  }
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 1ed2dda..cfdd040 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -19879,6 +19879,16 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
>      vshPrint(ctl, "\n");
>  }
>  
> +static bool
> +vshAllowedEscapeChar(char c)
> +{
> +    /* Allowed escape characters:
> +     * a-z A-Z @ [ \ ] ^ _
> +     */
> +    return ('a' <= c && c <= 'z') ||
> +        ('@' <= c && c <= '_');

Assumes ASCII encoding, but I guess it's okay (no one has really
complained about compiling libvirt on EBCDIC).

ACK with nit fixed.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]