[Mesa-dev] [PATCH] glsl: Fix absurd whitespace conventions in the parser.

Kenneth Graunke kenneth at whitecape.org
Sat Jul 13 14:58:07 PDT 2013


Historically, we indented grammar production rules with a single 8-space
tab, but code inside of blocks used Mesa's 3-space indents.

This meant when editing code, you had to use an 8-space tab for the
first level of indentation, and 3-spaces after that.  Unless you
specifically configure your editor to understand this, it will get the
indentation wrong on every single line you touch, which quickly devolves
into a colossal waste of time.

It's also inconsistent with every other file in the entire project.

This patch removes all tabs and moves to a consistent 3-space indent.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/glsl_parser.yy | 3387 +++++++++++++++++++++++------------------------
 1 file changed, 1691 insertions(+), 1696 deletions(-)

For your review, I've attached the output of 'git show -b' (which eliminates
whitespace differences).  Otherwise the patch would be huge, and frankly
you're more interested in making sure I didn't sneak in other changes.

The real patch is available in the 'parser' branch of ~kwg/mesa.

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 25bcc65..b8f3df9 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1514,19 +1514,19 @@ basic_type_specifier_nonarray:
    ;
 
 precision_qualifier:
-	HIGHP	  {
+   HIGHP
+   {
       state->check_precision_qualifiers_allowed(&@1);
-
       $$ = ast_precision_high;
    }
-	| MEDIUMP {
+   | MEDIUMP
+   {
       state->check_precision_qualifiers_allowed(&@1);
-
       $$ = ast_precision_medium;
    }
-	| LOWP	  {
+   | LOWP
+   {
       state->check_precision_qualifiers_allowed(&@1);
-
       $$ = ast_precision_low;
    }
    ;
@@ -2092,20 +2092,17 @@ instance_name_opt:
    /* empty */
    {
       $$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
-					     NULL,
-					     NULL);
+                                          NULL, NULL);
    }
    | NEW_IDENTIFIER
    {
       $$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
-					     $1,
-					     NULL);
+                                          $1, NULL);
    }
    | NEW_IDENTIFIER '[' constant_expression ']'
    {
       $$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
-					     $1,
-					     $3);
+                                          $1, $3);
    }
    | NEW_IDENTIFIER '[' ']'
    {
@@ -2113,8 +2110,7 @@ instance_name_opt:
                        "instance block arrays must be explicitly sized\n");
 
       $$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
-					     $1,
-					     NULL);
+                                          $1, NULL);
    }
    ;
 
@@ -2159,8 +2155,7 @@ member_declaration:
 layout_defaults:
    layout_qualifier UNIFORM ';'
    {
-	   if (!state->default_uniform_qualifier->merge_qualifier(& @1, state,
-								  $1)) {
+      if (!state->default_uniform_qualifier->merge_qualifier(& @1, state, $1)) {
          YYERROR;
       }
    }


More information about the mesa-dev mailing list