This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] strftime incorrectly combines flags
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Ondrej Oprala <ooprala at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 24 May 2013 09:58:44 -0700
- Subject: Re: [PATCH] strftime incorrectly combines flags
- References: <519F7845 dot 7040703 at redhat dot com>
Three things.
1. The swap-case flag isn't documented, so this patch is fixing
a bug in documented behavior. Shouldn't the flag be documented?
2. I don't see how the patch fixes the %p and %P formats, e.g.,
%^P, %#P, %^#P. Admittedly the code may already be buggy there.
3. For a patch like this:
- if (change_case)
+ if (change_case && (to_uppcase ^ to_lowcase))
{
- to_uppcase = 1;
- to_lowcase = 0;
+ to_uppcase = !to_uppcase;
+ to_lowcase = !to_lowcase;
}
to_lowcase is known to be zero before
the above code is executed, so there's opportunity for
simplification here. How about omitting the 'if' entirely,
and replacing it with something like this?
to_lowcase = change_case & to_uppcase;
to_uppcase ^= change_case;