Messages in this thread | | | From | Rasmus Villemoes <> | Subject | Re: [PATCH v3] sscanf: implement basic character sets | Date | Wed, 24 Feb 2016 01:01:57 +0100 |
| |
On Tue, Feb 23 2016, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
> On that note, it seems that your field width handling is off-by-one.
Sorry about that, it's me who's off-by-one.
Rasmus
> To get rid of the allocation, why not use a small bitmap? Something like > > { > char *s = (char *)va_arg(args, char *); > DECLARE_BITMAP(map, 256) = {0}; > bool negate = false; > > /* a field width is required, and must provide room for at least a '\0' */ > if (field_width <= 0) > return num; >
should be
/* a field width is required */ if (field_width < 0)
and
> while (test_bit((u8)*str, map) && --field_width) {
should be field_width--, exactly as in your code.
| |