Re: [PATCH v3] sscanf: implement basic character sets
From: Rasmus Villemoes
Date: Tue Feb 23 2016 - 19:02:06 EST
On Tue, Feb 23 2016, Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> 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.