Subject: bin/6516: indent does not recognize all constant suffixes
To: None <gnats-bugs@gnats.netbsd.org>
From: Brian Ginsbach <ginsbach@sgi.com>
List: netbsd-bugs
Date: 11/30/1998 16:05:30
>Number:         6516
>Category:       bin
>Synopsis:       indent does not recognize all constant suffixes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 30 14:20:00 1998
>Last-Modified:
>Originator:     Brian Ginsbach
>Organization:
Silicon Graphics/Cray Research
>Release:        NetBSD 1.3.2
>Environment:
N.A.


>Description:
	The *BSD indent program does not recognize all constant suffixes
	([fF], [uU], [lL], [uU][lL], [lL][lL], or [uU][lL][lL]).
	Currently only l or L is considered a constant suffix.  As a
	result, it will insert a space between the constant and the
	unrecognized suffix.  This causes these constant declarations
	to be wrong.

>How-To-Repeat:
	Take for example the following code:

	main() {
	  long long ll = 1234567LL;
	  unsigned long long ull = 9876543ULL
	  unsigned u = 0xFFFFFFFFU;
	  float f = 1.234F;

	  printf("%lld, %llu, %u, %f\n", ll, ull, u, f);
	}

	This code is reformatted like this by indent:

	main()
	{
	    long long       ll = 1234567L L;
	    unsigned long long ull = 9876543 ULL;
	    unsigned        u = 0xFFFFFFFF U;
	    float           f = 1.234 F;

	    printf("%lld, %llu, %u, %f\n", ll, ull, u, f);
	}

	This code will not compile because of the incorrect constant
	declarations.

>Fix:
*** /usr/src/usr.bin/indent/lexi.c	Mon May  4 17:55:20 1998
--- ~/dvl/netbsd-src/indent/lexi.c	Mon Nov 30 13:25:28 1998
***************
*** 190,197 ****
  								*e_token++ = *buf_ptr++;
  						}
  				}
! 			if (*buf_ptr == 'L' || *buf_ptr == 'l')
! 				*e_token++ = *buf_ptr++;
  		} else
  			while (chartype[(int) *buf_ptr] == alphanum) {	/* copy it over */
  				CHECK_SIZE_TOKEN;
--- 190,207 ----
  								*e_token++ = *buf_ptr++;
  						}
  				}
! 			if (*buf_ptr == 'F' || *buf_ptr == 'f')
! 				/* float constant */
! 				*e_token = *buf_ptr++;
! 			else {
! 				/* integer constant (U, L, UL, LL, ULL) */
! 				if (*buf_ptr == 'U' || *buf_ptr == 'u')
! 					*e_token++ = *buf_ptr++;
! 				if (*buf_ptr == 'L' || *buf_ptr == 'l')
! 					*e_token++ = *buf_ptr++;
! 				if (*buf_ptr == 'L' || *buf_ptr == 'l')
! 					*e_token++ = *buf_ptr++;
! 			}
  		} else
  			while (chartype[(int) *buf_ptr] == alphanum) {	/* copy it over */
  				CHECK_SIZE_TOKEN;
>Audit-Trail:
>Unformatted: