Re: [PATCH] Enhance virBuffer code

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

 



On Fri, Dec 14, 2007 at 08:34:13AM +0100, Jim Meyering wrote:
> You're right that we shouldn't use isalnum here.
> However, we shouldn't use inequality comparisons, either.
> While 0 <= c <= 9 is guaranteed to be ok for the digits, the
> a..z and A..Z ranges need not be contiguous, i.e., with EBCDIC:
> 
>   http://www.natural-innovations.com/computing/asciiebcdic.html
> 
> so how about this instead?
> 
> int
> is_alphanum (char c)
> {
>   switch (c)
>   {
>     /* generated by LC_ALL=C perl -e \
>        "print map {qq(case '\$_': )}('a'..'z', 'A'..'Z', '0'..'9')"|fmt
>     case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
>     case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
>     case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
>     case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B':
>     case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I':
>     case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P':
>     case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W':
>     case 'X': case 'Y': case 'Z': case '0': case '1': case '2': case '3':
>     case '4': case '5': case '6': case '7': case '8': case '9':

  This makes it unreadable, really no.

> Of course, systems for which this can make a difference (z/OS, S390)
> may not be libvirt portability targets, but better safe than sorry.

  I do that kind range comparison in libxml2. This raised a problem
only once ever on an Unisys mainframe, they upgraded the compiler and
got an ascii option which allowed to fix it without patching libxml2.
  Maintainance wise, I really prefer we keep the status quo.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard@xxxxxxxxxx  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

--
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]