On 03/22/13 10:23, Markus Armbruster wrote: > Laszlo Ersek <ler...@redhat.com> writes: >> On 03/14/13 18:49, Markus Armbruster wrote:
>>> +{ >>> + static int min_cp[5] = { 0x80, 0x800, 0x10000, 0x200000, 0x4000000 }; >>> + const unsigned char *p; >>> + unsigned byte, mask, len, i; >>> + int cp; >>> + >>> + if (n == 0) { >>> + *end = (char *)s; >>> + return 0; >>> + } >> >> This is a special case (we return the code point U+0000 after looking at >> zero bytes); we can probably expect the caller to know about n==0. > > We could make it an error instead. What's your gut feeling? (If the question still stands -- maybe it doesn't any more, considering future handling of '\0':) I guess this function would be called in a loop, with increasing "s" and decreasing "n" values. "end" can only be checked after the first call. If you write a loop that checks "end" in the controlling expression, then accepting n==0 without error is useful. If you write a loop that checks "n" in the controlling expression, then refusing n==0 is OK. I'd probably write the latter kind of loop (I like pre-testing more), but I can't say in general :) Laszlo