On Monday, September 23, 2002, at 03:52  PM, Zem wrote:
>      length = TREE_STRING_LENGTH (str) - 1;
>   +  if (warn_nonportable_cfstrings)
>   +    {
>   +      char *s = TREE_STRING_POINTER (str);
>   +      int l = 0;
>   +
>   +      while (l < length && isascii (s[l])) l++;
>   +      if (!isascii (s[l]))
>   +   warning ("non-ASCII characters in CFString literal");
>   +    }


   Maybe there is a good reason for this, but I always prefer to write 
non-tricky code.   So, I'd write this more like:

        for (l = 0; l < length; l++) {
                if (!isascii(s[l])) {
                        warning("non-ASCII characters in CFString literal");
                        break;
                }
        }

   The original implementation will call isascii() on the trailing null 
twice (I think).  At any rate, the second implementation is more clear.

   Finally, it seems like it would be good to get a warning about 
embedded nulls in CFString literals -- I know of no case where this is 
valid.

   Just my two cents :)

   Thanks!

-tim

Reply via email to