recognise 'F'/'f' suffix in indent
Floating point constants default to double precision and can be made single precision with a 'f' or 'F' suffix or long double precision with 'l' or 'L'. It turns out indent only knows about 'u'/'U' and 'l'/'L' suffixes and will add a space between floating point constants and the suffix if 'f' or 'F' is used which results in code that won't compile. This particular problem broke the build of Mesa master on at least OpenBSD/FreeBSD/Mac OS X: https://bugs.freedesktop.org/show_bug.cgi?id=88335 Index: lexi.c === RCS file: /cvs/src/usr.bin/indent/lexi.c,v retrieving revision 1.17 diff -u -p -r1.17 lexi.c --- lexi.c 11 Oct 2014 03:05:48 - 1.17 +++ lexi.c 16 Jan 2015 13:07:26 - @@ -202,6 +202,12 @@ lexi(void) } break; } + if (!(seensfx 1) + (*buf_ptr == 'F' || *buf_ptr == 'f')) { + CHECK_SIZE_TOKEN; + *e_token++ = *buf_ptr++; + seensfx |= 1; + } } else while (chartype[(int)*buf_ptr] == alphanum) { /* copy it over */
Re: recognise 'F'/'f' suffix in indent
Floating point constants default to double precision and can be made single precision with a 'f' or 'F' suffix or long double precision with 'l' or 'L'. It turns out indent only knows about 'u'/'U' and 'l'/'L' suffixes and will add a space between floating point constants and the suffix if 'f' or 'F' is used which results in code that won't compile. Your diff will allow for `fl' suffixes. What about doing seensfx |= 1 | 2; to make sure a forthcoming `l' suffix gets rejected? Index: lexi.c === RCS file: /cvs/src/usr.bin/indent/lexi.c,v retrieving revision 1.17 diff -u -p -r1.17 lexi.c --- lexi.c11 Oct 2014 03:05:48 - 1.17 +++ lexi.c16 Jan 2015 13:07:26 - @@ -202,6 +202,12 @@ lexi(void) } break; } + if (!(seensfx 1) + (*buf_ptr == 'F' || *buf_ptr == 'f')) { + CHECK_SIZE_TOKEN; + *e_token++ = *buf_ptr++; + seensfx |= 1; + } } else while (chartype[(int)*buf_ptr] == alphanum) { /* copy it over */
Re: recognise 'F'/'f' suffix in indent
On Fri, Jan 16, 2015 at 21:43, Miod Vallat wrote: Floating point constants default to double precision and can be made single precision with a 'f' or 'F' suffix or long double precision with 'l' or 'L'. It turns out indent only knows about 'u'/'U' and 'l'/'L' suffixes and will add a space between floating point constants and the suffix if 'f' or 'F' is used which results in code that won't compile. Your diff will allow for `fl' suffixes. What about doing seensfx |= 1 | 2; to make sure a forthcoming `l' suffix gets rejected? I'm not sure indent needs a precise parser. Isn't that what the compiler is for? As long as it doesn't *generate* incorrect code, I think it's fine. If for some reason the source file I pass to indent has 0.0fl in it, let it through; cc will tell me about it soon enough.
Re: recognise 'F'/'f' suffix in indent
On Fri, Jan 16, 2015 at 09:43:36PM +, Miod Vallat wrote: Floating point constants default to double precision and can be made single precision with a 'f' or 'F' suffix or long double precision with 'l' or 'L'. It turns out indent only knows about 'u'/'U' and 'l'/'L' suffixes and will add a space between floating point constants and the suffix if 'f' or 'F' is used which results in code that won't compile. Your diff will allow for `fl' suffixes. What about doing seensfx |= 1 | 2; to make sure a forthcoming `l' suffix gets rejected? Well it is out of the loop for u/l so it doesn't look like that is possible? Running the patched indent on 1.0fl gives me 1.0f l Index: lexi.c === RCS file: /cvs/src/usr.bin/indent/lexi.c,v retrieving revision 1.17 diff -u -p -r1.17 lexi.c --- lexi.c 11 Oct 2014 03:05:48 - 1.17 +++ lexi.c 16 Jan 2015 13:07:26 - @@ -202,6 +202,12 @@ lexi(void) } break; } + if (!(seensfx 1) + (*buf_ptr == 'F' || *buf_ptr == 'f')) { + CHECK_SIZE_TOKEN; + *e_token++ = *buf_ptr++; + seensfx |= 1; + } } else while (chartype[(int)*buf_ptr] == alphanum) { /* copy it over */