svn commit: r337862 - in head/usr.bin/indent: . tests

Piotr Pawel Stefaniak pstef at FreeBSD.org
Wed Aug 15 18:19:47 UTC 2018


Author: pstef
Date: Wed Aug 15 18:19:45 2018
New Revision: 337862
URL: https://svnweb.freebsd.org/changeset/base/337862

Log:
  indent(1): bug fix after r336333
  
  The bug was that isalnum() is not exactly equivalent to previous code which
  also allowed characters "$" and "_", so check for those explicitly.
  
  Reported by:	tuexen@

Modified:
  head/usr.bin/indent/lexi.c
  head/usr.bin/indent/tests/float.0
  head/usr.bin/indent/tests/float.0.stdout

Modified: head/usr.bin/indent/lexi.c
==============================================================================
--- head/usr.bin/indent/lexi.c	Wed Aug 15 17:41:19 2018	(r337861)
+++ head/usr.bin/indent/lexi.c	Wed Aug 15 18:19:45 2018	(r337862)
@@ -193,6 +193,7 @@ lexi(struct parser_state *state)
 
     /* Scan an alphanumeric token */
     if (isalnum((unsigned char)*buf_ptr) ||
+	*buf_ptr == '_' || *buf_ptr == '$' ||
 	(buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) {
 	/*
 	 * we have a character or number
@@ -222,7 +223,7 @@ lexi(struct parser_state *state)
 	else
 	    while (isalnum((unsigned char)*buf_ptr) ||
 	        *buf_ptr == BACKSLASH ||
-		*buf_ptr == '_') {
+		*buf_ptr == '_' || *buf_ptr == '$') {
 		/* fill_buffer() terminates buffer with newline */
 		if (*buf_ptr == BACKSLASH) {
 		    if (*(buf_ptr + 1) == '\n') {

Modified: head/usr.bin/indent/tests/float.0
==============================================================================
--- head/usr.bin/indent/tests/float.0	Wed Aug 15 17:41:19 2018	(r337861)
+++ head/usr.bin/indent/tests/float.0	Wed Aug 15 18:19:45 2018	(r337862)
@@ -4,4 +4,5 @@ void t(void) {
 	double y[] = {0x1P+9F, 0.3, .1, 1.2f, 0xa.p01f, 3.14f, 2.L};
 	int z = 0b0101;
 	DO_NOTHING;
+	x._y = 5;
 }

Modified: head/usr.bin/indent/tests/float.0.stdout
==============================================================================
--- head/usr.bin/indent/tests/float.0.stdout	Wed Aug 15 17:41:19 2018	(r337861)
+++ head/usr.bin/indent/tests/float.0.stdout	Wed Aug 15 18:19:45 2018	(r337862)
@@ -6,4 +6,5 @@ t(void)
 	double		y[] = {0x1P+9F, 0.3, .1, 1.2f, 0xa.p01f, 3.14f, 2.L};
 	int		z = 0b0101;
 	DO_NOTHING;
+	x._y = 5;
 }


More information about the svn-src-all mailing list