Re: [PATCH] Support for binary constants

Colin Leitner <[email protected]> Tue, 23 Mar 2010 20:51:56 +0100
Newsgroups gmane.comp.gnu.indent.bugs
Organization colin.de
Message-ID <[email protected]>
David,
here a second patch that adds a regression test for binary constants.

Cheers,
	Colin

--- indent-2.2.10.orig/regression/binary-constants.c	1970-01-01 01:00:00.000000000 +0100
+++ indent-2.2.10.new/regression/binary-constants.c	2010-03-23 20:38:25.462053367 +0100
@@ -0,0 +1 @@
+int foo(void) {0b111000010101UL;0B111000010101;}
--- indent-2.2.10.orig/regression/standard/binary-constants.c	1970-01-01 01:00:00.000000000 +0100
+++ indent-2.2.10.new/regression/standard/binary-constants.c	2010-03-23 20:37:01.661551790 +0100
@@ -0,0 +1,6 @@
+int
+foo (void)
+{
+  0b111000010101UL;
+  0B111000010101;
+}
--- indent-2.2.10.orig/regression/TEST	2008-03-11 19:50:42.000000000 +0100
+++ indent-2.2.10.new/regression/TEST	2010-03-23 20:33:45.785551488 +0100
@@ -31,7 +31,8 @@
 
 EXAMPLES="do.c else.c for.c func-def.c lshift.c ncs.c \
         proto.c typedef.h no-newline.c emacs-compatible.h fp.c unary.c \
-        struct_param.c no-newline2.c no-newline3.c wide.c goto.c"
+        struct_param.c no-newline2.c no-newline3.c wide.c goto.c \
+        binary-constants.c"
 
 BUGS="case-label.c one-line-1.c one-line-2.c one-line-3.c \
         one-line-4.c struct-decl.c sizeof-in-while.c line-break-comment.c \

Am Dienstag, den 23.03.2010, 19:31 +0100 schrieb indent:
> Colin,
> Thanks for the update.
> 
> Please supply a regression test that proves the functionality.
> See the script regression/TEST for examples of how the regression test
> fit together.
> 
> david.
> 
> On 04/03/10 15:17, Colin Leitner wrote:
> > Hello,
> >
> > this is a patch to support binary constants of the form ``0b00101010''. Mostly
> > used in embedded C compilers and gcc supports them too:
> >
> > http://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html
> >
> > Regards,
> > 	Colin Leitner
> >
> > --- indent-2.2.10.orig/ChangeLog	2008-03-11 19:53:21.000000000 +0100
> > +++ indent-2.2.10.new/ChangeLog	2010-03-04 13:40:28.450417903 +0100
> > @@ -1,3 +1,6 @@
> > +2010-03-04 Colin Leitner <[email protected]>
> > +	* lexi.c: Added support for binary constants as understood by a couple of compilers.
> > +
> >  -2008-03-11 david <[email protected]>
> >  	* Re-baselined to the freeBSD indent version to avoid onerous constraints in the old BSD license.
> >  	* Release version 2.2.10
> > --- indent-2.2.10.orig/src/lexi.c	2008-03-11 19:50:42.000000000 +0100
> > +++ indent-2.2.10.new/src/lexi.c	2010-03-04 13:32:37.302911824 +0100
> > @@ -288,6 +288,14 @@
> >                 buf_ptr++;
> >              }
> >           }
> > +         else if ((*buf_ptr == '0') && ((buf_ptr[1] == 'b') || (buf_ptr[1] == 'B')))
> > +         {
> > +            buf_ptr += 2;
> > +            while ((*buf_ptr == '0') || (*buf_ptr == '1'))
> > +            {
> > +               buf_ptr++;
> > +            }
> > +         }
> >           else
> >           {
> >              while (1)
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > bug-indent mailing list
> > [email protected]
> > http://lists.gnu.org/mailman/listinfo/bug-indent
> >
> >   
>